user.vue 16 KB

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