user.vue 17 KB

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