center.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view>
  3. <u-navbar :border-bottom="false" :is-back="false" title="我的"></u-navbar>
  4. <view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-t-30 u-p-b-30">
  5. <view class="u-flex" @click="profile">
  6. <view class="u-m-r-20">
  7. <u-avatar :src="avatar" size="140"></u-avatar>
  8. </view>
  9. <view class="u-flex-1">
  10. <view class="u-font-18 u-p-b-20">{{ vuex_user.user.userName }}</view>
  11. <view class="u-font-14 u-tips-color">昵称:{{ vuex_user.user.nickName }}</view>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="center-nav">
  16. <u-row>
  17. <u-col v-for="(item,index) in navList" :key="index" span="3" text-align="center">
  18. <view v-if="item.name=='问题反馈'">
  19. <!-- 调用微信反馈功能 -->
  20. <button class="clearBtn" hover-class="none" open-type="feedback" style="background-color: #FFFFFF;"
  21. type="default">
  22. <u-icon :name="item.icon" color="#909399" size="50"></u-icon>
  23. <view class="tabName" style="padding-top: 15rpx;">{{ item.name }}</view>
  24. </button>
  25. </view>
  26. <view v-else @click="clickNav(item.url)">
  27. <u-icon :name="item.icon" color="#909399" size="50"></u-icon>
  28. <view class="tabName">{{ item.name }}</view>
  29. </view>
  30. </u-col>
  31. </u-row>
  32. </view>
  33. <view class="u-m-t-20">
  34. <u-cell-group>
  35. <!-- <u-cell-item icon="integral" title="实名认证" @click="setting"></u-cell-item> -->
  36. <u-cell-item icon="setting" title="个人中心" @click="setting"></u-cell-item>
  37. </u-cell-group>
  38. </view>
  39. <view class="u-m-t-20">
  40. <u-cell-group>
  41. <u-cell-item :arrow="false" icon="level" title="技术支持" value="18720989281"
  42. @click="callPhoneNumber"></u-cell-item>
  43. <u-cell-item icon="question-circle" title="常见问题" @click="problem"></u-cell-item>
  44. <u-cell-item icon="star" title="关于我们" @click="aboutMe"></u-cell-item>
  45. </u-cell-group>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import config from "@/common/config.js" // 全局配置文件
  51. export default {
  52. data() {
  53. return {
  54. avatar: uni.getStorageSync('lifeData').vuex_user.user.avatar.includes(config.staticUrl) ? uni.getStorageSync('lifeData').vuex_user.user.avatar : config.staticUrl + uni.getStorageSync('lifeData').vuex_user.user.avatar,
  55. show: true,
  56. navList: [
  57. {name: "浏览记录", icon: "checkmark-circle", url: "pages/center/history"},
  58. {name: "我的收藏", icon: "heart", url: "pages/center/heart"},
  59. {name: "我的委托", icon: "order", url: "pages/center/order"},
  60. {name: "问题反馈", icon: "info-circle"}
  61. ],
  62. }
  63. },
  64. onLoad() {
  65. uni.$on('updateAvatar', (obj) => {
  66. // 获取数据
  67. this.updateAvatar();
  68. })
  69. },
  70. onUnload() {
  71. // 移除监听事件
  72. uni.$off('updateAvatar');
  73. },
  74. onShow() {
  75. // 检查token
  76. this.checkToken();
  77. },
  78. methods: {
  79. logout() {
  80. // 登录成功修改token与用户信息
  81. this.$u.vuex('vuex_token', '');
  82. this.$u.vuex('vuex_user', {});
  83. this.$u.route('/pages/login/login')
  84. },
  85. profile() {
  86. this.$u.route('/pages/profile/profile')
  87. },
  88. setting() {
  89. this.$u.route('/pages/profile/setting')
  90. },
  91. //拨打固定电话
  92. callPhoneNumber() {
  93. uni.makePhoneCall({
  94. phoneNumber: "18720989281",
  95. });
  96. },
  97. problem() {
  98. this.$u.route({
  99. url: 'pages/login/problem'
  100. })
  101. },
  102. // 关于作者
  103. aboutMe() {
  104. this.$u.route('/pages/profile/aboutMe')
  105. },
  106. checkToken() {
  107. // 判断是否有token
  108. let lifeData = uni.getStorageSync('lifeData');
  109. let token = lifeData.vuex_token
  110. if (!token) {
  111. // 没有token 则跳转到登录
  112. return uni.reLaunch({
  113. url: '../login/login'
  114. })
  115. } else {
  116. // 判断Token是否有效
  117. let url = "/api/profile/isExpiration";
  118. this.$u.get(url, {
  119. token: token
  120. }).then(obj => {
  121. if (obj.data) {
  122. // 没有token过期则跳转到登录
  123. return uni.reLaunch({
  124. url: '../login/login'
  125. })
  126. }
  127. });
  128. }
  129. },
  130. code() {
  131. this.$mytip.toast('敬请期待')
  132. },
  133. clickNav(url) {
  134. if (url) {
  135. this.$u.route(url);
  136. } else {
  137. this.$mytip.toast('敬请期待')
  138. }
  139. },
  140. updateAvatar() {
  141. this.avatar = uni.getStorageSync('lifeData').vuex_user.user.avatar.includes(config.staticUrl) ? uni.getStorageSync('lifeData').vuex_user.user.avatar : config.staticUrl + uni.getStorageSync('lifeData').vuex_user.user.avatar
  142. },
  143. }
  144. }
  145. </script>
  146. <style lang="scss">
  147. .user-box {
  148. background-color: #fff;
  149. justify-content: space-between;
  150. }
  151. .center-nav {
  152. background-color: #FFFFFF;
  153. margin-top: 30 rpx;
  154. padding: 30 rpx 0;
  155. border-radius: 8px;
  156. .tabName {
  157. color: #606266;
  158. font-size: 26 rpx;
  159. padding-top: 10 rpx;
  160. }
  161. }
  162. .qiandao {
  163. color: #606266;
  164. font-size: 24 rpx;
  165. margin-right: 24 rpx;
  166. margin-top: 54 rpx;
  167. justify-content: center;
  168. align-items: center;
  169. }
  170. .clearBtn {
  171. margin: 0;
  172. padding: 0;
  173. line-height: 1;
  174. background-color: #FFFFFF;
  175. }
  176. .clearBtn::after {
  177. position: unset !important;
  178. border: unset;
  179. }
  180. </style>