index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view>
  3. <!-- ===================================== tabbar ===================================== -->
  4. <u-navbar
  5. title-color="#fff"
  6. :custom-back="customBack"
  7. :border-bottom="false"
  8. back-icon-color="#CCE8FF"
  9. :background="{ background: '#008CFF' }"
  10. title="我的"
  11. ></u-navbar>
  12. <!-- ===================================== 头像 ===================================== -->
  13. <view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30 u-p-t-30">
  14. <view class="u-m-r-24" @click="clickHead">
  15. <u-avatar :src="userInfo.headImgUrl || pic" size="140"></u-avatar>
  16. </view>
  17. <view class="u-flex-1">
  18. <view class="u-font-18 u-p-b-20">{{ userInfo.nickname || userInfo.mobile }}</view>
  19. <view class="u-font-14">手机号:{{ userInfo.mobile || '暂无' }}</view>
  20. </view>
  21. </view>
  22. <view class="u-m-t-20">
  23. <u-cell-group>
  24. <!-- <u-cell-item title="贵州银行支付" @click="guizhouPay()">
  25. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  26. </u-cell-item>-->
  27. <u-cell-item title="我的车辆" @click="openPage('pages/myCars/myCars', true)">
  28. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  29. </u-cell-item>
  30. <u-cell-item title="停车记录" @click="openPage('pages/center/order/order')">
  31. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="tingchejilu"></u-icon>
  32. </u-cell-item>
  33. </u-cell-group>
  34. </view>
  35. <view class="u-m-t-20">
  36. <u-cell-group>
  37. <!-- <u-cell-item title="充值" @click="openPage('pages/myCars/myCars')">
  38. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="chongzhi"></u-icon>
  39. </u-cell-item>-->
  40. <u-cell-item title="包月" @click="openPage('pages/center/monthly/monthly')">
  41. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="baoyue"></u-icon>
  42. </u-cell-item>
  43. <!-- <u-cell-item title="提现" @click="openPage('pages/center/order/order')">
  44. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="tixian"></u-icon>
  45. </u-cell-item>-->
  46. <!-- <u-cell-item title="退款" @click="openPage('pages/center/order/order')">
  47. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="tuikuan"></u-icon>
  48. </u-cell-item>-->
  49. <!-- <u-cell-item title="账单记录" @click="openPage('pages/center/order/order')">
  50. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="zhangdanjilu"></u-icon>
  51. </u-cell-item>-->
  52. </u-cell-group>
  53. </view>
  54. <!-- <view class="u-m-t-20">
  55. <u-cell-group>
  56. <u-cell-item title="我的优惠" @click="openPage('pages/myCars/myCars')">
  57. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodeyouhui"></u-icon>
  58. </u-cell-item>
  59. </u-cell-group>
  60. </view>-->
  61. <!-- <view class="u-m-t-20">
  62. <u-cell-group>
  63. <u-cell-item title="发票管理" @click="openPage('pages/center/invoice/invoice')">
  64. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="fapiaoguanli"></u-icon>
  65. </u-cell-item>
  66. </u-cell-group>
  67. </view>-->
  68. <view class="u-m-t-20">
  69. <u-cell-group>
  70. <u-cell-item title="消息中心" @click="openPage('pages/message/message', true)">
  71. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="xiaoxi"></u-icon>
  72. <u-badge type="success" :count="messageNum" :offset="[38, 80]"></u-badge>
  73. </u-cell-item>
  74. </u-cell-group>
  75. </view>
  76. <view class="u-m-t-20 u-m-b-40">
  77. <u-cell-group>
  78. <u-cell-item title="拨打客服电话" @click="phoneCall(phoneNo)">
  79. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="dianhua"></u-icon>
  80. </u-cell-item>
  81. </u-cell-group>
  82. </view>
  83. <!-- <view class="u-m-t-20">
  84. <u-cell-group>
  85. <u-cell-item icon="phone" title="手机号登录" @click="openPage('/pages/center/phoneLogin/phoneLogin')"></u-cell-item>
  86. </u-cell-group>
  87. </view>-->
  88. <!-- ===================================== 登出提示 ===================================== -->
  89. <u-modal
  90. v-model="logoutPop"
  91. :title-style="{ color: '#404040' }"
  92. title="登出提示"
  93. :show-confirm-button="true"
  94. confirm-text="确认"
  95. :confirm-style="{ backgroundColor: '#3397FA', color: '#fff' }"
  96. :show-cancel-button="true"
  97. cancel-text="取消"
  98. @cancel="logoutPop = false"
  99. :cancel-style="{ backgroundColor: '#EBF1FF', color: '#3397FA' }"
  100. @confirm="loginOut"
  101. >
  102. <view class="slot-content">
  103. <view class="pay-tips">你确认退出登录吗?</view>
  104. </view>
  105. </u-modal>
  106. <u-toast ref="uToast" />
  107. </view>
  108. </template>
  109. <script>
  110. import getUrlParams from '../../utils/getUrlParams.js'
  111. export default {
  112. data() {
  113. return {
  114. // 默认头像
  115. pic: '/static/img/default-avatar.png',
  116. // 用户信息
  117. userInfo: [],
  118. phoneNo: '0851-38222696',
  119. logoutPop: false,
  120. messageNum: 0
  121. }
  122. },
  123. onLoad() {},
  124. onShow() {
  125. this.getMsgNum()
  126. if (this.$store.state.vuex_hasLogin) {
  127. this.userInfo = this.$store.state.vuex_user;
  128. if (this.$store.state.vuex_wxinfo) {
  129. this.userInfo = Object.assign(this.userInfo, this.$store.state.vuex_wxinfo);
  130. }
  131. } else {
  132. this.userInfo = [];
  133. }
  134. },
  135. methods: {
  136. /**
  137. * 打开新页面
  138. * @param {String} path 跳转路径
  139. * @param {flag} flag 返回存储标识
  140. * */
  141. openPage(path, flag) {
  142. this.$u.route({
  143. url: path
  144. })
  145. if (flag) {
  146. uni.setStorage({
  147. key: 'messageBack',
  148. data: 'pages/center/index'
  149. })
  150. }
  151. },
  152. // 获取消息未读条数
  153. getMsgNum() {
  154. this.$u.api.getIndexData()
  155. .then(res => {
  156. if (res.code === 200) {
  157. let num = 0
  158. if (res.data.news) {
  159. res.data.news.forEach(item => {
  160. if (item.readFlag == 0) {
  161. num += 1
  162. }
  163. })
  164. }
  165. this.messageNum = num
  166. } else {
  167. this.$refs.uToast.show({
  168. title: res.msg,
  169. type: 'error'
  170. })
  171. }
  172. })
  173. },
  174. // tabbar 返回
  175. customBack() {
  176. this.$u.route({
  177. type: 'switchTab',
  178. url: 'pages/index/index'
  179. });
  180. },
  181. // 拨打电话
  182. phoneCall(phone) {
  183. uni.makePhoneCall({
  184. phoneNumber: phone
  185. });
  186. },
  187. // 登出
  188. loginOut() {
  189. this.$u.api.codeV2Api.logoutApi().then(res => {
  190. if (res.code === 200) {
  191. this.$u.vuex('vuex_hasLogin', false);
  192. this.$u.vuex('vuex_token', '');
  193. this.$u.vuex('vuex_user', null);
  194. uni.removeStorage({
  195. key: 'jumpUrl'
  196. });
  197. uni.removeStorage({
  198. key: 'backUrl'
  199. });
  200. setTimeout(() => {
  201. this.logoutPop = false
  202. uni.navigateTo({
  203. url: '/pages/center/phoneLogin/phoneLogin'
  204. })
  205. }, 500)
  206. } else {
  207. this.$refs.uToast.show({
  208. title: res.msg || '登出失败',
  209. type: 'error'
  210. })
  211. }
  212. })
  213. },
  214. // 点击头像
  215. clickHead() {
  216. if (this.$store.state.vuex_hasLogin) {
  217. this.logoutPop = true
  218. }
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="scss" scoped>
  224. page {
  225. background-color: $my-page-bg-color;
  226. }
  227. .user-box {
  228. position: relative;
  229. background-color: $my-main-color;
  230. color: #fff;
  231. &:after {
  232. position: absolute;
  233. right: 0;
  234. bottom: 0;
  235. content: "";
  236. background: url(../../static/img/center-top-bg.png) no-repeat;
  237. background-position: -90rpx 0;
  238. width: 305rpx;
  239. height: 145rpx;
  240. z-index: 999;
  241. }
  242. }
  243. .u-avatar {
  244. border: 10rpx solid #4caeff;
  245. }
  246. .u-cell-box /deep/ .u-cell__left-icon-wrap,
  247. .u-cell-box /deep/ .custom-icon {
  248. color: $my-main-color;
  249. margin-right: 10rpx;
  250. }
  251. .pay-tips {
  252. text-align: center;
  253. margin: 30rpx 0;
  254. }
  255. </style>