index.vue 7.9 KB

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