my.vue 9.9 KB

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