user.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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.state)">
  27. <u-icon :name="item.icon" :size="32"></u-icon>
  28. <text class="grid-title">{{ item.title }}</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. export default {
  53. data() {
  54. return {
  55. orderPage: '/pages/order/order',
  56. orderStatusList: [
  57. { icon: 'red-packet', title: '待付款', state: '0' },
  58. { icon: 'car', title: '待发货', state:'20' },
  59. { icon: 'order', title: '待收货', state: '30' },
  60. { icon: 'integral', title: '已完成', state: '40' }
  61. ],
  62. statList: [
  63. { value: '0', title: '我的收藏' },
  64. { value: '0', title: '我的消息' },
  65. { value: '0', title: '我的足迹' }
  66. ]
  67. }
  68. },
  69. onLoad() {
  70. if (this.hasLogin){
  71. this.$store.dispatch('ObtainUserInfo')
  72. }
  73. },
  74. methods: {
  75. pageRouter(pageUrl, param) {
  76. if (!this.hasLogin) {
  77. uni.$u.route('/pages/login/social')
  78. } else if (pageUrl === this.orderPage) {
  79. uni.$u.route(this.orderPage, {
  80. status: param
  81. });
  82. } else {
  83. uni.$u.route(pageUrl)
  84. }
  85. },
  86. logout() {
  87. uni.showModal({
  88. title: '提示',
  89. content: '您确定要退出登录吗',
  90. success: res => {
  91. if (res.confirm) {
  92. this.$store.dispatch('Logout')
  93. } else if (res.cancel) {
  94. //console.log('用户点击取消')
  95. }
  96. }
  97. })
  98. }
  99. },
  100. computed: {
  101. userInfo() {
  102. return this.$store.getters.userInfo
  103. },
  104. hasLogin() {
  105. return this.$store.getters.hasLogin
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped>
  111. .user-header {
  112. background-color: #fff;
  113. @include flex-space-between;
  114. padding: 30rpx;
  115. height: 200rpx;
  116. .user-info {
  117. @include flex-left;
  118. align-items: center;
  119. .info-text {
  120. margin-left: 20rpx;
  121. .user-nickname {
  122. font-size: 30rpx;
  123. font-weight: 700;
  124. line-height: 50rpx;
  125. }
  126. .user-mobile {
  127. font-size: 24rpx;
  128. font-weight: 700;
  129. color: #939393;
  130. line-height: 50rpx;
  131. }
  132. }
  133. }
  134. .user-setting {
  135. margin-right: 5rpx;
  136. }
  137. }
  138. .order-header {
  139. @include flex-space-between;
  140. padding: 20rpx 30rpx;
  141. border-bottom: $custom-border-style;
  142. .order-title {
  143. color: #333333;
  144. font-size: 34rpx;
  145. }
  146. .see-all {
  147. height: 40rpx;
  148. @include flex-right;
  149. color: #666666;
  150. font-size: 26rpx;
  151. }
  152. }
  153. .order-status-box {
  154. padding: 40rpx 0;
  155. }
  156. .stat-box {
  157. padding: 20rpx 0;
  158. }
  159. .grid-title {
  160. line-height: 50rpx;
  161. font-size: 26rpx;
  162. }
  163. .grid-value {
  164. line-height: 50rpx;
  165. font-size: 36rpx;
  166. font-weight: 700;
  167. color: #2b85e4;
  168. }
  169. .fun-list {
  170. .fun-item {
  171. padding-top: 10rpx;
  172. padding-bottom: 10rpx;
  173. border-bottom: $custom-border-style;
  174. }
  175. }
  176. </style>