user.vue 15 KB

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