user.vue 17 KB

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