index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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 || 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="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="callPhoneShow = true">
  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. <u-select v-model="callPhoneShow" :list="callPhoneList" @confirm="phoneCall"></u-select>
  84. <view class="u-m-t-20">
  85. <u-cell-group>
  86. <u-cell-item icon="coupon" title="我的优惠券" @click="openPage('/pages/center/coupon/myCoupon/myCoupon')"></u-cell-item>
  87. </u-cell-group>
  88. </view>
  89. <!-- ===================================== 登出提示 ===================================== -->
  90. <u-modal
  91. v-model="logoutPop"
  92. :title-style="{ color: '#404040' }"
  93. title="登出提示"
  94. :show-confirm-button="true"
  95. confirm-text="确认"
  96. :confirm-style="{ backgroundColor: '#3397FA', color: '#fff' }"
  97. :show-cancel-button="true"
  98. cancel-text="取消"
  99. @cancel="logoutPop = false"
  100. :cancel-style="{ backgroundColor: '#EBF1FF', color: '#3397FA' }"
  101. @confirm="loginOut"
  102. >
  103. <view class="slot-content">
  104. <view class="pay-tips">你确认退出登录吗?</view>
  105. </view>
  106. </u-modal>
  107. <u-toast ref="uToast" />
  108. </view>
  109. </template>
  110. <script>
  111. import getUrlParams from '../../utils/getUrlParams.js';
  112. export default {
  113. data() {
  114. return {
  115. // 默认头像
  116. pic: '/static/img/default-avatar.png',
  117. // 用户信息
  118. userInfo: [],
  119. logoutPop: false,
  120. messageNum: 0,
  121. callPhoneShow: false,
  122. callPhoneList: []
  123. };
  124. },
  125. onLoad() {},
  126. onShow() {
  127. this.getMsgNum();
  128. this.getDict();
  129. if (this.vuex_hasLogin) {
  130. this.userInfo = this.vuex_user;
  131. if (this.vuex_wxinfo) {
  132. this.userInfo = Object.assign(this.userInfo, this.vuex_wxinfo);
  133. }
  134. } else {
  135. this.userInfo = [];
  136. }
  137. },
  138. methods: {
  139. /**
  140. * 获取客服电话字典
  141. */
  142. getDict() {
  143. this.$u.api
  144. .getDictApi({
  145. type: 'customer_service_phone'
  146. })
  147. .then((res) => {
  148. if (res.code === 200) {
  149. this.callPhoneList = res.data.map((item) => {
  150. return {
  151. value: item.dictValue,
  152. label: item.dictLabel
  153. };
  154. });
  155. }
  156. });
  157. },
  158. /**
  159. * 打开新页面
  160. * @param {String} path 跳转路径
  161. * @param {flag} flag 返回存储标识
  162. * */
  163. openPage(path, flag) {
  164. this.$u.route({
  165. url: path
  166. });
  167. if (flag) {
  168. uni.setStorage({
  169. key: 'messageBack',
  170. data: 'pages/center/index'
  171. });
  172. }
  173. },
  174. // 获取消息未读条数
  175. getMsgNum() {
  176. this.$u.api.getIndexData().then((res) => {
  177. if (res.code === 200) {
  178. let num = 0;
  179. if (res.data.news) {
  180. res.data.news.forEach((item) => {
  181. if (item.readFlag == 0) {
  182. num += 1;
  183. }
  184. });
  185. }
  186. this.messageNum = num;
  187. } else {
  188. this.$refs.uToast.show({
  189. title: res.msg,
  190. type: 'error'
  191. });
  192. }
  193. });
  194. },
  195. // tabbar 返回
  196. customBack() {
  197. this.$u.route({
  198. type: 'switchTab',
  199. url: 'pages/index/index'
  200. });
  201. },
  202. // 拨打电话
  203. phoneCall(phone) {
  204. uni.makePhoneCall({
  205. phoneNumber: phone[0].value || '0851-38222696'
  206. });
  207. },
  208. // 登出
  209. loginOut() {
  210. this.$u.api.codeV2Api.logoutApi().then((res) => {
  211. if (res.code === 200) {
  212. this.$u.vuex('vuex_hasLogin', false);
  213. this.$u.vuex('vuex_token', '');
  214. this.$u.vuex('vuex_user', null);
  215. uni.removeStorage({
  216. key: 'jumpUrl'
  217. });
  218. uni.removeStorage({
  219. key: 'backUrl'
  220. });
  221. setTimeout(() => {
  222. this.logoutPop = false;
  223. uni.navigateTo({
  224. url: '/pages/center/phoneLogin/phoneLogin'
  225. });
  226. }, 500);
  227. } else {
  228. this.$refs.uToast.show({
  229. title: res.msg || '登出失败',
  230. type: 'error'
  231. });
  232. }
  233. });
  234. },
  235. // 点击头像
  236. clickHead() {
  237. if (this.$store.state.vuex_hasLogin) {
  238. this.logoutPop = true;
  239. }
  240. }
  241. }
  242. };
  243. </script>
  244. <style lang="scss" scoped>
  245. page {
  246. background-color: $my-page-bg-color;
  247. }
  248. .user-box {
  249. position: relative;
  250. background-color: $my-main-color;
  251. color: #fff;
  252. &:after {
  253. position: absolute;
  254. right: 0;
  255. bottom: 0;
  256. content: '';
  257. background: url(../../static/img/center-top-bg.png) no-repeat;
  258. background-position: -90rpx 0;
  259. width: 305rpx;
  260. height: 145rpx;
  261. z-index: 999;
  262. }
  263. }
  264. .u-avatar {
  265. border: 10rpx solid #4caeff;
  266. }
  267. .u-cell-box /deep/ .u-cell__left-icon-wrap,
  268. .u-cell-box /deep/ .custom-icon {
  269. color: $my-main-color;
  270. margin-right: 10rpx;
  271. }
  272. .pay-tips {
  273. text-align: center;
  274. margin: 30rpx 0;
  275. }
  276. </style>