user.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. <template>
  2. <view class="container">
  3. <scroll-view class="content-box" scroll-y="true">
  4. <view class="user-section">
  5. <view class="bg"><image src="/static/user/bg.png" mode=""></image></view>
  6. <view class="user-info-box ">
  7. <view class="detail flex">
  8. <view class="portrait-box" @click="navTo('/pages/set/userinfo')">
  9. <image class="portrait" :src="userInfo.avatar || '/static/error/missing-face.png'"></image>
  10. </view>
  11. <view class="info-box">
  12. <view class="info-top flex">
  13. <view class="username clamp">{{ userInfo.nickname || '游客' }}</view>
  14. <view class="vip" v-if="userInfo.level > 0">
  15. <image class="vip-bg" src="../../static/img/vip.png" mode=""></image>
  16. <view class="vip-title">V{{ userInfo.level }}会员</view>
  17. </view>
  18. </view>
  19. <view class="font-size-sm">{{ userInfo.account }}</view>
  20. </view>
  21. </view>
  22. <view class="my-info flex" @click="navTo('/pages/set/userinfo')" v-if="hasLogin">
  23. <image src="../../static/user/set.png" mode=""></image>
  24. <view class="title">设置</view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 订单 -->
  29. <view class="item-box item-box-b">
  30. <view class="box-title flex borde-b">
  31. <view class="title"><text>我的订单</text></view>
  32. <view class="link" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover"><text class="iconfont iconenter"></text></view>
  33. </view>
  34. <view class="order-section">
  35. <view class="order-item" @click="navTo('/pages/order/order?state=0')" hover-class="common-hover" :hover-stay-time="50">
  36. <view class=" icon position-relative">
  37. <image class="icon-img" src="/static/user/order1.png" mode="aspectFit"></image>
  38. <view class="corner" v-if="orderInfo.unpaid_count > 0">
  39. <text>{{ orderInfo.unpaid_count }}</text>
  40. </view>
  41. </view>
  42. <text>待付款</text>
  43. </view>
  44. <view class="order-item" @click="navTo('/pages/order/order?state=1')" hover-class="common-hover" :hover-stay-time="50">
  45. <view class=" icon position-relative">
  46. <image class="icon-img" src="/static/user/order2.png" mode="aspectFit"></image>
  47. <view class="corner" v-if="orderInfo.unshipped_count > 0">
  48. <text>{{ orderInfo.unshipped_count }}</text>
  49. </view>
  50. </view>
  51. <text>待发货</text>
  52. </view>
  53. <view class="order-item" @click="navTo('/pages/order/order?state=2')" hover-class="common-hover" :hover-stay-time="50">
  54. <view class="icon position-relative">
  55. <image class="icon-img" src="/static/user/order3.png" mode="aspectFit"></image>
  56. <view class="corner" v-if="orderInfo.received_count > 0">
  57. <text>{{ orderInfo.received_count }}</text>
  58. </view>
  59. </view>
  60. <text>待收货</text>
  61. </view>
  62. <view class="order-item" @click="navTo('/pages/order/order?state=4')" hover-class="common-hover" :hover-stay-time="50">
  63. <view class="icon position-relative"><image class="icon-img" src="/static/user/order4.png" mode="aspectFit"></image></view>
  64. <text>已完成</text>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="vip-box" @click="navTo('/pages/category/vip')"><image src="../../static/user/open-m.png" mode=""></image></view>
  69. <view>
  70. <view class="item-box item-box-a">
  71. <view class="order-section">
  72. <view class="order-item" @click="navTo('/pages/money/wallet')" hover-class="common-hover" :hover-stay-time="50">
  73. <view class="icon icon-b"><image class="icon-img" src="/static/user/yue.png" mode="aspectFit"></image></view>
  74. <view class="order-font">我的奖金</view>
  75. </view>
  76. <view class="order-item" @click="navTo('/pages/user/award')" hover-class="common-hover" :hover-stay-time="50">
  77. <view class="icon icon-b"><image class="icon-img" src="/static/user/yongjin.png" mode="aspectFit"></image></view>
  78. <view class="order-font">我的余额</view>
  79. </view>
  80. <view class="order-item" @click="navTo('/pages/user/jindou')" hover-class="common-hover" :hover-stay-time="50">
  81. <view class="icon icon-b"><image class="icon-img" src="/static/user/yaoqing.png" mode="aspectFit"></image></view>
  82. <view class="order-font">我的金豆</view>
  83. </view>
  84. <view class="order-item" @click="navTo('/pages/user/team')" hover-class="common-hover" :hover-stay-time="50">
  85. <view class="icon icon-b"><image class="icon-img" src="/static/user/tuiguang.png" mode="aspectFit"></image></view>
  86. <view class="order-font">我的推广</view>
  87. </view>
  88. </view>
  89. </view>
  90. <view class="history-section icon">
  91. <uni-list>
  92. <uni-list-item title="批发订单" @click="navTo('/pages/user/myWholesale')" thumb="/static/user/u1.png"></uni-list-item>
  93. <uni-list-item title="金豆池" @click="navTo('/pages/user/JDcool')" thumb="/static/user/u2.png"></uni-list-item>
  94. <uni-list-item title="申请美容院" @click="navTo('/pages/category/apply')" thumb="/static/user/u3.png"></uni-list-item>
  95. <uni-list-item title="分享海报" @click="navTo('/pages/user/shareQrCode')" thumb="/static/user/u4.png"></uni-list-item>
  96. <uni-list-item title="我的收藏" @click="navTo('/pages/user/favorites')" thumb="/static/user/u5.png"></uni-list-item>
  97. <uni-list-item title="收货地址" @click="navTo('/pages/set/address')" thumb="/static/user/u6.png"></uni-list-item>
  98. </uni-list>
  99. </view>
  100. </view>
  101. </scroll-view>
  102. </view>
  103. </template>
  104. <script>
  105. import { mapState, mapMutations } from 'vuex';
  106. import uniList from '@/components/uni-list/uni-list.vue';
  107. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  108. import { orderData, getUserInfo } from '@/api/user.js';
  109. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  110. let startY = 0,
  111. moveY = 0,
  112. pageAtTop = true;
  113. export default {
  114. components: {
  115. uniList,
  116. uniListItem
  117. },
  118. data() {
  119. return {};
  120. },
  121. onShow() {
  122. // 判断是否已经登录
  123. if (this.hasLogin) {
  124. this.loadBaseData();
  125. }
  126. },
  127. onReady() {
  128. // 初始化获取页面宽度
  129. uni.createSelectorQuery()
  130. .select('.container')
  131. .fields(
  132. {
  133. size: true
  134. },
  135. data => {
  136. // 计算最多下拉的高度
  137. this.userDowm = Math.floor((data.width / 750) * 185);
  138. // 计算最大触发修改高度事件
  139. this.userMaxDowm = Math.floor((data.width / 750) * 250);
  140. }
  141. )
  142. .exec();
  143. },
  144. computed: {
  145. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  146. },
  147. methods: {
  148. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  149. // 加载初始数据
  150. loadBaseData() {
  151. getUserInfo({})
  152. .then(({ data }) => {
  153. this.setUserInfo(data);
  154. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  155. orderData({})
  156. .then(({ data }) => {
  157. this.setOrderInfo(data);
  158. })
  159. .catch(e => {
  160. this.setOrderInfo({
  161. complete_count: 0, //完成
  162. received_count: 0, //待收货
  163. unshipped_count: 0, //待发货
  164. order_count: 0, //订单总数
  165. unpaid_count: 0 //待付款
  166. });
  167. });
  168. })
  169. .catch(e => {
  170. console.log(e);
  171. });
  172. },
  173. /**
  174. * 统一跳转接口,拦截未登录路由
  175. * navigator标签现在默认没有转场动画,所以用view
  176. */
  177. navTo(url) {
  178. // if (!this.hasLogin) {
  179. // // 保存地址
  180. // saveUrl();
  181. // // 登录拦截
  182. // interceptor();
  183. // } else {
  184. uni.navigateTo({
  185. url
  186. });
  187. // }
  188. }
  189. }
  190. };
  191. </script>
  192. <style lang="scss">
  193. page {
  194. height: 100%;
  195. background-color: $page-color-base;
  196. }
  197. %flex-center {
  198. display: flex;
  199. flex-direction: column;
  200. justify-content: center;
  201. align-items: center;
  202. }
  203. %section {
  204. display: flex;
  205. justify-content: space-around;
  206. align-content: center;
  207. background: #fff;
  208. border-radius: 10rpx;
  209. }
  210. .container {
  211. height: 100%;
  212. background-color: #fff;
  213. }
  214. .content-box {
  215. height: 100%;
  216. }
  217. .user-section {
  218. height: 420rpx;
  219. padding: 50rpx 0rpx 0 30rpx;
  220. position: relative;
  221. .bg {
  222. position: absolute;
  223. left: 0;
  224. top: 0;
  225. width: 750rpx;
  226. height: 420rpx;
  227. image {
  228. width: 750rpx;
  229. height: 420rpx;
  230. }
  231. }
  232. }
  233. .user-info-box {
  234. height: 180rpx;
  235. color: white;
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-between;
  239. position: relative;
  240. z-index: 1;
  241. .detail {
  242. height: 130rpx;
  243. .portrait-box {
  244. height: 100%;
  245. .portrait {
  246. width: 130rpx;
  247. height: 100%;
  248. border: 5rpx solid #fff;
  249. border-radius: 50%;
  250. }
  251. }
  252. .info-box {
  253. margin-left: 20rpx;
  254. line-height: 1.5;
  255. .username {
  256. font-size: $font-lg + 2rpx;
  257. height: 100%;
  258. max-width: 200rpx;
  259. }
  260. .vip {
  261. position: relative;
  262. margin-left: 12rpx;
  263. width: 120rpx;
  264. height: 40rpx;
  265. .vip-bg {
  266. position: absolute;
  267. top: 0;
  268. left: 0;
  269. right: 0;
  270. width: 100%;
  271. height: 100%;
  272. }
  273. .vip-title {
  274. position: relative;
  275. z-index: 10;
  276. font-size: 20rpx;
  277. font-family: PingFang SC;
  278. font-weight: 500;
  279. color: #93794b;
  280. padding-left: 36rpx;
  281. line-height: 40rpx;
  282. }
  283. }
  284. .username-t {
  285. font-size: $font-lg + 6rpx;
  286. // height: 32rpx;
  287. display: flex;
  288. align-items: center;
  289. image {
  290. display: inline-block;
  291. margin-left: 10rpx;
  292. width: 147rpx;
  293. height: 32rpx;
  294. }
  295. }
  296. .user-get {
  297. font-size: $font-lg;
  298. text {
  299. font-size: $font-lg + 6rpx;
  300. }
  301. }
  302. }
  303. }
  304. .config {
  305. font-size: 48rpx;
  306. height: 130rpx;
  307. .setting {
  308. margin-right: 51rpx;
  309. }
  310. }
  311. .my-info {
  312. margin-right: 30rpx;
  313. width: 130rpx;
  314. height: 50rpx;
  315. border: 1px solid #ffffff;
  316. border-radius: 26rpx;
  317. justify-content: center;
  318. image {
  319. width: 30rpx;
  320. height: 30rpx;
  321. }
  322. .title {
  323. padding-left: 9rpx;
  324. font-size: 24rpx;
  325. font-family: PingFang SC;
  326. font-weight: 500;
  327. color: #ffffff;
  328. }
  329. }
  330. }
  331. .vip-card-box {
  332. display: flex;
  333. flex-direction: column;
  334. color: #f7d680;
  335. height: 240rpx;
  336. background: linear-gradient(left, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.8));
  337. border-radius: 16rpx 16rpx 0 0;
  338. overflow: hidden;
  339. position: relative;
  340. padding: 20rpx 24rpx;
  341. .card-bg {
  342. position: absolute;
  343. top: 20rpx;
  344. right: 0;
  345. width: 380rpx;
  346. height: 260rpx;
  347. }
  348. .b-btn {
  349. position: absolute;
  350. right: 20rpx;
  351. top: 16rpx;
  352. width: 132rpx;
  353. height: 40rpx;
  354. text-align: center;
  355. line-height: 40rpx;
  356. font-size: 22rpx;
  357. color: #36343c;
  358. border-radius: 20px;
  359. background: linear-gradient(left, #f9e6af, #ffd465);
  360. z-index: 1;
  361. }
  362. .tit {
  363. font-size: $font-base + 2rpx;
  364. color: #f7d680;
  365. margin-bottom: 28rpx;
  366. .iconfont {
  367. color: #f6e5a3;
  368. margin-right: 16rpx;
  369. }
  370. }
  371. .e-b {
  372. font-size: $font-sm;
  373. color: #d8cba9;
  374. margin-top: 10rpx;
  375. }
  376. }
  377. .cover-container {
  378. background: $page-color-base;
  379. margin-top: -150rpx;
  380. padding: 0 30rpx;
  381. position: relative;
  382. background: #f5f5f5;
  383. padding-bottom: 20rpx;
  384. .arc {
  385. position: absolute;
  386. left: 0;
  387. top: -34rpx;
  388. width: 100%;
  389. height: 36rpx;
  390. }
  391. }
  392. .tj-sction {
  393. @extend %section;
  394. .tj-item {
  395. @extend %flex-center;
  396. flex-direction: column;
  397. height: 140rpx;
  398. font-size: $font-sm;
  399. color: #75787d;
  400. }
  401. .num {
  402. font-size: $font-lg;
  403. color: $font-color-dark;
  404. margin-bottom: 8rpx;
  405. }
  406. }
  407. .vip-box {
  408. width: 710rpx;
  409. height: 90rpx;
  410. margin: 32rpx auto 0;
  411. image {
  412. width: 100%;
  413. height: 100%;
  414. }
  415. }
  416. .item-box {
  417. // width: 710rpx;
  418. // height: 221rpx;
  419. // background: #FFFFFF;
  420. // box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  421. // border-radius: 20rpx;
  422. // position: relative;
  423. // top: -150rpx;
  424. // left: 0;
  425. // right: 0;
  426. // margin: 0 auto -150rpx;
  427. margin: 20rpx 0;
  428. .box-title {
  429. background-color: #fff;
  430. line-height: 1;
  431. // padding: 30rpx;
  432. padding: 0 36rpx 0 35rpx;
  433. height: 73rpx;
  434. border-radius: 20rpx 20rpx 0 0;
  435. .title {
  436. font-weight: bold;
  437. font-size: 30rpx;
  438. font-family: PingFang SC;
  439. font-weight: bold;
  440. color: #333333;
  441. }
  442. .link {
  443. font-size: $font-base - 2rpx;
  444. color: $font-color-light;
  445. }
  446. }
  447. .order-section {
  448. height: 146rpx;
  449. @extend %section;
  450. // padding: 28rpx 0;
  451. .order-item {
  452. @extend %flex-center;
  453. width: 120rpx;
  454. height: 146rpx;
  455. border-radius: 10rpx;
  456. font-size: $font-sm;
  457. color: $font-color-dark;
  458. }
  459. .iconfont {
  460. font-size: 48rpx;
  461. margin-bottom: 18rpx;
  462. color: #fa436a;
  463. }
  464. .icon-shouhoutuikuan {
  465. font-size: 44rpx;
  466. }
  467. .icon {
  468. height: 50rpx;
  469. width: 48rpx;
  470. margin-bottom: 18rpx;
  471. background-size: 100%;
  472. background-repeat: no-repeat;
  473. background-position: center;
  474. .icon-img {
  475. width: 100%;
  476. height: 100%;
  477. }
  478. }
  479. .icon-b {
  480. height: 90rpx;
  481. width: 88rpx;
  482. }
  483. }
  484. }
  485. .history-section {
  486. // padding: 30rpx 0 0;
  487. margin-top: 20rpx;
  488. background: #fff;
  489. border-radius: 10rpx;
  490. .sec-header {
  491. display: flex;
  492. align-items: center;
  493. font-size: $font-base;
  494. color: $font-color-dark;
  495. line-height: 40rpx;
  496. margin-left: 30rpx;
  497. padding-top: 30rpx;
  498. .iconfont {
  499. font-size: 44rpx;
  500. color: $color-red;
  501. margin-right: 16rpx;
  502. line-height: 40rpx;
  503. }
  504. }
  505. .h-list {
  506. white-space: nowrap;
  507. padding: 30rpx 30rpx 0;
  508. .h-list-image {
  509. display: inline-block;
  510. width: 160rpx;
  511. height: 160rpx;
  512. margin-right: 20rpx;
  513. border-radius: 10rpx;
  514. }
  515. }
  516. }
  517. .up-box {
  518. margin: 21rpx auto;
  519. width: 710rpx;
  520. height: 90rpx;
  521. background: linear-gradient(73deg, #ffffff 0%, #fffbeb 0%, #fff1da 0%, #fed591 100%);
  522. border-radius: 20rpx;
  523. image {
  524. width: 100%;
  525. height: 100%;
  526. border-radius: 20rpx;
  527. }
  528. }
  529. .item-box-b {
  530. width: 710rpx;
  531. height: 221rpx;
  532. background: #ffffff;
  533. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.5);
  534. border-radius: 20rpx;
  535. position: relative;
  536. top: -150rpx;
  537. left: 0;
  538. right: 0;
  539. margin: 0 auto -150rpx;
  540. }
  541. .popup-box {
  542. width: 522rpx;
  543. height: 605rpx;
  544. background-color: #ffffff;
  545. border-radius: 20rpx;
  546. position: relative;
  547. .img {
  548. position: relative;
  549. top: -56rpx;
  550. left: 0;
  551. width: 522rpx;
  552. height: 132rpx;
  553. display: flex;
  554. justify-content: center;
  555. image {
  556. border-radius: 20rpx 20rpx 0 0;
  557. width: 450rpx;
  558. height: 132rpx;
  559. }
  560. }
  561. .mian {
  562. margin-top: -44rpx;
  563. display: flex;
  564. flex-direction: column;
  565. align-items: center;
  566. // padding: 32rpx 32rpx;
  567. background-color: #ffffff;
  568. border-radius: 0 0 20rpx 20rpx;
  569. text-align: center;
  570. .delivery {
  571. font-size: 40rpx;
  572. color: #333333;
  573. display: flex;
  574. align-items: center;
  575. flex-direction: column;
  576. .title {
  577. }
  578. image {
  579. margin-top: 48rpx;
  580. width: 172rpx;
  581. height: 160rpx;
  582. }
  583. }
  584. .nocancel {
  585. font-size: 32rpx;
  586. color: #333333;
  587. margin-top: 14rpx;
  588. }
  589. .comfirm-box {
  590. margin-top: 52rpx;
  591. display: flex;
  592. // margin-bottom: 32rpx;
  593. // justify-content: space-around;
  594. .cancel {
  595. display: flex;
  596. align-items: center;
  597. justify-content: center;
  598. width: 197rpx;
  599. height: 74rpx;
  600. border: 1px solid #dcc786;
  601. border-radius: 38rpx;
  602. font-size: 32rpx;
  603. color: #605128;
  604. }
  605. .comfirm {
  606. margin-left: 32rpx;
  607. display: flex;
  608. align-items: center;
  609. justify-content: center;
  610. width: 197rpx;
  611. height: 74rpx;
  612. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  613. border-radius: 38px;
  614. font-size: 32rpx;
  615. color: #605128;
  616. }
  617. }
  618. }
  619. }
  620. .outlogin {
  621. margin: 40rpx auto;
  622. width: 500rpx;
  623. background-color: #fff;
  624. color: #ff4c4b;
  625. border: 1px solid #ff4c4b;
  626. text-align: center;
  627. padding: 10rpx 0rpx;
  628. border-radius: 50rpx;
  629. }
  630. .order-font {
  631. margin-top: -24rpx;
  632. }
  633. </style>