user.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. methods: {
  67. loginOrJump(pageUrl) {
  68. if (!this.hasLogin) {
  69. uni.$u.route('/pages/login/login')
  70. } else {
  71. uni.$u.route(pageUrl)
  72. }
  73. },
  74. logout() {
  75. uni.showModal({
  76. title: '提示',
  77. content: '您确定要退出登录吗',
  78. success: res => {
  79. if (res.confirm) {
  80. console.log('用户点击确定')
  81. this.$store.commit('logout')
  82. } else if (res.cancel) {
  83. console.log('用户点击取消')
  84. }
  85. }
  86. })
  87. }
  88. },
  89. computed: {
  90. userInfo() {
  91. return this.$store.state.userInfo
  92. },
  93. hasLogin() {
  94. return this.$store.getters.hasLogin
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .user-header {
  101. @include flex-center(column);
  102. height: 280rpx;
  103. .user-info {
  104. @include flex-center(column);
  105. .nick-name {
  106. margin-top: 20rpx;
  107. font-size: 32rpx;
  108. font-weight: 700;
  109. }
  110. }
  111. }
  112. .order-header {
  113. @include flex-space-between;
  114. padding: 20rpx 30rpx;
  115. border-bottom: $custom-border-style;
  116. .order-title {
  117. color: #333333;
  118. font-size: 34rpx;
  119. }
  120. .see-all {
  121. height: 40rpx;
  122. @include flex-right;
  123. color: #666666;
  124. font-size: 26rpx;
  125. }
  126. }
  127. .order-status-box {
  128. padding: 40rpx 0;
  129. }
  130. .stat-box {
  131. padding: 20rpx 0;
  132. }
  133. .grid-title {
  134. line-height: 50rpx;
  135. font-size: 26rpx;
  136. }
  137. .grid-value {
  138. line-height: 50rpx;
  139. font-size: 36rpx;
  140. font-weight: 700;
  141. color: #2b85e4;
  142. }
  143. .fun-list {
  144. .fun-item {
  145. padding-top: 10rpx;
  146. padding-bottom: 10rpx;
  147. border-bottom: $custom-border-style;
  148. }
  149. }
  150. .logout-btn {
  151. margin: 60rpx auto 0;
  152. width: 400rpx;
  153. }
  154. </style>