my.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view class="user">
  3. <!-- 个人信息 -->
  4. <view class="status_bar">
  5. <!-- 这里是状态栏 -->
  6. </view>
  7. <view class="header" @click="userDetail">
  8. <view class="head-1">
  9. <image :src="userInfo.face || '/static/missing-face.png'"></image>
  10. </view>
  11. <view class="head-2" v-if="userInfo.id">
  12. <view class="user-name">{{ userInfo.nickName }}</view>
  13. </view>
  14. <view class="head-2" v-else>
  15. <view class="user-name">登录/注册</view>
  16. </view>
  17. <u-icon style="display: flex;align-items: flex-start;" name="arrow-right"></u-icon>
  18. </view>
  19. <!-- 积分,优惠券,关注, -->
  20. <div class="pointBox box">
  21. <u-row text-align="center" gutter="16" class="point">
  22. <u-col text-align="center" span="4" @click="navigateTo('/pages/mine/deposit/operation')">
  23. <view>预存款</view>
  24. <view class="money">{{ walletNum | unitPrice}}</view>
  25. </u-col>
  26. <u-col text-align="center" span="4" @click="navigateTo('/pages/cart/coupon/myCoupon')">
  27. <view>优惠券</view>
  28. <view>{{ couponNum || 0 }}</view>
  29. </u-col>
  30. <u-col text-align="center" span="4" @click="navigateTo('/pages/mine/myTracks')">
  31. <view>足迹</view>
  32. <view>{{ footNum || 0 }}</view>
  33. </u-col>
  34. </u-row>
  35. <!-- 我的订单,代付款 -->
  36. <view class="order">
  37. <view class="order-item" @click="navigateTo('/pages/order/myOrder?status=0')">
  38. <div class="bag bag1">
  39. <u-icon name="order" size="35" color="#fff"></u-icon>
  40. </div>
  41. <view>我的订单</view>
  42. </view>
  43. <view class="order-item" @click="navigateTo('/pages/order/myOrder?status=1')">
  44. <div class="bag bag2">
  45. <u-icon name="bag-fill" size="35" color="#fff"></u-icon>
  46. </div>
  47. <view>待付款</view>
  48. </view>
  49. <view class="order-item" @click="navigateTo('/pages/order/myOrder?status=3')">
  50. <div class="bag bag3">
  51. <u-icon name="car-fill" size="35" color="#fff"></u-icon>
  52. </div>
  53. <view>待收货</view>
  54. </view>
  55. <view class="order-item" @click="navigateTo('/pages/order/evaluate/myEvaluate')">
  56. <div class="bag bag4">
  57. <u-icon name="star-fill" size="35" color="#fff"></u-icon>
  58. </div>
  59. <view>待评价</view>
  60. </view>
  61. <view class="order-item" @click="navigateTo('/pages/order/afterSales/afterSales')">
  62. <div class="bag bag5">
  63. <u-icon name="server-fill" size="35" color="#fff"></u-icon>
  64. </div>
  65. <view>售后服务</view>
  66. </view>
  67. </view>
  68. </div>
  69. <!-- 常用工具 -->
  70. <tool />
  71. </view>
  72. </template>
  73. <script>
  74. import tool from "@/pages/tabbar/user/utils/tool.vue";
  75. import { getCouponsNum, getFootprintNum } from "@/api/members.js";
  76. import { getUserWallet } from "@/api/members";
  77. let startY = 0,
  78. moveY = 0,
  79. pageAtTop = true;
  80. export default {
  81. components: {
  82. tool,
  83. },
  84. data() {
  85. return {
  86. coverTransform: "translateY(0px)",
  87. coverTransition: "0s",
  88. moving: false,
  89. userInfo: {},
  90. couponNum: "",
  91. footNum: "",
  92. walletNum: "",
  93. };
  94. },
  95. onLoad() {},
  96. onShow() {
  97. this.userInfo = this.$options.filters.isLogin();
  98. if (this.$options.filters.isLogin("auth")) {
  99. this.getUserOrderNum();
  100. }
  101. },
  102. onPullDownRefresh() {
  103. this.getUserOrderNum();
  104. this.userInfo = this.$options.filters.isLogin();
  105. },
  106. // #ifndef MP
  107. onNavigationBarButtonTap(e) {
  108. const index = e.index;
  109. if (index === 0) {
  110. this.navigateTo("/pages/mine/set/setUp");
  111. }
  112. },
  113. // #endif
  114. mounted() {},
  115. methods: {
  116. /**
  117. * 统一跳转接口,拦截未登录路由
  118. * navigator标签现在默认没有转场动画,所以用view
  119. */
  120. navigateTo(url) {
  121. uni.navigateTo({
  122. url,
  123. });
  124. },
  125. userDetail() {
  126. this.userInfo.id
  127. ? this.navigateTo("/pages/mine/set/personMsg")
  128. : this.navigateTo("/pages/passport/login");
  129. },
  130. /**
  131. * 会员卡下拉和回弹
  132. * 1.关闭bounce避免ios端下拉冲突
  133. * 2.由于touchmove事件的缺陷(以前做小程序就遇到,比如20跳到40,h5反而好很多),下拉的时候会有掉帧的感觉
  134. * transition设置0.1秒延迟,让css来过渡这段空窗期
  135. * 3.回弹效果可修改曲线值来调整效果,推荐一个好用的bezier生成工具 http://cubic-bezier.com/
  136. */
  137. coverTouchstart(e) {
  138. if (pageAtTop === false) {
  139. return;
  140. }
  141. this.coverTransition = "transform .1s linear";
  142. startY = e.touches[0].clientY;
  143. },
  144. coverTouchmove(e) {
  145. moveY = e.touches[0].clientY;
  146. let moveDistance = moveY - startY;
  147. if (moveDistance < 0) {
  148. this.moving = false;
  149. return;
  150. }
  151. this.moving = true;
  152. if (moveDistance >= 80 && moveDistance < 100) {
  153. moveDistance = 80;
  154. }
  155. if (moveDistance > 0 && moveDistance <= 80) {
  156. this.coverTransform = `translateY(${moveDistance}px)`;
  157. }
  158. },
  159. coverTouchend() {
  160. if (this.moving === false) {
  161. return;
  162. }
  163. this.moving = false;
  164. this.coverTransition = "transform 0.3s cubic-bezier(.21,1.93,.53,.64)";
  165. this.coverTransform = "translateY(0px)";
  166. },
  167. async getUserOrderNum() {
  168. uni.stopPullDownRefresh();
  169. Promise.all([
  170. getCouponsNum(), //优惠券
  171. getFootprintNum(), //浏览数量
  172. getUserWallet(), //预存款
  173. ]).then((res) => {
  174. this.couponNum = res[0].data.result;
  175. this.footNum = res[1].data.result;
  176. this.walletNum = res[2].data.result.memberWallet;
  177. });
  178. },
  179. },
  180. };
  181. </script>
  182. <style lang="scss" scoped>
  183. html,
  184. body {
  185. overflow: auto;
  186. }
  187. .money {
  188. overflow: hidden;
  189. text-overflow: ellipsis;
  190. white-space: nowrap;
  191. }
  192. .user {
  193. .header {
  194. max-width: 100%;
  195. padding: calc(50rpx + var(--status-bar-height)) 30rpx 0 6%;
  196. height: calc(var(--status-bar-height) + 360rpx);
  197. background-size: cover;
  198. border-bottom-left-radius: 30rpx;
  199. border-bottom-right-radius: 30rpx;
  200. background-image: url("/static/img/main-bg.png");
  201. background-position: bottom;
  202. background-repeat: no-repeat;
  203. color: #ffffff;
  204. display: flex;
  205. justify-content: space-between;
  206. .head-1 {
  207. text-align: center;
  208. width: 152rpx;
  209. position: relative;
  210. display: flex;
  211. align-items: center;
  212. image {
  213. width: 152rpx;
  214. height: 144rpx;
  215. border-radius: 50%;
  216. margin-bottom: 30rpx;
  217. border: 3px solid #fff;
  218. }
  219. .edti-head {
  220. position: absolute;
  221. width: 40rpx;
  222. height: 40rpx;
  223. border-radius: 50%;
  224. background-color: rgba(255, 255, 255, 0.3);
  225. top: 100rpx;
  226. right: 0;
  227. image {
  228. width: 100%;
  229. height: 100%;
  230. }
  231. }
  232. }
  233. .head-2 {
  234. flex: 1;
  235. margin-left: 30rpx;
  236. margin-top: 100rpx;
  237. line-height: 1;
  238. }
  239. /deep/ .u-icon,
  240. .u-icon {
  241. margin-top: 106rpx;
  242. }
  243. }
  244. .pointBox {
  245. width: 94%;
  246. margin: 0 3%;
  247. background: #fff;
  248. border-radius: 20rpx;
  249. box-shadow: 0 4rpx 24rpx 0 rgba($color: #f6f6f6, $alpha: 1);
  250. }
  251. .point {
  252. text-align: center;
  253. height: 160rpx;
  254. font-size: $font-sm;
  255. // #ifdef MP-WEIXIN
  256. padding: 24rpx;
  257. // #endif
  258. .u-col {
  259. view {
  260. color: $u-main-color;
  261. font-size: 28rpx;
  262. }
  263. view:last-child {
  264. margin-top: 8rpx;
  265. color: $main-color;
  266. font-size: $font-lg;
  267. }
  268. }
  269. }
  270. .order {
  271. height: 140rpx;
  272. text-align: center;
  273. font-size: $font-sm;
  274. display: flex;
  275. justify-content: space-around;
  276. align-items: center;
  277. padding: 0 3%;
  278. color: #999;
  279. .order-item {
  280. position: relative;
  281. line-height: 2em;
  282. width: 96rpx;
  283. :first-child {
  284. font-size: 48rpx;
  285. margin-bottom: 10rpx;
  286. }
  287. }
  288. }
  289. }
  290. .box {
  291. transform: translateY(-30rpx);
  292. }
  293. .user-name {
  294. font-size: 34rpx;
  295. }
  296. .bag {
  297. width: 56rpx;
  298. height: 56rpx;
  299. border-radius: 50%;
  300. margin: 0 auto;
  301. }
  302. .bag1 {
  303. background: #ff4a48;
  304. }
  305. .bag2 {
  306. background: #ff992f;
  307. }
  308. .bag3 {
  309. background: #009ee0;
  310. }
  311. .bag4 {
  312. background: #00d5d5;
  313. }
  314. .bag5 {
  315. background: #28ccb0;
  316. }
  317. </style>