index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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="pic" size="140"></u-avatar>
  16. <!-- <u-avatar :src="userInfo.headImgUrl || userInfo.avatar || pic" size="140"></u-avatar> -->
  17. </view>
  18. <view class="u-flex-1" @click="login($store.state.vuex_hasLogin)">
  19. <!-- <view class="u-font-18 u-p-b-20">{{ userInfo.nickname || userInfo.userName || '请登录' }}</view> -->
  20. <view class="u-font-18 u-p-b-20">{{ userInfo.mobile || '请登录' }}</view>
  21. <view class="u-font-14">手机号:{{ userInfo.mobile || '暂无' }}</view>
  22. </view>
  23. </view>
  24. <view class="u-m-t-20">
  25. <u-cell-group>
  26. <!-- <u-cell-item title="贵州银行支付" @click="guizhouPay()">
  27. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  28. </u-cell-item>-->
  29. <u-cell-item title="我的车辆" @click="openPage('pages/myCars/myCars', true)">
  30. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
  31. </u-cell-item>
  32. <u-cell-item title="停车记录" @click="openPage('pages/center/order/order')">
  33. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="tingchejilu"></u-icon>
  34. </u-cell-item>
  35. </u-cell-group>
  36. </view>
  37. <view class="u-m-t-20">
  38. <u-cell-group>
  39. <!-- <u-cell-item title="充值" @click="openPage('pages/myCars/myCars')">
  40. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="chongzhi"></u-icon>
  41. </u-cell-item>-->
  42. <u-cell-item title="包月" @click="openPage('pages/center/monthly/monthly')">
  43. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="baoyue"></u-icon>
  44. </u-cell-item>
  45. <!-- <u-cell-item title="提现" @click="openPage('pages/center/order/order')">
  46. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="tixian"></u-icon>
  47. </u-cell-item>-->
  48. <!-- <u-cell-item title="退款" @click="openPage('pages/center/order/order')">
  49. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="tuikuan"></u-icon>
  50. </u-cell-item>-->
  51. <!-- <u-cell-item title="账单记录" @click="openPage('pages/center/order/order')">
  52. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="zhangdanjilu"></u-icon>
  53. </u-cell-item>-->
  54. </u-cell-group>
  55. </view>
  56. <!-- <view class="u-m-t-20">
  57. <u-cell-group>
  58. <u-cell-item title="我的优惠" @click="openPage('pages/myCars/myCars')">
  59. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodeyouhui"></u-icon>
  60. </u-cell-item>
  61. </u-cell-group>
  62. </view>-->
  63. <!-- <view class="u-m-t-20">
  64. <u-cell-group>
  65. <u-cell-item title="发票管理" @click="openPage('pages/center/invoice/invoice')">
  66. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="fapiaoguanli"></u-icon>
  67. </u-cell-item>
  68. </u-cell-group>
  69. </view>-->
  70. <view class="u-m-t-20">
  71. <u-cell-group>
  72. <u-cell-item title="消息中心" @click="openPage('pages/message/message', true)">
  73. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="xiaoxi"></u-icon>
  74. <u-badge type="success" :count="messageNum" :offset="[38, 80]"></u-badge>
  75. </u-cell-item>
  76. </u-cell-group>
  77. </view>
  78. <view class="u-m-t-20 u-m-b-40">
  79. <u-cell-group>
  80. <u-cell-item title="拨打客服电话" @click="phoneCall(phoneNo)">
  81. <u-icon slot="icon" custom-prefix="custom-icon" size="35" name="dianhua"></u-icon>
  82. </u-cell-item>
  83. </u-cell-group>
  84. </view>
  85. <!-- <view class="u-m-t-20">
  86. <u-cell-group>
  87. <u-cell-item icon="phone" title="手机号登录" @click="openPage('/pages/center/phoneLogin/phoneLogin')"></u-cell-item>
  88. </u-cell-group>
  89. </view>-->
  90. <!-- ===================================== 登出提示 ===================================== -->
  91. <u-modal
  92. v-model="logoutPop"
  93. :title-style="{ color: '#404040' }"
  94. title="登出提示"
  95. :show-confirm-button="true"
  96. confirm-text="确认"
  97. :confirm-style="{ backgroundColor: '#3397FA', color: '#fff' }"
  98. :show-cancel-button="true"
  99. cancel-text="取消"
  100. @cancel="logoutPop = false"
  101. :cancel-style="{ backgroundColor: '#EBF1FF', color: '#3397FA' }"
  102. @confirm="loginOut"
  103. >
  104. <view class="slot-content">
  105. <view class="pay-tips">你确认退出登录吗?</view>
  106. </view>
  107. </u-modal>
  108. <u-toast ref="uToast" />
  109. </view>
  110. </template>
  111. <script>
  112. import getUrlParams from '../../utils/getUrlParams.js'
  113. export default {
  114. data() {
  115. return {
  116. // 默认头像
  117. pic: '/static/img/default-avatar.png',
  118. // 用户信息
  119. userInfo: [],
  120. phoneNo: '0851-38222696',
  121. logoutPop: false,
  122. messageNum: 0
  123. }
  124. },
  125. onLoad() {},
  126. onShow() {
  127. this.getMsgNum()
  128. if (this.$store.state.vuex_hasLogin) {
  129. this.userInfo = this.$store.state.vuex_user;
  130. if (this.$store.state.vuex_wxinfo) {
  131. this.userInfo = Object.assign(this.userInfo, this.$store.state.vuex_wxinfo);
  132. }
  133. } else {
  134. this.userInfo = [];
  135. }
  136. },
  137. methods: {
  138. /**
  139. * 打开新页面
  140. * @param {String} path 跳转路径
  141. * @param {flag} flag 返回存储标识
  142. * */
  143. openPage(path, flag) {
  144. this.$u.route({
  145. url: path
  146. })
  147. if (flag) {
  148. uni.setStorage({
  149. key: 'messageBack',
  150. data: 'pages/center/index'
  151. })
  152. }
  153. },
  154. // 获取消息未读条数
  155. getMsgNum() {
  156. this.$u.api.getIndexData()
  157. .then(res => {
  158. if (res.code === 200) {
  159. let num = 0
  160. if (res.data.news) {
  161. res.data.news.forEach(item => {
  162. if (item.readFlag == 0) {
  163. num += 1
  164. }
  165. })
  166. }
  167. this.messageNum = num
  168. } else {
  169. this.$refs.uToast.show({
  170. title: res.msg,
  171. type: 'error'
  172. })
  173. }
  174. })
  175. },
  176. // tabbar 返回
  177. customBack() {
  178. this.$u.route({
  179. type: 'switchTab',
  180. url: 'pages/index/index'
  181. });
  182. },
  183. // 拨打电话
  184. phoneCall(phone) {
  185. uni.makePhoneCall({
  186. phoneNumber: phone
  187. });
  188. },
  189. // 登出
  190. loginOut() {
  191. this.$u.api.codeV2Api.logoutApi().then(res => {
  192. if (res.code === 200) {
  193. this.$u.vuex('vuex_hasLogin', false);
  194. this.$u.vuex('vuex_token', '');
  195. this.$u.vuex('vuex_user', null);
  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>