user.vue 16 KB

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