index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. code: null,
  121. phoneNo: '18885351206',
  122. logoutPop: false,
  123. messageNum: 0
  124. }
  125. },
  126. onLoad() {},
  127. onShow() {
  128. this.getMsgNum()
  129. if (this.$store.state.vuex_hasLogin) {
  130. this.userInfo = this.$store.state.vuex_user;
  131. if (this.$store.state.vuex_wxinfo) {
  132. this.userInfo = Object.assign(this.userInfo, this.$store.state.vuex_wxinfo);
  133. }
  134. } else {
  135. this.userInfo = [];
  136. };
  137. // let locationLocaturl = window.location.search;
  138. // this.code = getUrlParams(locationLocaturl, "code");
  139. // if (this.code && !this.$store.state.vuex_wxinfo.openId) {
  140. // this.handleGetWXInfo(this.code)
  141. // };
  142. },
  143. methods: {
  144. /**
  145. * 打开新页面
  146. * @param {String} path 跳转路径
  147. * @param {flag} flag 返回存储标识
  148. * */
  149. openPage(path, flag) {
  150. this.$u.route({
  151. url: path
  152. })
  153. if (flag) {
  154. uni.setStorage({
  155. key: 'messageBack',
  156. data: 'pages/center/index'
  157. })
  158. }
  159. },
  160. // 获取消息未读条数
  161. getMsgNum() {
  162. this.$u.api.getIndexData()
  163. .then(res => {
  164. if (res.code === 200) {
  165. let num = 0
  166. if (res.data.news) {
  167. res.data.news.forEach(item => {
  168. if (item.readFlag == 0) {
  169. num += 1
  170. }
  171. })
  172. }
  173. this.messageNum = num
  174. } else {
  175. this.$refs.uToast.show({
  176. title: res.msg,
  177. type: 'error'
  178. })
  179. }
  180. })
  181. .catch(err => {
  182. this.$refs.uToast.show({
  183. title: '系统错误!',
  184. type: 'error'
  185. })
  186. })
  187. },
  188. //登录判断
  189. login(status) {
  190. console.log('this.$store.state.vuex_hasLogin', this.$store.state.vuex_hasLogin);
  191. if (!status) {
  192. this.$u.route({
  193. url: 'pages/center/phoneLogin/phoneLogin'
  194. });
  195. }
  196. },
  197. // tabbar 返回
  198. customBack() {
  199. this.$u.route({
  200. type: 'switchTab',
  201. url: 'pages/index/index'
  202. });
  203. },
  204. // 拨打电话
  205. phoneCall(phone) {
  206. uni.makePhoneCall({
  207. phoneNumber: phone
  208. });
  209. },
  210. // 登出
  211. loginOut() {
  212. this.$u.vuex('vuex_hasLogin', false);
  213. this.$u.vuex('vuex_wxinfo', null);
  214. this.$u.vuex('vuex_token', '');
  215. this.$u.vuex('vuex_user', null);
  216. this.userInfo = []
  217. this.code = ''
  218. localStorage.clear()
  219. setTimeout(() => {
  220. this.logoutPop = false
  221. uni.navigateTo({
  222. url: '/pages/center/phoneLogin/phoneLogin'
  223. })
  224. }, 500)
  225. },
  226. // 点击头像
  227. clickHead() {
  228. if (this.$store.state.vuex_hasLogin) {
  229. this.logoutPop = true
  230. }
  231. }
  232. }
  233. }
  234. </script>
  235. <style lang="scss" scoped>
  236. page {
  237. background-color: $my-page-bg-color;
  238. }
  239. .user-box {
  240. position: relative;
  241. background-color: $my-main-color;
  242. color: #fff;
  243. &:after {
  244. position: absolute;
  245. right: 0;
  246. bottom: 0;
  247. content: "";
  248. background: url(../../static/img/center-top-bg.png) no-repeat;
  249. background-position: -90rpx 0;
  250. width: 305rpx;
  251. height: 145rpx;
  252. z-index: 999;
  253. }
  254. }
  255. .u-avatar {
  256. border: 10rpx solid #4caeff;
  257. }
  258. .u-cell-box /deep/ .u-cell__left-icon-wrap,
  259. .u-cell-box /deep/ .custom-icon {
  260. color: $my-main-color;
  261. margin-right: 10rpx;
  262. }
  263. .pay-tips {
  264. text-align: center;
  265. margin: 30rpx 0;
  266. }
  267. </style>