user.vue 15 KB

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