user.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <template>
  2. <view class="container">
  3. <view class="vheigh"></view>
  4. <scroll-view class="content-box" scroll-y="true">
  5. <view class="user-section">
  6. <view class="bg">
  7. <image src="../../static/user/bg.png" mode=""></image>
  8. </view>
  9. <view class="user-info-box ">
  10. <view class="detail flex" @click="navTo('/pages/set/userinfo')">
  11. <view class="portrait-box">
  12. <image class="portrait" :src="userInfo.avatar || '/static/error/missing-face.png'"></image>
  13. </view>
  14. <view class="info-box">
  15. <view class="username">{{ userInfo.nickname || '游客' }}111111</view>
  16. <view class="phone">
  17. 18952592739
  18. </view>
  19. </view>
  20. </view>
  21. <view class="config iconfont">
  22. <view class="config-img">
  23. <image src="../../static/user/set.png" mode=""></image>
  24. </view>
  25. <text class="setting " @click="navTo('/pages/set/set')">设置</text>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="order-box">
  30. <view class="order">
  31. <text class="order-font">我的订单</text>
  32. <image src="../../static/user/right01.png" mode=""></image>
  33. </view>
  34. <view class="order1">
  35. <view class="order-content1">
  36. <view class="order-item1" @click="navTo('/pages/money/wallet')" hover-class="common-hover"
  37. :hover-stay-time="50">
  38. <view class="icon1">
  39. <image class="icon-img1" src="/static/user/user01.png" mode="aspectFit"></image>
  40. </view>
  41. <text>待付款</text>
  42. </view>
  43. </view>
  44. <view class="order-content1">
  45. <view class="order-item1" @click="navTo('/pages/money/wallet')" hover-class="common-hover"
  46. :hover-stay-time="50">
  47. <view class="icon1">
  48. <image class="icon-img1" src="/static/user/user02.png" mode="aspectFit"></image>
  49. </view>
  50. <text>待发货</text>
  51. </view>
  52. </view>
  53. <view class="order-content1">
  54. <view class="order-item1" @click="navTo('/pages/money/wallet')" hover-class="common-hover"
  55. :hover-stay-time="50">
  56. <view class="icon1">
  57. <image class="icon-img1" src="/static/user/user03.png" mode="aspectFit"></image>
  58. </view>
  59. <text>待收货</text>
  60. </view>
  61. </view>
  62. <view class="order-content1">
  63. <view class="order-item1" @click="navTo('/pages/money/wallet')" hover-class="common-hover"
  64. :hover-stay-time="50">
  65. <view class="icon1">
  66. <image class="icon-img1" src="/static/user/user04.png" mode="aspectFit"></image>
  67. </view>
  68. <text>已完成</text>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <view class="cover-container" @touchstart="coverTouchstart" @touchmove="coverTouchmove"
  74. @touchend="coverTouchend">
  75. <!-- <image class="arc" src="/static/img/arc.png"></image> -->
  76. <view class="item-box">
  77. <!-- <view class="box-title flex borde-b">
  78. <view class="title"><text>我的资产</text></view>
  79. </view> -->
  80. <view class="order-section">
  81. <view class="order-item" @click="navTo('/pages/user/balance')" hover-class="common-hover"
  82. :hover-stay-time="50">
  83. <view class="icon">
  84. <image class="icon-img" src="/static/user/user09.png" mode="aspectFit"></image>
  85. </view>
  86. <text>我的余额</text>
  87. </view>
  88. <view class="order-item" @click="navTo('/pages/user/yongjin')" hover-class="common-hover"
  89. :hover-stay-time="50">
  90. <view class="icon">
  91. <image class="icon-img" src="/static/user/user06.png" mode="aspectFit"></image>
  92. </view>
  93. <text>我的佣金</text>
  94. </view>
  95. <view class="order-item" @click="navTo('/pages/user/scoreAccumulate')" hover-class="common-hover"
  96. :hover-stay-time="50">
  97. <view class="icon">
  98. <image class="icon-img" src="/static/user/user18.png" mode="aspectFit"></image>
  99. </view>
  100. <text>我的积分</text>
  101. </view>
  102. <view class="order-item" @click="navTo('/pages/user/jifen')" hover-class="common-hover"
  103. :hover-stay-time="50">
  104. <view class="icon">
  105. <image class="icon-img" src="/static/user/user07.png" mode="aspectFit"></image>
  106. </view>
  107. <text>购物积分</text>
  108. </view>
  109. </view>
  110. </view>
  111. <view class="history-section icon">
  112. <uni-list>
  113. <uni-list-item title="我的推广" @click="navTo('/pages/money/wallet')"
  114. thumb="/static/user/user12.png"></uni-list-item>
  115. <uni-list-item title="USDT专区" @click="navTo('/pages/money/USDT')"
  116. thumb="/static/user/user16.png">
  117. </uni-list-item>
  118. <uni-list-item title="收款方式" @click="navTo('/pages/collection/collection')"
  119. thumb="/static/user/user15.png"></uni-list-item>
  120. <uni-list-item title="邀请好友" @click="navTo('/pages/user/invite')"
  121. thumb="/static/user/user11.png">
  122. </uni-list-item>
  123. <uni-list-item title="我的收藏" @click="navTo('/pages/user/favorites')"
  124. thumb="/static/user/user14.png"></uni-list-item>
  125. <uni-list-item title="收货地址" @click="navTo('/pages/set/address')"
  126. thumb="/static/user/user13.png"></uni-list-item>
  127. </uni-list>
  128. </view>
  129. </view>
  130. </scroll-view>
  131. </view>
  132. </template>
  133. <script>
  134. import {
  135. mapState,
  136. mapMutations
  137. } from 'vuex';
  138. import uniList from '@/components/uni-list/uni-list.vue';
  139. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  140. import {
  141. orderData,
  142. userinfo
  143. } from '@/api/user.js';
  144. import {
  145. saveUrl,
  146. interceptor
  147. } from '@/utils/loginUtils.js';
  148. let startY = 0,
  149. moveY = 0,
  150. pageAtTop = true;
  151. export default {
  152. components: {
  153. uniList,
  154. uniListItem
  155. },
  156. data() {
  157. return {
  158. coverTransform: 'translateY(0px)',
  159. coverTransition: '0s',
  160. moving: false,
  161. userDowm: 0, //卡片升级专属高度
  162. userMaxDowm: 0 //卡片最高高度
  163. };
  164. },
  165. onShow() {
  166. // 判断是否已经登录
  167. if (this.hasLogin) {
  168. this.loadBaseData();
  169. }
  170. },
  171. onReady() {
  172. // 初始化获取页面宽度
  173. uni.createSelectorQuery()
  174. .select('.container')
  175. .fields({
  176. size: true
  177. },
  178. data => {
  179. // 计算最多下拉的高度
  180. this.userDowm = Math.floor((data.width / 750) * 185);
  181. // 计算最大触发修改高度事件
  182. this.userMaxDowm = Math.floor((data.width / 750) * 250);
  183. }
  184. )
  185. .exec();
  186. },
  187. // #ifndef MP
  188. // onNavigationBarButtonTap(e) {
  189. // const index = e.index;
  190. // if (index === 0) {
  191. // this.navTo('/pages/set/set');
  192. // } else if (index === 1) {
  193. // // #ifdef APP-PLUS
  194. // const pages = getCurrentPages();
  195. // const page = pages[pages.length - 1];
  196. // const currentWebview = page.$getAppWebview();
  197. // currentWebview.hideTitleNViewButtonRedDot({
  198. // index
  199. // });
  200. // // #endif
  201. // uni.navigateTo({
  202. // url: '/pages/user/notice'
  203. // });
  204. // }
  205. // },
  206. // #endif
  207. computed: {
  208. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  209. },
  210. methods: {
  211. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  212. // 加载初始数据
  213. loadBaseData() {
  214. userinfo({})
  215. .then(({
  216. data
  217. }) => {
  218. this.setUserInfo(data);
  219. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  220. orderData({})
  221. .then(({
  222. data
  223. }) => {
  224. this.setOrderInfo(data);
  225. })
  226. .catch(e => {
  227. this.setOrderInfo({
  228. complete_count: 0, //完成
  229. received_count: 0, //待收货
  230. unshipped_count: 0, //待发货
  231. order_count: 0, //订单总数
  232. unpaid_count: 0 //待付款
  233. });
  234. });
  235. })
  236. .catch(e => {
  237. console.log(e);
  238. });
  239. },
  240. /**
  241. * 统一跳转接口,拦截未登录路由
  242. * navigator标签现在默认没有转场动画,所以用view
  243. */
  244. navTo(url) {
  245. if (!this.hasLogin) {
  246. // 保存地址
  247. saveUrl();
  248. // 登录拦截
  249. interceptor();
  250. } else {
  251. uni.navigateTo({
  252. url
  253. });
  254. }
  255. },
  256. /**
  257. * 会员卡下拉和回弹
  258. * 1.关闭bounce避免ios端下拉冲突
  259. * 2.由于touchmove事件的缺陷(以前做小程序就遇到,比如20跳到40,h5反而好很多),下拉的时候会有掉帧的感觉
  260. * transition设置0.1秒延迟,让css来过渡这段空窗期
  261. * 3.回弹效果可修改曲线值来调整效果,推荐一个好用的bezier生成工具 http://cubic-bezier.com/
  262. */
  263. coverTouchstart(e) {
  264. // console.log(e);
  265. if (pageAtTop === false) {
  266. return;
  267. }
  268. this.coverTransition = 'transform .1s linear';
  269. startY = e.touches[0].clientY;
  270. },
  271. coverTouchmove(e) {
  272. // console.log(e);
  273. moveY = e.touches[0].clientY;
  274. let moveDistance = moveY - startY;
  275. let maxDowm = this.userMaxDowm;
  276. let Dowm = this.userDowm;
  277. if (moveDistance < 0) {
  278. this.moving = false;
  279. return;
  280. }
  281. this.moving = true;
  282. if (moveDistance >= Dowm && moveDistance < maxDowm) {
  283. moveDistance = Dowm;
  284. }
  285. if (moveDistance > 0 && moveDistance <= Dowm) {
  286. this.coverTransform = `translateY(${moveDistance}px)`;
  287. }
  288. },
  289. coverTouchend() {
  290. if (this.moving === false) {
  291. return;
  292. }
  293. this.moving = false;
  294. this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
  295. this.coverTransform = 'translateY(0px)';
  296. }
  297. }
  298. };
  299. </script>
  300. <style lang="scss">
  301. page {
  302. height: 100%;
  303. }
  304. %flex-center {
  305. display: flex;
  306. flex-direction: column;
  307. justify-content: center;
  308. align-items: center;
  309. }
  310. %section {
  311. display: flex;
  312. justify-content: space-around;
  313. align-content: center;
  314. background: #fff;
  315. border-radius: 10rpx;
  316. }
  317. .container {
  318. height: 100%;
  319. background-color: $page-color-base;
  320. }
  321. .user-section {
  322. display: flex;
  323. align-items: center;
  324. justify-content: space-between;
  325. position: relative;
  326. top: 0;
  327. left: 0;
  328. right: 0;
  329. .bg {
  330. width: 100%;
  331. height: 400rpx;
  332. image {
  333. width: 100%;
  334. height: 100%;
  335. }
  336. }
  337. .user-info-box {
  338. width: 100%;
  339. position: absolute;
  340. display: flex;
  341. justify-content: space-between;
  342. align-items: center;
  343. .detail {
  344. margin-left: 20rpx;
  345. .portrait-box {
  346. width: 127rpx;
  347. height: 127rpx;
  348. border-radius: 50%;
  349. .portrait {
  350. width: 100%;
  351. height: 100%;
  352. }
  353. }
  354. .info-box {
  355. padding-left: 15rpx;
  356. display: flex;
  357. flex-direction: column;
  358. justify-content: center;
  359. .username {
  360. font-size: 34rpx;
  361. font-family: PingFang SC;
  362. font-weight: bold;
  363. color: #FFFFFF;
  364. line-height: 44rpx;
  365. }
  366. .phone {
  367. font-size: 26rpx;
  368. font-family: PingFang SC;
  369. font-weight: 500;
  370. color: #FFFFFF;
  371. line-height: 44rpx;
  372. }
  373. }
  374. }
  375. .config {
  376. width: 165rpx;
  377. height: 64rpx;
  378. background: #FFFFFF;
  379. border-radius: 32px 0px 0px 32px;
  380. display: flex;
  381. justify-content: center;
  382. align-items: center;
  383. .config-img {
  384. width: 32rpx;
  385. height: 32rpx;
  386. margin-right: 5rpx;
  387. image {
  388. width: 100%;
  389. height: 100%;
  390. }
  391. }
  392. .setting {
  393. margin-left: 5rpx;
  394. font-size: 28rpx;
  395. font-family: PingFang SC;
  396. font-weight: 500;
  397. color: #438BED;
  398. line-height: 72rpx;
  399. }
  400. }
  401. }
  402. }
  403. .content-box {
  404. height: 100%;
  405. }
  406. .vheigh {
  407. height: var(--status-bar-height);
  408. background-color: $base-color;
  409. }
  410. .cover-container {
  411. background: $page-color-base;
  412. padding: 0 20rpx;
  413. position: relative;
  414. background: #f5f5f5;
  415. padding-bottom: 20rpx;
  416. .arc {
  417. position: absolute;
  418. left: 0;
  419. top: -34rpx;
  420. width: 100%;
  421. height: 36rpx;
  422. }
  423. }
  424. .order-box {
  425. position: relative;
  426. margin: -80rpx 20rpx 0 20rpx;
  427. display: flex;
  428. flex-direction: column;
  429. justify-content: center;
  430. width: 710rpx;
  431. height: 221rpx;
  432. background: #FFFFFF;
  433. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  434. border-radius: 20rpx;
  435. .order {
  436. width: 100%;
  437. height: 80rpx;
  438. padding: 0 35rpx;
  439. border-bottom: #F5F5F5 solid 2rpx;
  440. display: flex;
  441. align-items: center;
  442. justify-content: space-between;
  443. .order-font {
  444. font-size: 30rpx;
  445. font-family: PingFang SC;
  446. font-weight: bold;
  447. color: #333333;
  448. }
  449. image {
  450. width: 12rpx;
  451. height: 22rpx;
  452. }
  453. }
  454. .order1 {
  455. display: flex;
  456. align-items: center;
  457. height: 170rpx;
  458. .order-content1 {
  459. width: 25%;
  460. .order-item1 {
  461. display: flex;
  462. flex-direction: column;
  463. align-items: center;
  464. .icon1 {
  465. width: 42rpx;
  466. height: 38rpx;
  467. .icon-img1 {
  468. width: 100%;
  469. height: 100%;
  470. }
  471. }
  472. text {
  473. font-size: 24rpx;
  474. font-family: PingFang SC;
  475. font-weight: 500;
  476. color: #333333;
  477. line-height: 54rpx;
  478. }
  479. }
  480. }
  481. }
  482. }
  483. .item-box {
  484. border-radius: 10rpx;
  485. background-color: white;
  486. margin-top: 20rpx;
  487. .box-title {
  488. line-height: 1;
  489. padding: 20rpx;
  490. .title {
  491. font-size: $font-lg;
  492. font-weight: bold;
  493. }
  494. .link {
  495. font-size: $font-base - 2rpx;
  496. color: $font-color-light;
  497. }
  498. }
  499. .order-section {
  500. @extend %section;
  501. padding: 28rpx 0;
  502. .order-item {
  503. @extend %flex-center;
  504. width: 120rpx;
  505. height: 120rpx;
  506. border-radius: 10rpx;
  507. font-size: $font-sm;
  508. color: $font-color-dark;
  509. }
  510. .iconfont {
  511. font-size: 48rpx;
  512. margin-bottom: 18rpx;
  513. color: #fa436a;
  514. }
  515. .icon-shouhoutuikuan {
  516. font-size: 44rpx;
  517. }
  518. .icon {
  519. height: 90rpx;
  520. width: 90rpx;
  521. margin-bottom: 18rpx;
  522. background-size: 100%;
  523. background-repeat: no-repeat;
  524. background-position: center;
  525. .icon-img {
  526. width: 100%;
  527. height: 100%;
  528. }
  529. }
  530. }
  531. }
  532. .history-section {
  533. // padding: 30rpx 0 0;
  534. margin-top: 20rpx;
  535. background: #fff;
  536. border-radius: 10rpx;
  537. .sec-header {
  538. display: flex;
  539. align-items: center;
  540. font-size: $font-base;
  541. color: $font-color-dark;
  542. line-height: 40rpx;
  543. margin-left: 30rpx;
  544. padding-top: 30rpx;
  545. .iconfont {
  546. font-size: 44rpx;
  547. color: $color-red;
  548. margin-right: 16rpx;
  549. line-height: 40rpx;
  550. }
  551. }
  552. .h-list {
  553. white-space: nowrap;
  554. padding: 30rpx 30rpx 0;
  555. .h-list-image {
  556. display: inline-block;
  557. width: 160rpx;
  558. height: 160rpx;
  559. margin-right: 20rpx;
  560. border-radius: 10rpx;
  561. }
  562. }
  563. }
  564. </style>