user.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view class="app">
  3. <!-- 个人信息 -->
  4. <view class="user-wrapper">
  5. <image class="user-background" src="/static/backgroud/user.jpg"></image>
  6. <view class="user">
  7. <!-- 头像 -->
  8. <image class="avatar" :src="userInfo.avatar || '/static/icon/default-avatar.png'" @click="navTo('/pages/set/userInfo', {login: true})"></image>
  9. <!-- 已登陆,展示昵称 -->
  10. <view class="cen column" v-if="hasLogin">
  11. <text class="username f-m">{{ userInfo.nickname }}</text>
  12. <text class="group">普通会员</text>
  13. </view>
  14. <!-- 未登陆,引导登陆 -->
  15. <view class="login-box" v-else @click="navTo('/pages/auth/login')">
  16. <text>点击注册/登录</text>
  17. </view>
  18. </view>
  19. <!-- 下面的圆弧 -->
  20. <image class="user-background-arc-line" src="/static/icon/arc.png" mode="aspectFill"></image>
  21. </view>
  22. <!-- 订单信息 -->
  23. <view class="order-wrap">
  24. <view class="order-header row" @click="navTo('/pages/order/list?current=0', {login: true})">
  25. <text class="title">我的订单</text>
  26. <text class="more">查看全部</text>
  27. <text class="mix-icon icon-you"></text>
  28. </view>
  29. <view class="order-list">
  30. <view class="item center" @click="navTo('/pages/order/list?current=1', {login: true})" hover-class="hover-gray" :hover-stay-time="50">
  31. <text class="mix-icon icon-daifukuan"></text>
  32. <text>待付款</text>
  33. <text v-if="orderCount.c0 > 0" class="number">{{ orderCount.c0 }}</text>
  34. </view>
  35. <view class="item center" @click="navTo('/pages/order/list?current=2', {login: true})" hover-class="hover-gray" :hover-stay-time="50">
  36. <text class="mix-icon icon-daifahuo"></text>
  37. <text>待发货</text>
  38. <text v-if="orderCount.c1 > 0" class="number">{{ orderCount.c1 }}</text>
  39. </view>
  40. <view class="item center" @click="navTo('/pages/order/list?current=3', {login: true})" hover-class="hover-gray" :hover-stay-time="50">
  41. <text class="mix-icon icon-yishouhuo"></text>
  42. <text>待收货</text>
  43. <text v-if="orderCount.c2 > 0" class="number">{{ orderCount.c2 }}</text>
  44. </view>
  45. <view class="item center" @click="navTo('/pages/order/list?current=4', {login: true})" hover-class="hover-gray" :hover-stay-time="50">
  46. <text class="mix-icon icon-daipingjia"></text>
  47. <text>待评价</text>
  48. <text v-if="orderCount.c3 > 0" class="number">{{ orderCount.c3 }}</text>
  49. </view>
  50. </view>
  51. </view>
  52. <!-- 功能入口 -->
  53. <u-cell-group class="option1-wrap">
  54. <u-cell icon="edit-pen" title="个人信息" isLink @click="navTo('/pages/set/userInfo', {login: true})"></u-cell>
  55. <u-cell icon="setting" title="账号安全" isLink @click="navTo('/pages/set/set', {login: true})"></u-cell>
  56. </u-cell-group>
  57. </view>
  58. </template>
  59. <script>
  60. import { mapState, mapGetters } from 'vuex'
  61. import { isLogin } from '@/common/js/util.js'
  62. export default {
  63. data() {
  64. return {
  65. orderCount: { // TODO 芋艿:读取
  66. c0: 1,
  67. c1: 2,
  68. c2: 3,
  69. c3: 4
  70. }
  71. };
  72. },
  73. computed: {
  74. ...mapState(['userInfo']),
  75. ...mapGetters(['hasLogin']),
  76. },
  77. onShow() {
  78. // 获得用户信息 TODO 芋艿:
  79. // if (isLogin()) {
  80. // this.$store.dispatch('obtainUserInfo');
  81. // }
  82. // TODO 芋艿:获得订单数量
  83. }
  84. }
  85. </script>
  86. <style lang="scss">
  87. .app {
  88. padding-bottom: 20rpx;
  89. }
  90. .user-wrapper {
  91. position: relative;
  92. overflow: hidden;
  93. padding-top: calc(var(--status-bar-height) + 52rpx);
  94. padding-bottom: 6rpx;
  95. .user {
  96. display: flex;
  97. flex-direction: column;
  98. flex-direction: row;
  99. align-items: center;
  100. position: relative;
  101. z-index: 5;
  102. padding: 20rpx 30rpx 60rpx;
  103. .avatar {
  104. flex-shrink: 0;
  105. width: 130rpx;
  106. height: 130rpx;
  107. border-radius: 100px;
  108. margin-right: 24rpx;
  109. border: 4rpx solid #fff;
  110. background-color: #fff;
  111. }
  112. .username {
  113. font-size: 34rpx;
  114. color: #fff;
  115. }
  116. .group {
  117. align-self: flex-start;
  118. padding: 10rpx 14rpx;
  119. margin: 16rpx 10rpx; // 10rpx 避免距离昵称太近
  120. font-size: 20rpx;
  121. color: #fff;
  122. background-color: rgba(255, 255, 255,.3);
  123. border-radius: 100rpx;
  124. }
  125. .login-box {
  126. font-size: 36rpx;
  127. color: #fff;
  128. }
  129. }
  130. .user-background {
  131. position: absolute;
  132. left: 0;
  133. top: 0;
  134. width: 100%;
  135. height: 330rpx;
  136. }
  137. .user-background-arc-line {
  138. position: absolute;
  139. left: 0;
  140. bottom: 0;
  141. z-index: 9;
  142. width: 100%;
  143. height: 32rpx;
  144. }
  145. }
  146. .order-wrap {
  147. width: 700rpx;
  148. margin: 20rpx auto 0;
  149. background: #fff;
  150. border-radius: 10rpx;
  151. .order-header {
  152. padding: 28rpx 20rpx 6rpx 26rpx;
  153. .title {
  154. flex: 1;
  155. font-size: 32rpx;
  156. color: #333;
  157. font-weight: 700;
  158. }
  159. .more {
  160. font-size: 24rpx;
  161. color: #999;
  162. }
  163. .icon-you {
  164. margin-left: 4rpx;
  165. font-size: 20rpx;
  166. color: #999;
  167. }
  168. }
  169. .order-list {
  170. display:flex;
  171. justify-content: space-around;
  172. padding: 20rpx 0;
  173. .item{
  174. flex-direction: column;
  175. width: 130rpx;
  176. height: 130rpx;
  177. border-radius: 8rpx;
  178. font-size: 24rpx;
  179. color: #606266;
  180. position: relative;
  181. .mix-icon {
  182. font-size: 50rpx;
  183. margin-bottom: 20rpx;
  184. color: #fa436a;
  185. }
  186. .icon-shouhoutuikuan {
  187. font-size: 44rpx;
  188. }
  189. .number {
  190. position: absolute;
  191. right: 22rpx;
  192. top: 6rpx;
  193. min-width: 34rpx;
  194. height: 34rpx;
  195. line-height: 30rpx;
  196. text-align: center;
  197. padding: 0 8rpx;
  198. font-size: 18rpx;
  199. color: #fff;
  200. border: 2rpx solid #fff;
  201. background-color: $base-color;
  202. border-radius: 100rpx;
  203. }
  204. }
  205. }
  206. }
  207. </style>