user.vue 4.1 KB

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