user.vue 16 KB

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