user.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="container">
  3. <view class="user-header">
  4. <view class="user-info" @click="pageRouter('/pages/profile/profile')">
  5. <u-avatar size="60" shape="square" :src="userInfo.avatar"></u-avatar>
  6. <view class="info-text">
  7. <view class="user-nickname">{{ hasLogin ? userInfo.nickname || '会员用户' : '匿名用户' }}</view>
  8. <view class="user-mobile">{{ hasLogin ? userInfo.mobile || ' ' : '登录/注册' }}</view>
  9. </view>
  10. </view>
  11. <view class="user-setting">
  12. <u-icon v-if="hasLogin" name="setting" color="#939393" size="22" @click="pageRouter('/pages/setting/setting')"></u-icon>
  13. </view>
  14. </view>
  15. <u-gap height="10" bgColor="#f3f3f3"></u-gap>
  16. <view>
  17. <view class="order-header">
  18. <text class="order-title">我的订单</text>
  19. <view class="see-all" @click="pageRouter(orderPage, -1)">
  20. <text>查看全部</text>
  21. <u-icon name="arrow-right"></u-icon>
  22. </view>
  23. </view>
  24. <view class="order-status-box">
  25. <u-grid :border="false" :col="orderStatusList.length">
  26. <u-grid-item v-for="(item, index) in orderStatusList" :key="index" @click="pageRouter(orderPage, item.status)">
  27. <u-icon :name="item.icon" :size="32"></u-icon>
  28. <text class="grid-title">{{ item.name }}</text>
  29. </u-grid-item>
  30. </u-grid>
  31. </view>
  32. </view>
  33. <u-gap height="10" bgColor="#f3f3f3"></u-gap>
  34. <view class="stat-box">
  35. <u-grid :border="false" col="3">
  36. <u-grid-item v-for="(item, index) in statList" :key="index">
  37. <text class="grid-value">{{ item.value }}</text>
  38. <text class="grid-title">{{ item.title }}</text>
  39. </u-grid-item>
  40. </u-grid>
  41. </view>
  42. <u-gap height="10" bgColor="#f3f3f3"></u-gap>
  43. <u-cell-group class="fun-list">
  44. <u-cell class="fun-item" :border="false" icon="gift" title="分销中心" isLink></u-cell>
  45. <u-cell class="fun-item" :border="false" icon="tags" title="领券中心" isLink></u-cell>
  46. <u-cell class="fun-item" :border="false" icon="coupon" title="我的优惠券" isLink></u-cell>
  47. <u-cell class="fun-item" :border="false" icon="map" title="收货地址" @click="pageRouter('/pages/address/list')" isLink></u-cell>
  48. </u-cell-group>
  49. </view>
  50. </template>
  51. <script>
  52. import orderStatus from '@/common/orderStatus'
  53. export default {
  54. data() {
  55. return {
  56. orderPage: '/pages/order/list',
  57. statList: [
  58. { value: '0', title: '我的收藏' },
  59. { value: '0', title: '我的消息' },
  60. { value: '0', title: '我的足迹' }
  61. ]
  62. }
  63. },
  64. onLoad() {
  65. if (this.hasLogin) {
  66. this.$store.dispatch('ObtainUserInfo')
  67. }
  68. },
  69. computed: {
  70. userInfo() {
  71. return this.$store.getters.userInfo
  72. },
  73. hasLogin() {
  74. return this.$store.getters.hasLogin
  75. },
  76. orderStatusList() {
  77. let orderStatusList = []
  78. for (let status in orderStatus) {
  79. if (status !== '40') {
  80. orderStatusList.push({ name: orderStatus[status].name, status: status, icon: orderStatus[status].icon })
  81. }
  82. }
  83. return orderStatusList
  84. }
  85. },
  86. methods: {
  87. pageRouter(pageUrl, param) {
  88. if (!this.hasLogin) {
  89. uni.$u.route('/pages/login/social')
  90. } else if (pageUrl === this.orderPage) {
  91. uni.$u.route(this.orderPage, {
  92. status: param
  93. })
  94. } else {
  95. uni.$u.route(pageUrl)
  96. }
  97. },
  98. logout() {
  99. uni.showModal({
  100. title: '提示',
  101. content: '您确定要退出登录吗',
  102. success: res => {
  103. if (res.confirm) {
  104. this.$store.dispatch('Logout')
  105. } else if (res.cancel) {
  106. //console.log('用户点击取消')
  107. }
  108. }
  109. })
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. .user-header {
  116. background-color: #fff;
  117. @include flex-space-between;
  118. padding: 30rpx;
  119. height: 200rpx;
  120. .user-info {
  121. @include flex-left;
  122. align-items: center;
  123. .info-text {
  124. margin-left: 20rpx;
  125. .user-nickname {
  126. font-size: 30rpx;
  127. font-weight: 700;
  128. line-height: 50rpx;
  129. }
  130. .user-mobile {
  131. font-size: 24rpx;
  132. font-weight: 700;
  133. color: #939393;
  134. line-height: 50rpx;
  135. }
  136. }
  137. }
  138. .user-setting {
  139. margin-right: 5rpx;
  140. }
  141. }
  142. .order-header {
  143. @include flex-space-between;
  144. padding: 20rpx 30rpx;
  145. border-bottom: $custom-border-style;
  146. .order-title {
  147. color: #333333;
  148. font-size: 34rpx;
  149. }
  150. .see-all {
  151. height: 40rpx;
  152. @include flex-right;
  153. color: #666666;
  154. font-size: 26rpx;
  155. }
  156. }
  157. .order-status-box {
  158. padding: 40rpx 0;
  159. }
  160. .stat-box {
  161. padding: 20rpx 0;
  162. }
  163. .grid-title {
  164. line-height: 50rpx;
  165. font-size: 26rpx;
  166. }
  167. .grid-value {
  168. line-height: 50rpx;
  169. font-size: 36rpx;
  170. font-weight: 700;
  171. color: #2b85e4;
  172. }
  173. .fun-list {
  174. .fun-item {
  175. padding-top: 10rpx;
  176. padding-bottom: 10rpx;
  177. border-bottom: $custom-border-style;
  178. }
  179. }
  180. </style>