user.vue 17 KB

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