user.vue 17 KB

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