user.vue 17 KB

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