user.vue 17 KB

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