user.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  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">UID: {{ userInfo.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/scoreAccumulate')" 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/order/jforder')" 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-item title="交易密码" @click="navTo('/pages/money/moneyPwd')"
  165. thumb="/static/icon/img07.png"></uni-list-item>
  166. <uni-list-item title="转账记录" @click="navTo('/pages/user/zhuanlist')"
  167. thumb="/static/icon/img08.png"></uni-list-item>
  168. </uni-list>
  169. </view>
  170. </view>
  171. </scroll-view>
  172. </view>
  173. </template>
  174. <script>
  175. import {
  176. mapState,
  177. mapMutations
  178. } from 'vuex';
  179. import uniList from '@/components/uni-list/uni-list.vue';
  180. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  181. import {
  182. orderData,
  183. getUserInfo
  184. } from '@/api/user.js';
  185. import {
  186. saveUrl,
  187. interceptor
  188. } from '@/utils/loginUtils.js';
  189. import {
  190. getTime
  191. } from '@/utils/rocessor.js'
  192. let startY = 0,
  193. moveY = 0,
  194. pageAtTop = true;
  195. export default {
  196. components: {
  197. uniList,
  198. uniListItem
  199. },
  200. data() {
  201. return {
  202. coverTransform: 'translateY(0px)',
  203. coverTransition: '0s',
  204. moving: false,
  205. userDowm: 0, //卡片升级专属高度
  206. userMaxDowm: 0, //卡片最高高度
  207. orderTime: '' //分红周期
  208. };
  209. },
  210. onShow() {
  211. // 判断是否已经登录
  212. if (this.hasLogin) {
  213. this.loadBaseData();
  214. }
  215. },
  216. onReady() {
  217. // 初始化获取页面宽度
  218. uni.createSelectorQuery()
  219. .select('.container')
  220. .fields({
  221. size: true
  222. },
  223. data => {
  224. // 计算最多下拉的高度
  225. this.userDowm = Math.floor((data.width / 750) * 185);
  226. // 计算最大触发修改高度事件
  227. this.userMaxDowm = Math.floor((data.width / 750) * 250);
  228. }
  229. )
  230. .exec();
  231. },
  232. // #ifndef MP
  233. // onNavigationBarButtonTap(e) {
  234. // const index = e.index;
  235. // if (index === 0) {
  236. // this.navTo('/pages/set/set');
  237. // } else if (index === 1) {
  238. // // #ifdef APP-PLUS
  239. // const pages = getCurrentPages();
  240. // const page = pages[pages.length - 1];
  241. // const currentWebview = page.$getAppWebview();
  242. // currentWebview.hideTitleNViewButtonRedDot({
  243. // index
  244. // });
  245. // // #endif
  246. // uni.navigateTo({
  247. // url: '/pages/user/notice'
  248. // });
  249. // }
  250. // },
  251. // #endif
  252. computed: {
  253. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  254. },
  255. methods: {
  256. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  257. // 加载初始数据
  258. loadBaseData() {
  259. let obj = this
  260. getUserInfo({})
  261. .then(({
  262. data
  263. }) => {
  264. console.log(this.userInfo, "dasdas");
  265. this.setUserInfo(data);
  266. console.log(data, '111111');
  267. obj.orderTime = getTime(data.cycle_time)
  268. if (obj.orderTime == '') {
  269. return
  270. } else if (data.cycle_time == 0) {
  271. return obj.orderTime = ''
  272. }
  273. console.log(obj.orderTime);
  274. console.log(typeof getTime(data.cycle_time));
  275. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  276. orderData({})
  277. .then(({
  278. data
  279. }) => {
  280. this.setOrderInfo(data);
  281. })
  282. .catch(e => {
  283. this.setOrderInfo({
  284. complete_count: 0, //完成
  285. received_count: 0, //待收货
  286. unshipped_count: 0, //待发货
  287. order_count: 0, //订单总数
  288. unpaid_count: 0 //待付款
  289. });
  290. });
  291. })
  292. .catch(e => {
  293. console.log(e);
  294. });
  295. },
  296. /**
  297. * 统一跳转接口,拦截未登录路由
  298. * navigator标签现在默认没有转场动画,所以用view
  299. */
  300. navTo(url) {
  301. if (!this.hasLogin) {
  302. // 保存地址
  303. saveUrl();
  304. // 登录拦截
  305. interceptor();
  306. } else {
  307. uni.navigateTo({
  308. url
  309. });
  310. }
  311. },
  312. /**
  313. * 会员卡下拉和回弹
  314. * 1.关闭bounce避免ios端下拉冲突
  315. * 2.由于touchmove事件的缺陷(以前做小程序就遇到,比如20跳到40,h5反而好很多),下拉的时候会有掉帧的感觉
  316. * transition设置0.1秒延迟,让css来过渡这段空窗期
  317. * 3.回弹效果可修改曲线值来调整效果,推荐一个好用的bezier生成工具 http://cubic-bezier.com/
  318. */
  319. coverTouchstart(e) {
  320. // console.log(e);
  321. if (pageAtTop === false) {
  322. return;
  323. }
  324. this.coverTransition = 'transform .1s linear';
  325. startY = e.touches[0].clientY;
  326. },
  327. coverTouchmove(e) {
  328. // console.log(e);
  329. moveY = e.touches[0].clientY;
  330. let moveDistance = moveY - startY;
  331. let maxDowm = this.userMaxDowm;
  332. let Dowm = this.userDowm;
  333. if (moveDistance < 0) {
  334. this.moving = false;
  335. return;
  336. }
  337. this.moving = true;
  338. if (moveDistance >= Dowm && moveDistance < maxDowm) {
  339. moveDistance = Dowm;
  340. }
  341. if (moveDistance > 0 && moveDistance <= Dowm) {
  342. this.coverTransform = `translateY(${moveDistance}px)`;
  343. }
  344. },
  345. coverTouchend() {
  346. if (this.moving === false) {
  347. return;
  348. }
  349. this.moving = false;
  350. this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
  351. this.coverTransform = 'translateY(0px)';
  352. }
  353. }
  354. };
  355. </script>
  356. <style lang="scss">
  357. page {
  358. height: 100%;
  359. }
  360. %flex-center {
  361. display: flex;
  362. flex-direction: column;
  363. justify-content: center;
  364. align-items: center;
  365. }
  366. %section {
  367. display: flex;
  368. justify-content: space-around;
  369. align-content: center;
  370. background: #fff;
  371. border-radius: 10rpx;
  372. }
  373. .container {
  374. height: 100%;
  375. background-color: $page-color-base;
  376. }
  377. .content-box {
  378. height: 100%;
  379. }
  380. .vheigh {
  381. height: var(--status-bar-height);
  382. background-color: $base-color;
  383. }
  384. .user-section {
  385. height: 435rpx;
  386. padding: 15rpx 30rpx 0;
  387. position: relative;
  388. .bg {
  389. position: absolute;
  390. left: 0;
  391. top: 0;
  392. width: 100%;
  393. height: 100%;
  394. background-color: $base-color;
  395. }
  396. }
  397. .user-info-box {
  398. height: 180rpx;
  399. color: white;
  400. display: flex;
  401. align-items: center;
  402. justify-content: space-between;
  403. position: relative;
  404. z-index: 1;
  405. .detail {
  406. height: 130rpx;
  407. .portrait-box {
  408. height: 100%;
  409. .portrait {
  410. width: 130rpx;
  411. height: 100%;
  412. border: 5rpx solid #fff;
  413. border-radius: 50%;
  414. }
  415. }
  416. .info-box {
  417. margin-left: 20rpx;
  418. line-height: 1.5;
  419. .username {
  420. font-size: $font-lg + 6rpx;
  421. height: 100%;
  422. }
  423. }
  424. }
  425. .config {
  426. font-size: 48rpx;
  427. height: 130rpx;
  428. .setting {
  429. margin-right: 51rpx;
  430. }
  431. }
  432. }
  433. .vip-card-box {
  434. display: flex;
  435. flex-direction: column;
  436. color: #f7d680;
  437. height: 240rpx;
  438. background: linear-gradient(left, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.8));
  439. border-radius: 16rpx 16rpx 0 0;
  440. overflow: hidden;
  441. position: relative;
  442. padding: 20rpx 24rpx;
  443. .card-bg {
  444. position: absolute;
  445. top: 20rpx;
  446. right: 0;
  447. width: 380rpx;
  448. height: 260rpx;
  449. }
  450. .b-btn {
  451. position: absolute;
  452. right: 20rpx;
  453. top: 16rpx;
  454. width: 132rpx;
  455. height: 40rpx;
  456. text-align: center;
  457. line-height: 40rpx;
  458. font-size: 22rpx;
  459. color: #36343c;
  460. border-radius: 20px;
  461. background: linear-gradient(left, #f9e6af, #ffd465);
  462. z-index: 1;
  463. }
  464. .tit {
  465. font-size: $font-base + 2rpx;
  466. color: #f7d680;
  467. margin-bottom: 28rpx;
  468. .iconfont {
  469. color: #f6e5a3;
  470. margin-right: 16rpx;
  471. }
  472. }
  473. .e-b {
  474. font-size: $font-sm;
  475. color: #d8cba9;
  476. margin-top: 10rpx;
  477. }
  478. }
  479. .cover-container {
  480. background: $page-color-base;
  481. margin-top: -150rpx;
  482. padding: 0 30rpx;
  483. position: relative;
  484. background: #f5f5f5;
  485. padding-bottom: 20rpx;
  486. .arc {
  487. position: absolute;
  488. left: 0;
  489. top: -34rpx;
  490. width: 100%;
  491. height: 36rpx;
  492. }
  493. }
  494. .tj-sction {
  495. @extend %section;
  496. .tj-item {
  497. @extend %flex-center;
  498. flex-direction: column;
  499. height: 140rpx;
  500. font-size: $font-sm;
  501. color: #75787d;
  502. }
  503. .num {
  504. font-size: $font-lg;
  505. color: $font-color-dark;
  506. margin-bottom: 8rpx;
  507. }
  508. }
  509. .item-box {
  510. border-radius: 10rpx;
  511. background-color: white;
  512. margin-top: 20rpx;
  513. .box-title {
  514. line-height: 1;
  515. padding: 30rpx;
  516. .title {
  517. font-size: $font-lg;
  518. font-weight: bold;
  519. }
  520. .link {
  521. font-size: $font-base - 2rpx;
  522. color: $font-color-light;
  523. }
  524. }
  525. .order-section {
  526. @extend %section;
  527. padding: 28rpx 0;
  528. .order-item {
  529. @extend %flex-center;
  530. width: 120rpx;
  531. height: 120rpx;
  532. border-radius: 10rpx;
  533. font-size: $font-sm;
  534. color: $font-color-dark;
  535. }
  536. .iconfont {
  537. font-size: 48rpx;
  538. margin-bottom: 18rpx;
  539. color: #fa436a;
  540. }
  541. .icon-shouhoutuikuan {
  542. font-size: 44rpx;
  543. }
  544. .icon {
  545. height: 50rpx;
  546. width: 48rpx;
  547. margin-bottom: 18rpx;
  548. background-size: 100%;
  549. background-repeat: no-repeat;
  550. background-position: center;
  551. .icon-img {
  552. width: 100%;
  553. height: 100%;
  554. }
  555. }
  556. }
  557. }
  558. .history-section {
  559. // padding: 30rpx 0 0;
  560. margin-top: 20rpx;
  561. background: #fff;
  562. border-radius: 10rpx;
  563. .sec-header {
  564. display: flex;
  565. align-items: center;
  566. font-size: $font-base;
  567. color: $font-color-dark;
  568. line-height: 40rpx;
  569. margin-left: 30rpx;
  570. padding-top: 30rpx;
  571. .iconfont {
  572. font-size: 44rpx;
  573. color: $color-red;
  574. margin-right: 16rpx;
  575. line-height: 40rpx;
  576. }
  577. }
  578. .h-list {
  579. white-space: nowrap;
  580. padding: 30rpx 30rpx 0;
  581. .h-list-image {
  582. display: inline-block;
  583. width: 160rpx;
  584. height: 160rpx;
  585. margin-right: 20rpx;
  586. border-radius: 10rpx;
  587. }
  588. }
  589. }
  590. </style>