index.vue 7.2 KB

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