user.vue 13 KB

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