user.vue 15 KB

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