user.vue 16 KB

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