center.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view>
  3. <view class="top">
  4. <image class="u-bg" src="/static/bg/user.jpg"></image>
  5. <view class="user-wrapper">
  6. <u-avatar :src="avatar" class="avatar" size="140"></u-avatar>
  7. <view class="login-box" @click="setting">
  8. <view class="u-font-18 u-p-b-20">{{ vuex_user.user.nickName }}</view>
  9. <view class="u-font-14">{{ vuex_user.user.userName }}</view>
  10. </view>
  11. </view>
  12. <image class="arc-line" mode="aspectFill" src="/static/icon/arc.png"></image>
  13. </view>
  14. <view class="contain">
  15. <view class="top-nav">
  16. <u-row v-if="vuex_token">
  17. <u-col v-for="(item,index) in topNavList" :key="index" span="4" text-align="center">
  18. <view @click="clickNav(item.url)">
  19. <view class="tabNum">{{ item.num }}</view>
  20. <view class="tabName">{{ item.name }}</view>
  21. </view>
  22. </u-col>
  23. </u-row>
  24. </view>
  25. <view class="center-nav">
  26. <view class="order">
  27. <view class="left">我的订单</view>
  28. <view class="right">
  29. <text class="text" @click="orderList">查看全部</text>
  30. <u-icon color="#ddd" name="arrow-right" size="20"></u-icon>
  31. </view>
  32. </view>
  33. <u-row v-if="vuex_token">
  34. <u-col v-for="(item,index) in navList" :key="index" span="3" text-align="center">
  35. <view @click="clickNav(item.url)">
  36. <u-icon :name="item.icon" color="#ff536f" size="50"></u-icon>
  37. <view class="tabName">{{ item.name }}</view>
  38. </view>
  39. </u-col>
  40. </u-row>
  41. </view>
  42. <view v-if="vuex_token" class="cell-list">
  43. <view class="cell" @click="orderList">
  44. <view class="left">
  45. <u-icon color="#fa436a" name="clock" size="38"></u-icon>
  46. <text class="text">浏览历史</text>
  47. </view>
  48. <view class="right">
  49. <u-icon color="#ddd" name="arrow-right" size="30"></u-icon>
  50. </view>
  51. </view>
  52. <view class="cell" @click="code">
  53. <view class="left">
  54. <u-icon color="#5fcda2" name="integral" size="38"></u-icon>
  55. <text class="text">我的钱包</text>
  56. </view>
  57. <view class="right">
  58. <u-icon color="#ddd" name="arrow-right" size="30"></u-icon>
  59. </view>
  60. </view>
  61. <view class="cell" @click="address">
  62. <view class="left">
  63. <u-icon color="#ee883b" name="map" size="38"></u-icon>
  64. <text class="text">收货地址</text>
  65. </view>
  66. <view class="right">
  67. <u-icon color="#ddd" name="arrow-right" size="30"></u-icon>
  68. </view>
  69. </view>
  70. <view class="cell" @click="code">
  71. <view class="left">
  72. <u-icon color="#54b4ef" name="star" size="38"></u-icon>
  73. <text class="text">我的收藏</text>
  74. </view>
  75. <view class="right">
  76. <u-icon color="#ddd" name="arrow-right" size="30"></u-icon>
  77. </view>
  78. </view>
  79. <view class="cell" @click="problem">
  80. <view class="left">
  81. <u-icon color="#ee883b" name="question-circle" size="38"></u-icon>
  82. <text class="text">常见问题</text>
  83. </view>
  84. <view class="right">
  85. <u-icon color="#ddd" name="arrow-right" size="30"></u-icon>
  86. </view>
  87. </view>
  88. <view class="cell" @click="setting">
  89. <view class="left">
  90. <u-icon color="#37b0fb" name="setting" size="38"></u-icon>
  91. <text class="text">设置</text>
  92. </view>
  93. <view class="right">
  94. <u-icon color="#ddd" name="arrow-right" size="30"></u-icon>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. </template>
  101. <script>
  102. import config from "@/common/config.js" // 全局配置文件
  103. export default {
  104. data() {
  105. return {
  106. 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,
  107. topNavList: [
  108. {name: "余额", num: "0", url: "/pages/detail/preHouse"},
  109. {name: "优惠卷", num: "0", url: "/pages/detail/preHouse"},
  110. {name: "积分", num: "0", url: "/pages/detail/preHouse"},
  111. ],
  112. navList: [
  113. {name: "待付款", icon: "red-packet", url: "/pages/order/order"},
  114. {name: "待发货", icon: "order", url: "/pages/order/order"},
  115. {name: "待收货", icon: "car", url: "/pages/order/order"},
  116. {name: "待评价", icon: "edit-pen", url: "/pages/order/order"}
  117. ],
  118. }
  119. },
  120. onLoad() {
  121. // 检查token
  122. this.checkToken();
  123. uni.$on('updateAvatar', (obj) => {
  124. // 获取数据
  125. this.updateAvatar();
  126. })
  127. },
  128. onUnload() {
  129. // 移除监听事件
  130. uni.$off('updateAvatar');
  131. },
  132. methods: {
  133. login() {
  134. this.$u.route('/pages/login/login')
  135. },
  136. logout() {
  137. // 登录成功修改token与用户信息
  138. this.$u.vuex('vuex_token', '');
  139. this.$u.vuex('vuex_user', {});
  140. this.$u.route('/pages/login/login')
  141. },
  142. setting() {
  143. this.$u.route('/pages/profile/setting')
  144. },
  145. //拨打固定电话
  146. callPhoneNumber() {
  147. uni.makePhoneCall({
  148. phoneNumber: "18720989281",
  149. });
  150. },
  151. problem() {
  152. this.$u.route({
  153. url: 'pages/login/problem'
  154. })
  155. },
  156. checkToken() {
  157. // 判断Token是否有效
  158. let lifeData = uni.getStorageSync('lifeData');
  159. let token = lifeData.vuex_token
  160. if (!token) {
  161. // 没有token 则跳转到登录
  162. return uni.reLaunch({
  163. url: '../login/login'
  164. })
  165. }
  166. },
  167. code() {
  168. this.$mytip.toast('敬请期待')
  169. },
  170. clickNav(url) {
  171. this.$u.route(url);
  172. },
  173. orderList() {
  174. this.$u.route('/pages/order/order')
  175. },
  176. address() {
  177. this.$u.route('/pages/address/address')
  178. },
  179. updateAvatar() {
  180. 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
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="scss">
  186. .top {
  187. position: relative;
  188. overflow: hidden;
  189. padding-top: calc(var(--status-bar-height) + 52rpx);
  190. padding-bottom: 6 rpx;
  191. .u-bg {
  192. position: absolute;
  193. left: 0;
  194. top: 0;
  195. width: 100%;
  196. height: 330 rpx;
  197. }
  198. .user-wrapper {
  199. display: flex;
  200. flex-direction: column;
  201. flex-direction: row;
  202. align-items: center;
  203. position: relative;
  204. z-index: 5;
  205. padding: 20 rpx 30 rpx 60 rpx;
  206. }
  207. .login-box {
  208. font-size: 36 rpx;
  209. color: #fff;
  210. }
  211. .avatar {
  212. flex-shrink: 0;
  213. width: 130 rpx;
  214. height: 130 rpx;
  215. border-radius: 100px;
  216. margin-right: 24 rpx;
  217. border: 4 rpx solid #fff;
  218. background-color: #fff;
  219. }
  220. .username {
  221. font-size: 34 rpx;
  222. color: #fff;
  223. }
  224. .user-group {
  225. align-self: flex-start;
  226. padding: 10 rpx 16 rpx;
  227. margin-top: 16 rpx;
  228. font-size: 20 rpx;
  229. color: #fff;
  230. background-color: rgba(255, 255, 255, .3);
  231. border-radius: 100 rpx;
  232. }
  233. .arc-line {
  234. position: absolute;
  235. left: 0;
  236. bottom: 0;
  237. z-index: 9;
  238. width: 100%;
  239. height: 32 rpx;
  240. }
  241. }
  242. .contain {
  243. padding: 10 rpx 20 rpx;
  244. .top-nav {
  245. background-color: #FFFFFF;
  246. padding: 30 rpx 0;
  247. border-radius: 8px;
  248. .tabNum {
  249. color: $u-main-color;
  250. font-size: 34 rpx;
  251. padding-top: 10 rpx;
  252. font-weight: 500;
  253. }
  254. .tabName {
  255. color: $u-tips-color;
  256. font-size: 22 rpx;
  257. padding-top: 10 rpx;
  258. }
  259. }
  260. .center-nav {
  261. margin-top: 20 rpx;
  262. background-color: #FFFFFF;
  263. padding: 30 rpx 0;
  264. border-radius: 8px;
  265. .order {
  266. padding: 10 rpx 30 rpx 40 rpx 30 rpx;
  267. display: flex;
  268. justify-content: space-between;
  269. align-items: center;
  270. .left {
  271. color: $u-main-color;
  272. font-size: 32 rpx;
  273. padding-top: 10 rpx;
  274. font-weight: 600;
  275. }
  276. .right {
  277. font-size: 22 rpx;
  278. color: $u-tips-color;
  279. .text {
  280. margin-right: 8 rpx;
  281. }
  282. }
  283. }
  284. .tabName {
  285. color: $u-tips-color;
  286. font-size: 26 rpx;
  287. padding-top: 10 rpx;
  288. }
  289. }
  290. .cell-list {
  291. background-color: #fff;
  292. margin-top: 20 rpx;
  293. padding-top: 20 rpx;
  294. .cell {
  295. padding: 20 rpx 30 rpx 40 rpx 30 rpx;
  296. display: flex;
  297. justify-content: space-between;
  298. align-items: center;
  299. .left {
  300. display: flex;
  301. justify-content: space-between;
  302. align-items: center;
  303. color: $u-main-color;
  304. font-size: 30 rpx;
  305. .text {
  306. padding-left: 10 rpx;
  307. }
  308. }
  309. .right {
  310. font-size: 28 rpx;
  311. color: $u-tips-color;
  312. }
  313. }
  314. }
  315. }
  316. </style>