user.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <view class="container">
  3. <view class="user-header">
  4. <view class="user-info" @click="loginOrJump('/pages/profile/profile')">
  5. <u-avatar size="80" :src="userInfo.avatar"></u-avatar>
  6. <text class="nick-name">{{ hasLogin ? userInfo.nickname || '游客' : '点击登录' }}</text>
  7. </view>
  8. </view>
  9. <u-gap height="10" bgColor="#f3f3f3"></u-gap>
  10. <view>
  11. <view class="order-header">
  12. <text class="order-title">我的订单</text>
  13. <view class="see-all">
  14. <text>查看全部</text>
  15. <u-icon name="arrow-right"></u-icon>
  16. </view>
  17. </view>
  18. <view class="order-status-box">
  19. <u-grid :border="false" :col="orderStatusList.length">
  20. <u-grid-item v-for="(item, index) in orderStatusList" :key="index">
  21. <u-icon :name="item.icon" :size="32"></u-icon>
  22. <text class="grid-title">{{ item.title }}</text>
  23. </u-grid-item>
  24. </u-grid>
  25. </view>
  26. </view>
  27. <u-gap height="10" bgColor="#f3f3f3"></u-gap>
  28. <view class="stat-box">
  29. <u-grid :border="false" col="3"
  30. ><u-grid-item v-for="(item, index) in statList" :key="index">
  31. <text class="grid-value">{{ item.value }}</text>
  32. <text class="grid-title">{{ item.title }}</text>
  33. </u-grid-item>
  34. </u-grid>
  35. </view>
  36. <u-gap height="10" bgColor="#f3f3f3"></u-gap>
  37. <u-cell-group class="fun-list">
  38. <u-cell class="fun-item" :border="false" icon="gift" title="分销中心" isLink></u-cell>
  39. <u-cell class="fun-item" :border="false" icon="tags" title="领券中心" isLink></u-cell>
  40. <u-cell class="fun-item" :border="false" icon="coupon" title="我的优惠券" isLink></u-cell>
  41. <u-cell class="fun-item" :border="false" icon="map" title="收货地址" @click="loginOrJump('/pages/address/list')" isLink></u-cell>
  42. </u-cell-group>
  43. <view v-if="hasLogin" class="logout-btn">
  44. <u-button type="error" color="#ea322b" text="退出登录" @click="logout"></u-button>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. export default {
  50. data() {
  51. return {
  52. orderStatusList: [
  53. { icon: 'rmb-circle', title: '待支付' },
  54. { icon: 'car', title: '代发货' },
  55. { icon: 'order', title: '待收货' },
  56. { icon: 'integral', title: '已完成' }
  57. ],
  58. statList: [
  59. { value: '0', title: '我的收藏' },
  60. { value: '0', title: '我的消息' },
  61. { value: '0', title: '我的足迹' }
  62. ]
  63. }
  64. },
  65. onLoad() {
  66. this.$store.dispatch('obtainUserInfo')
  67. },
  68. methods: {
  69. loginOrJump(pageUrl) {
  70. if (!this.hasLogin) {
  71. uni.$u.route('/pages/login/login')
  72. } else {
  73. uni.$u.route(pageUrl)
  74. }
  75. },
  76. logout() {
  77. uni.showModal({
  78. title: '提示',
  79. content: '您确定要退出登录吗',
  80. success: res => {
  81. if (res.confirm) {
  82. console.log('用户点击确定')
  83. this.$store.dispatch('logout')
  84. } else if (res.cancel) {
  85. console.log('用户点击取消')
  86. }
  87. }
  88. })
  89. }
  90. },
  91. computed: {
  92. userInfo() {
  93. return this.$store.state.userInfo
  94. },
  95. hasLogin() {
  96. return this.$store.getters.hasLogin
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. .user-header {
  103. @include flex-center(column);
  104. height: 280rpx;
  105. .user-info {
  106. @include flex-center(column);
  107. .nick-name {
  108. margin-top: 20rpx;
  109. font-size: 32rpx;
  110. font-weight: 700;
  111. }
  112. }
  113. }
  114. .order-header {
  115. @include flex-space-between;
  116. padding: 20rpx 30rpx;
  117. border-bottom: $custom-border-style;
  118. .order-title {
  119. color: #333333;
  120. font-size: 34rpx;
  121. }
  122. .see-all {
  123. height: 40rpx;
  124. @include flex-right;
  125. color: #666666;
  126. font-size: 26rpx;
  127. }
  128. }
  129. .order-status-box {
  130. padding: 40rpx 0;
  131. }
  132. .stat-box {
  133. padding: 20rpx 0;
  134. }
  135. .grid-title {
  136. line-height: 50rpx;
  137. font-size: 26rpx;
  138. }
  139. .grid-value {
  140. line-height: 50rpx;
  141. font-size: 36rpx;
  142. font-weight: 700;
  143. color: #2b85e4;
  144. }
  145. .fun-list {
  146. .fun-item {
  147. padding-top: 10rpx;
  148. padding-bottom: 10rpx;
  149. border-bottom: $custom-border-style;
  150. }
  151. }
  152. .logout-btn {
  153. margin: 60rpx auto 0;
  154. width: 400rpx;
  155. }
  156. </style>