user.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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/shareQrCode/index')" thumb="/static/icon/img09.png"></uni-list-item>
  151. </uni-list>
  152. </view>
  153. </view>
  154. </scroll-view>
  155. <u-tabbar activeColor="#375AFE" v-model="current" :list="tabbar" :mid-button="true"></u-tabbar>
  156. </view>
  157. </template>
  158. <script>
  159. import { mapState, mapMutations } from 'vuex';
  160. import uniList from '@/components/uni-list/uni-list.vue';
  161. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  162. import { orderData, getUserInfo } from '@/api/user.js';
  163. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  164. import { tabbar } from '@/utils/tabbar.js'
  165. let startY = 0,
  166. moveY = 0,
  167. pageAtTop = true;
  168. export default {
  169. components: {
  170. uniList,
  171. uniListItem
  172. },
  173. data() {
  174. return {
  175. tabbar: tabbar,
  176. current: 4,
  177. coverTransform: 'translateY(0px)',
  178. coverTransition: '0s',
  179. moving: false,
  180. userDowm: 0, //卡片升级专属高度
  181. userMaxDowm: 0 //卡片最高高度
  182. };
  183. },
  184. onShow() {
  185. // 判断是否已经登录
  186. if (this.hasLogin) {
  187. this.loadBaseData();
  188. }
  189. },
  190. onReady() {
  191. // 初始化获取页面宽度
  192. uni.createSelectorQuery()
  193. .select('.container')
  194. .fields(
  195. {
  196. size: true
  197. },
  198. data => {
  199. // 计算最多下拉的高度
  200. this.userDowm = Math.floor((data.width / 750) * 185);
  201. // 计算最大触发修改高度事件
  202. this.userMaxDowm = Math.floor((data.width / 750) * 250);
  203. }
  204. )
  205. .exec();
  206. },
  207. // #ifndef MP
  208. // onNavigationBarButtonTap(e) {
  209. // const index = e.index;
  210. // if (index === 0) {
  211. // this.navTo('/pages/set/set');
  212. // } else if (index === 1) {
  213. // // #ifdef APP-PLUS
  214. // const pages = getCurrentPages();
  215. // const page = pages[pages.length - 1];
  216. // const currentWebview = page.$getAppWebview();
  217. // currentWebview.hideTitleNViewButtonRedDot({
  218. // index
  219. // });
  220. // // #endif
  221. // uni.navigateTo({
  222. // url: '/pages/user/notice'
  223. // });
  224. // }
  225. // },
  226. // #endif
  227. computed: {
  228. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  229. },
  230. methods: {
  231. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  232. // 加载初始数据
  233. loadBaseData() {
  234. getUserInfo({})
  235. .then(({ data }) => {
  236. this.setUserInfo(data);
  237. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  238. orderData({})
  239. .then(({ data }) => {
  240. this.setOrderInfo(data);
  241. })
  242. .catch(e => {
  243. this.setOrderInfo({
  244. complete_count: 0, //完成
  245. received_count: 0, //待收货
  246. unshipped_count: 0, //待发货
  247. order_count: 0, //订单总数
  248. unpaid_count: 0 //待付款
  249. });
  250. });
  251. })
  252. .catch(e => {
  253. console.log(e);
  254. });
  255. },
  256. /**
  257. * 统一跳转接口,拦截未登录路由
  258. * navigator标签现在默认没有转场动画,所以用view
  259. */
  260. navTo(url) {
  261. if (!this.hasLogin) {
  262. // 保存地址
  263. saveUrl();
  264. // 登录拦截
  265. interceptor();
  266. } else {
  267. uni.navigateTo({
  268. url
  269. });
  270. }
  271. },
  272. /**
  273. * 会员卡下拉和回弹
  274. * 1.关闭bounce避免ios端下拉冲突
  275. * 2.由于touchmove事件的缺陷(以前做小程序就遇到,比如20跳到40,h5反而好很多),下拉的时候会有掉帧的感觉
  276. * transition设置0.1秒延迟,让css来过渡这段空窗期
  277. * 3.回弹效果可修改曲线值来调整效果,推荐一个好用的bezier生成工具 http://cubic-bezier.com/
  278. */
  279. coverTouchstart(e) {
  280. // console.log(e);
  281. if (pageAtTop === false) {
  282. return;
  283. }
  284. this.coverTransition = 'transform .1s linear';
  285. startY = e.touches[0].clientY;
  286. },
  287. coverTouchmove(e) {
  288. // console.log(e);
  289. moveY = e.touches[0].clientY;
  290. let moveDistance = moveY - startY;
  291. let maxDowm = this.userMaxDowm;
  292. let Dowm = this.userDowm;
  293. if (moveDistance < 0) {
  294. this.moving = false;
  295. return;
  296. }
  297. this.moving = true;
  298. if (moveDistance >= Dowm && moveDistance < maxDowm) {
  299. moveDistance = Dowm;
  300. }
  301. if (moveDistance > 0 && moveDistance <= Dowm) {
  302. this.coverTransform = `translateY(${moveDistance}px)`;
  303. }
  304. },
  305. coverTouchend() {
  306. if (this.moving === false) {
  307. return;
  308. }
  309. this.moving = false;
  310. this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
  311. this.coverTransform = 'translateY(0px)';
  312. }
  313. }
  314. };
  315. </script>
  316. <style lang="scss">
  317. page {
  318. height: 100%;
  319. }
  320. %flex-center {
  321. display: flex;
  322. flex-direction: column;
  323. justify-content: center;
  324. align-items: center;
  325. }
  326. %section {
  327. display: flex;
  328. justify-content: space-around;
  329. align-content: center;
  330. background: #fff;
  331. border-radius: 10rpx;
  332. }
  333. .container {
  334. height: 100%;
  335. background-color: $page-color-base;
  336. }
  337. .content-box {
  338. height: 100%;
  339. }
  340. .vheigh {
  341. height: var(--status-bar-height);
  342. background-color: $base-color;
  343. }
  344. .user-section {
  345. height: 435rpx;
  346. padding: 15rpx 30rpx 0;
  347. position: relative;
  348. .bg {
  349. position: absolute;
  350. left: 0;
  351. top: 0;
  352. width: 100%;
  353. height: 100%;
  354. background-color: $base-color;
  355. }
  356. }
  357. .user-info-box {
  358. height: 180rpx;
  359. color: white;
  360. display: flex;
  361. align-items: center;
  362. justify-content: space-between;
  363. position: relative;
  364. z-index: 1;
  365. .detail {
  366. height: 130rpx;
  367. .portrait-box {
  368. height: 100%;
  369. .portrait {
  370. width: 130rpx;
  371. height: 100%;
  372. border: 5rpx solid #fff;
  373. border-radius: 50%;
  374. }
  375. }
  376. .info-box {
  377. margin-left: 20rpx;
  378. line-height: 1.5;
  379. .username {
  380. font-size: $font-lg + 6rpx;
  381. height: 100%;
  382. }
  383. }
  384. }
  385. .config {
  386. font-size: 48rpx;
  387. height: 130rpx;
  388. .setting {
  389. margin-right: 51rpx;
  390. }
  391. }
  392. }
  393. .vip-card-box {
  394. display: flex;
  395. flex-direction: column;
  396. color: #f7d680;
  397. height: 240rpx;
  398. background: linear-gradient(left, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.8));
  399. border-radius: 16rpx 16rpx 0 0;
  400. overflow: hidden;
  401. position: relative;
  402. padding: 20rpx 24rpx;
  403. .card-bg {
  404. position: absolute;
  405. top: 20rpx;
  406. right: 0;
  407. width: 380rpx;
  408. height: 260rpx;
  409. }
  410. .b-btn {
  411. position: absolute;
  412. right: 20rpx;
  413. top: 16rpx;
  414. width: 132rpx;
  415. height: 40rpx;
  416. text-align: center;
  417. line-height: 40rpx;
  418. font-size: 22rpx;
  419. color: #36343c;
  420. border-radius: 20px;
  421. background: linear-gradient(left, #f9e6af, #ffd465);
  422. z-index: 1;
  423. }
  424. .tit {
  425. font-size: $font-base + 2rpx;
  426. color: #f7d680;
  427. margin-bottom: 28rpx;
  428. .iconfont {
  429. color: #f6e5a3;
  430. margin-right: 16rpx;
  431. }
  432. }
  433. .e-b {
  434. font-size: $font-sm;
  435. color: #d8cba9;
  436. margin-top: 10rpx;
  437. }
  438. }
  439. .cover-container {
  440. background: $page-color-base;
  441. margin-top: -150rpx;
  442. padding: 0 30rpx;
  443. position: relative;
  444. background: #f5f5f5;
  445. padding-bottom: 20rpx;
  446. .arc {
  447. position: absolute;
  448. left: 0;
  449. top: -34rpx;
  450. width: 100%;
  451. height: 36rpx;
  452. }
  453. }
  454. .tj-sction {
  455. @extend %section;
  456. .tj-item {
  457. @extend %flex-center;
  458. flex-direction: column;
  459. height: 140rpx;
  460. font-size: $font-sm;
  461. color: #75787d;
  462. }
  463. .num {
  464. font-size: $font-lg;
  465. color: $font-color-dark;
  466. margin-bottom: 8rpx;
  467. }
  468. }
  469. .item-box {
  470. border-radius: 10rpx;
  471. background-color: white;
  472. margin-top: 20rpx;
  473. .box-title {
  474. line-height: 1;
  475. padding: 30rpx;
  476. .title {
  477. font-size: $font-lg;
  478. font-weight: bold;
  479. }
  480. .link {
  481. font-size: $font-base - 2rpx;
  482. color: $font-color-light;
  483. }
  484. }
  485. .order-section {
  486. @extend %section;
  487. padding: 28rpx 0;
  488. .order-item {
  489. @extend %flex-center;
  490. width: 120rpx;
  491. height: 120rpx;
  492. border-radius: 10rpx;
  493. font-size: $font-sm;
  494. color: $font-color-dark;
  495. }
  496. .iconfont {
  497. font-size: 48rpx;
  498. margin-bottom: 18rpx;
  499. color: #fa436a;
  500. }
  501. .icon-shouhoutuikuan {
  502. font-size: 44rpx;
  503. }
  504. .icon {
  505. height: 50rpx;
  506. width: 48rpx;
  507. margin-bottom: 18rpx;
  508. background-size: 100%;
  509. background-repeat: no-repeat;
  510. background-position: center;
  511. .icon-img {
  512. width: 100%;
  513. height: 100%;
  514. }
  515. }
  516. }
  517. }
  518. .history-section {
  519. // padding: 30rpx 0 0;
  520. margin-top: 20rpx;
  521. background: #fff;
  522. border-radius: 10rpx;
  523. .sec-header {
  524. display: flex;
  525. align-items: center;
  526. font-size: $font-base;
  527. color: $font-color-dark;
  528. line-height: 40rpx;
  529. margin-left: 30rpx;
  530. padding-top: 30rpx;
  531. .iconfont {
  532. font-size: 44rpx;
  533. color: $color-red;
  534. margin-right: 16rpx;
  535. line-height: 40rpx;
  536. }
  537. }
  538. .h-list {
  539. white-space: nowrap;
  540. padding: 30rpx 30rpx 0;
  541. .h-list-image {
  542. display: inline-block;
  543. width: 160rpx;
  544. height: 160rpx;
  545. margin-right: 20rpx;
  546. border-radius: 10rpx;
  547. }
  548. }
  549. }
  550. </style>