index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <view>
  3. <u-navbar title-color="#fff" :custom-back="customBack" :border-bottom="false" back-icon-color="#CCE8FF" :background="{background: '#008CFF' }" title="我的"></u-navbar>
  4. <view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30 u-p-t-30">
  5. <view class="u-m-r-24" @click="clickHead">
  6. <u-avatar :src="userInfo.headImgUrl || userInfo.avatar||pic" size="140"></u-avatar>
  7. </view>
  8. <view class="u-flex-1" @click="login($store.state.vuex_hasLogin)">
  9. <view class="u-font-18 u-p-b-20">{{ userInfo.nickname || userInfo.userName || '请登录' }}</view>
  10. <view class="u-font-14">手机号:{{ userInfo.mobile || '暂无' }}</view>
  11. </view>
  12. <!-- <view class="u-m-l-10 u-p-10">
  13. <u-icon name="arrow-right" color="#fff" size="28"></u-icon>
  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')">
  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="[35, 60]"></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
  84. v-model="logoutPop"
  85. :title-style="{color: '#404040'}"
  86. title="登出提示"
  87. :show-confirm-button="true"
  88. confirm-text="确认"
  89. :confirm-style="{backgroundColor: '#3397FA', color: '#fff'}"
  90. :show-cancel-button="true"
  91. cancel-text="取消"
  92. @cancel="logoutPop = false"
  93. :cancel-style="{backgroundColor: '#EBF1FF', color: '#3397FA'}"
  94. @confirm="loginOut">
  95. <view class="slot-content">
  96. <view class="pay-tips">你确认退出登录吗?</view>
  97. </view>
  98. </u-modal>
  99. <u-toast ref="uToast" />
  100. </view>
  101. </template>
  102. <script>
  103. import getUrlParams from "../../utils/getUrlParams.js";
  104. export default {
  105. data() {
  106. return {
  107. // 默认头像
  108. pic: '/static/img/default-avatar.png',
  109. // 用户信息
  110. userInfo: [],
  111. code: null,
  112. phoneNo: '16608538666',
  113. logoutPop: false,
  114. messageNum: 0
  115. }
  116. },
  117. onLoad() {
  118. this.getMsgNum()
  119. },
  120. onShow() {
  121. if(this.$store.state.vuex_hasLogin){
  122. this.userInfo = this.$store.state.vuex_user;
  123. if(this.$store.state.vuex_wxinfo){
  124. this.userInfo = Object.assign(this.userInfo,this.$store.state.vuex_wxinfo);
  125. }
  126. }else{
  127. this.userInfo = [];
  128. };
  129. let locationLocaturl = window.location.search;
  130. this.code = getUrlParams(locationLocaturl, "code");
  131. if (this.code&&!this.$store.state.vuex_wxinfo.openId){
  132. this.handleGetWXInfo(this.code)
  133. };
  134. },
  135. methods: {
  136. openPage(path, flag) {
  137. this.$u.route({
  138. url: path
  139. })
  140. if (flag) {
  141. uni.setStorage({
  142. key: 'messageBack',
  143. data: 'pages/center/index'
  144. })
  145. }
  146. },
  147. // 获取消息未读条数
  148. getMsgNum() {
  149. this.$u.api.getIndexData()
  150. .then(res=>{
  151. if (res.code === 200) {
  152. let num = 0
  153. if (res.data.news) {
  154. res.data.news.forEach(item => {
  155. if (item.readFlag == 0) {
  156. num += 1
  157. }
  158. })
  159. }
  160. this.messageNum = num
  161. } else {
  162. this.$refs.uToast.show({
  163. title: res.msg,
  164. type: 'error'
  165. })
  166. }
  167. })
  168. .catch(err => {
  169. this.$refs.uToast.show({
  170. title: '系统错误!',
  171. type: 'error'
  172. })
  173. })
  174. },
  175. //登录判断
  176. login(status){
  177. console.log('this.$store.state.vuex_hasLogin',this.$store.state.vuex_hasLogin);
  178. if(!status){
  179. this.$u.route({
  180. url: 'pages/center/phoneLogin/phoneLogin'
  181. });
  182. }
  183. },
  184. customBack(){
  185. this.$u.route({
  186. type:'switchTab',
  187. url: 'pages/index/index'
  188. });
  189. },
  190. phoneCall(phone){
  191. uni.makePhoneCall({
  192. phoneNumber: phone
  193. });
  194. },
  195. loginOut() {
  196. // this.$store.state.vuex_hasLogin = false
  197. // this.$store.state.vuex_wxinfo = null
  198. // this.$store.state.vuex_token = ''
  199. // this.$store.state.vuex_user = null
  200. this.$u.vuex('vuex_hasLogin', false);
  201. this.$u.vuex('vuex_wxinfo', null);
  202. this.$u.vuex('vuex_token', '');
  203. this.$u.vuex('vuex_user', null);
  204. this.userInfo = []
  205. this.code = ''
  206. localStorage.clear()
  207. setTimeout(() => {
  208. this.logoutPop = false
  209. uni.navigateTo({
  210. url: '/pages/center/phoneLogin/phoneLogin'
  211. })
  212. }, 500)
  213. },
  214. clickHead() {
  215. if (this.$store.state.vuex_hasLogin) {
  216. this.logoutPop = true
  217. }
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. page{background-color: $my-page-bg-color;}
  224. .user-box{
  225. position: relative;
  226. background-color: $my-main-color;
  227. color: #fff;
  228. &:after{
  229. position: absolute;
  230. right: 0;
  231. bottom: 0;
  232. content: '';
  233. background: url(../../static/img/center-top-bg.png) no-repeat;
  234. background-position: -90rpx 0;
  235. width: 305rpx;
  236. height: 145rpx;
  237. z-index: 999;
  238. }
  239. }
  240. .u-avatar{border: 10rpx solid #4CAEFF;}
  241. .u-cell-box /deep/ .u-cell__left-icon-wrap,
  242. .u-cell-box /deep/ .custom-icon
  243. {color: $my-main-color;margin-right: 10rpx;}
  244. .pay-tips {text-align: center;margin: 30rpx 0;}
  245. </style>