index.vue 7.4 KB

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