user.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. <template>
  2. <view class="container">
  3. <view class="vheigh"></view>
  4. <view class="top-image">
  5. <image src="../../static/user/user-top.png" mode=""></image>
  6. </view>
  7. <view class="user-set flex">
  8. <!-- <view class="set-logo" @click="navTo('/pages/set/userinfo')"><image src="../../static/user/user08.png" mode=""></image></view> -->
  9. <!-- <view class="xx-logo"><image src="../../static/user/user2.png" mode=""></image></view> -->
  10. </view>
  11. <view class="user-wrap">
  12. <view class="info-left flex">
  13. <view class="user-name">
  14. <image :src="userInfo.avatar || '../../static/error/missing-face.png'" mode=""></image>
  15. <view class="user-font">
  16. <view class="name clamp">{{ userInfo.nickname }}</view>
  17. <view class="phone" v-if="isPhone=true">{{ getPhone }}</view>
  18. <view class="phone">{{getFh}}</view>
  19. </view>
  20. </view>
  21. <view class="kpi" v-show="userInfo.level!=0">
  22. <image style="width: 34rpx; height: 34rpx; margin-right: 8rpx;" src="../../static/icon/vip.png"
  23. mode=""></image>会员VIP
  24. </view>
  25. </view>
  26. <view class="info-right">
  27. <view class="item-item" @click="navTo('/pages/money/wallet')">
  28. <view class="item-num">{{ userInfo.now_money || 0}}</view>
  29. <view class="item-font">我的钱包</view>
  30. </view>
  31. <view class="" style="width: 1rpx;height: 100rpx;background: #EEEEEE;">
  32. </view>
  33. <view class="item-item" @click="navTo('/pages/user/cash')">
  34. <view class="item-num">{{userInfo.brokerage_price || 0}}</view>
  35. <view class="item-font">我的佣金</view>
  36. </view>
  37. <view class="" style="width: 1rpx;height: 100rpx;background: #EEEEEE;">
  38. </view>
  39. <view class="item-item" @click="navTo('/pages/user/team')">
  40. <view class="item-num">{{all || 0}}</view>
  41. <view class="item-font">我的推广</view>
  42. </view>
  43. <view class="item-item">
  44. <view class="item-num">{{(userInfo.ordsum).toFixed(2) || 0}}</view>
  45. <view class="item-font">消费金额</view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="main-box">
  50. <view class="title flex" @click="navTo('/pages/order/order?state=0')">
  51. <view class="title-left">
  52. <image class="title-icon" src="../../static/user/user10.png" mode=""></image>
  53. <view class="title-font">我的订单</view>
  54. </view>
  55. <image class="title-right" src="../../static/user/user04.png" mode=""></image>
  56. </view>
  57. <view class="main flex">
  58. <view class="oitem" @click="navTo('/pages/order/order?state=0')">
  59. <image class="oitem-image" src="../../static/user/user01.png" mode=""></image>
  60. <view class="oitem-font">待付款</view>
  61. </view>
  62. <view class="oitem" @click="navTo('/pages/order/order?state=1')">
  63. <image class="oitem-image" src="../../static/user/user03.png" mode=""></image>
  64. <view class="oitem-font">待发货</view>
  65. </view>
  66. <view class="oitem" @click="navTo('/pages/order/order?state=2')">
  67. <image class="oitem-image" src="../../static/user/user02.png" mode=""></image>
  68. <view class="oitem-font">待收货</view>
  69. </view>
  70. <view class="oitem" @click="navTo('/pages/order/order?state=3')">
  71. <image class="oitem-image" src="../../static/user/user07.png" mode=""></image>
  72. <view class="oitem-font">已完成</view>
  73. </view>
  74. </view>
  75. </view>
  76. <uni-list class="tool-list">
  77. <uni-list-item title="邀请有礼" @click="navTo('/pages/user/shareQrCode')" thumb="/static/user/user08.png">
  78. </uni-list-item>
  79. <uni-list-item title="我的收藏" @click="navTo('/pages/user/favorites')" thumb="/static/user/user11.png">
  80. </uni-list-item>
  81. <!-- <uni-list-item title="点击试试" @click="navTo('/pages/public/login')" thumb="/static/user/user11.png">
  82. </uni-list-item> -->
  83. <uni-list-item title="客服中心" @click="openKf()" thumb="/static/user/user09.png"></uni-list-item>
  84. <uni-list-item title="设置" @click="navTo('/pages/set/userinfo')" thumb="/static/user/user13.png">
  85. </uni-list-item>
  86. </uni-list>
  87. <uni-popup ref="popupkf" type="center">
  88. <view class="popup-box">
  89. <view class="img">
  90. <image src="../../static/img/img009.png" mode=""></image>
  91. </view>
  92. <view class="mian">
  93. <view class="delivery">
  94. <view class="title">已经为您定制专属客服</view>
  95. <image src="../../static/img/img010.png" mode=""></image>
  96. </view>
  97. <view class="nocancel">客服VX:{{ text }}</view>
  98. <view class="comfirm-box">
  99. <view class="cancel" @click="cancel">取消</view>
  100. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  101. </view>
  102. </view>
  103. </view>
  104. </uni-popup>
  105. <!-- <uni-popup ref="popupqd" type="center">
  106. <view class="popup">
  107. <view class="popup-dox"><image class="popup-logo" src="../../static/img/sign-popup.png"></image></view>
  108. <view class="popup-title">
  109. 获得
  110. <text>{{ today_integral }}</text>
  111. {{ today_type }}
  112. </view>
  113. <view class="popup-tip">
  114. 明天签到可得
  115. <text>{{ tom_integral }}</text>
  116. {{ tom_type }}
  117. </view>
  118. <view class="popup-btn" @click="closeQd">知道了</view>
  119. </view>
  120. </uni-popup> -->
  121. </view>
  122. </template>
  123. <script>
  124. import {
  125. tabbar1
  126. } from '@/utils/tabbar.js';
  127. import {
  128. mapState,
  129. mapMutations
  130. } from 'vuex';
  131. import uniList from '@/components/uni-list/uni-list.vue';
  132. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  133. import {
  134. orderData,
  135. getUserInfo,
  136. myspread
  137. } from '@/api/user.js';
  138. import {
  139. saveUrl,
  140. interceptor
  141. } from '@/utils/loginUtils.js';
  142. let startY = 0,
  143. moveY = 0,
  144. pageAtTop = true;
  145. export default {
  146. components: {
  147. uniList,
  148. uniListItem
  149. },
  150. data() {
  151. return {
  152. isPhone:false,
  153. all: 0, //推荐人数
  154. current: 4,
  155. tabbar: tabbar1,
  156. qded: false, //是否已签到
  157. text: '', //客服微信
  158. today_integral: '', //签到获得的数值
  159. today_type: '', //签到获得的数值单位
  160. tom_integral: '', //明天签到获得的数值
  161. tom_type: '', //签到获得的数值单位
  162. userDowm: 0, //卡片升级专属高度
  163. userMaxDowm: 0, //卡片最高高度
  164. toolList: [{
  165. id: 't1',
  166. name: '新人通道',
  167. width: '56rpx',
  168. heigt: '54rpx',
  169. img: '../../static/icon/tool-1.png',
  170. path: '/pages/user/xrtd'
  171. },
  172. {
  173. id: 't2',
  174. name: '邀请好友',
  175. width: '56rpx',
  176. heigt: '57rpx',
  177. img: '../../static/icon/tool-2.png',
  178. path: '/pages/user/shareQrCode'
  179. },
  180. {
  181. id: 't3',
  182. name: '我的粉丝',
  183. width: '68rpx',
  184. heigt: '53rpx',
  185. img: '../../static/icon/tool-3.png',
  186. path: '/pages/user/myfans'
  187. },
  188. {
  189. id: 't4',
  190. name: '我的订单',
  191. width: '55rpx',
  192. heigt: '54rpx',
  193. img: '../../static/icon/tool-4.png',
  194. path: '/pages/order/order'
  195. },
  196. {
  197. id: 't5',
  198. name: '我的商品',
  199. width: '50rpx',
  200. heigt: '58rpx',
  201. img: '../../static/icon/tool-5.png',
  202. path: '/pages/order/order'
  203. },
  204. {
  205. id: 't6',
  206. name: '馆长申请',
  207. width: '59rpx',
  208. heigt: '56rpx',
  209. img: '../../static/icon/tool-6.png',
  210. path: '/pages/user/gzsq'
  211. }
  212. ]
  213. };
  214. },
  215. onShow() {
  216. // 判断是否已经登录
  217. if (this.hasLogin) {
  218. this.loadBaseData();
  219. myspread({}).then(({
  220. data
  221. }) => {
  222. console.log(data, '推荐人');
  223. this.all = data.total;
  224. })
  225. }
  226. this.loadBaseData();
  227. },
  228. onReady() {
  229. // 初始化获取页面宽度
  230. uni.createSelectorQuery()
  231. .select('.container')
  232. .fields({
  233. size: true
  234. },
  235. data => {
  236. // 计算最多下拉的高度
  237. this.userDowm = Math.floor((data.width / 750) * 185);
  238. // 计算最大触发修改高度事件
  239. this.userMaxDowm = Math.floor((data.width / 750) * 250);
  240. }
  241. )
  242. .exec();
  243. },
  244. // #ifndef MP
  245. // onNavigationBarButtonTap(e) {
  246. // const index = e.index;
  247. // if (index === 0) {
  248. // this.navTo('/pages/set/set');
  249. // } else if (index === 1) {
  250. // // #ifdef APP-PLUS
  251. // const pages = getCurrentPages();
  252. // const page = pages[pages.length - 1];
  253. // const currentWebview = page.$getAppWebview();
  254. // currentWebview.hideTitleNViewButtonRedDot({
  255. // index
  256. // });
  257. // // #endif
  258. // uni.navigateTo({
  259. // url: '/pages/user/notice'
  260. // });
  261. // }
  262. // },
  263. // #endif
  264. computed: {
  265. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin']),
  266. getPhone() {
  267. if(this.userInfo.phone){
  268. this.isPhone=true
  269. let reg = /^(\d{3})\d{4}(\d{4})$/;
  270. return this.userInfo.phone.replace(reg, '$1****$2')
  271. }else{
  272. this.isPhone=false
  273. }
  274. },
  275. getFh(){
  276. //具体分红权益
  277. if(isNaN(this.userInfo.vipsum)){
  278. return this.userInfo.vipsum
  279. }else{
  280. return `距离分红权益相差${this.userInfo.vipsum}元`
  281. }
  282. }
  283. },
  284. methods: {
  285. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  286. // 加载初始数据
  287. loadBaseData() {
  288. console.log(this.userInfo, 'info');
  289. getUserInfo({})
  290. .then(({
  291. data
  292. }) => {
  293. this.setUserInfo(data);
  294. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  295. orderData({})
  296. .then(({
  297. data
  298. }) => {
  299. this.setOrderInfo(data);
  300. })
  301. .catch(e => {
  302. this.setOrderInfo({
  303. complete_count: 0, //完成
  304. received_count: 0, //待收货
  305. unshipped_count: 0, //待发货
  306. order_count: 0, //订单总数
  307. unpaid_count: 0 //待付款
  308. });
  309. });
  310. })
  311. .catch(e => {
  312. console.log(e);
  313. });
  314. },
  315. /**
  316. * 统一跳转接口,拦截未登录路由
  317. * navigator标签现在默认没有转场动画,所以用view
  318. */
  319. navTo(url) {
  320. console.log(url);
  321. let pages = getCurrentPages();
  322. console.log(pages, 'pages');
  323. let prevPage = pages[pages.length - 2]
  324. console.log(prevPage, 'pages2');
  325. // if (!this.hasLogin) {
  326. // // 保存地址
  327. // saveUrl();
  328. // // 登录拦截
  329. // interceptor();
  330. // } else {
  331. uni.navigateTo({
  332. url
  333. });
  334. // }
  335. },
  336. useTool(e) {
  337. this.navTo(e.path);
  338. },
  339. // 签到弹窗
  340. goQd() {
  341. this.$refs.popupqd.open();
  342. this.qded = true;
  343. },
  344. // 关闭签到弹窗
  345. closeQd() {
  346. this.$refs.popupqd.close();
  347. },
  348. // 打开客服
  349. openKf() {
  350. this.$refs.popupkf.open();
  351. },
  352. // 关闭客服
  353. cancel() {
  354. this.$refs.popupkf.close();
  355. }
  356. }
  357. };
  358. </script>
  359. <style lang="scss">
  360. %flex-center {
  361. display: flex;
  362. flex-direction: column;
  363. justify-content: center;
  364. align-items: center;
  365. }
  366. %section {
  367. display: flex;
  368. justify-content: space-around;
  369. align-content: center;
  370. background: #fff;
  371. border-radius: 10rpx;
  372. }
  373. .container,
  374. page {
  375. min-height: 100%;
  376. height: auto;
  377. background-color: $page-color-base;
  378. }
  379. .vheigh {
  380. height: var(--status-bar-height);
  381. background-color: $base-color;
  382. }
  383. .top-image {
  384. position: absolute;
  385. top: 0;
  386. left: 0;
  387. right: 0;
  388. height: 230rpx;
  389. image {
  390. width: 100%;
  391. height: 100%;
  392. }
  393. }
  394. .tool-list {
  395. width: 690rpx;
  396. margin: auto;
  397. margin-top: 20rpx;
  398. background: #ffffff;
  399. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  400. border-radius: 20rpx;
  401. }
  402. .popup-box {
  403. width: 522rpx;
  404. height: 605rpx;
  405. background-color: #ffffff;
  406. border-radius: 20rpx;
  407. position: relative;
  408. .img {
  409. position: relative;
  410. top: -56rpx;
  411. left: 0;
  412. width: 522rpx;
  413. height: 132rpx;
  414. display: flex;
  415. justify-content: center;
  416. image {
  417. border-radius: 20rpx 20rpx 0 0;
  418. width: 450rpx;
  419. height: 132rpx;
  420. }
  421. }
  422. .mian {
  423. margin-top: -44rpx;
  424. display: flex;
  425. flex-direction: column;
  426. align-items: center;
  427. // padding: 32rpx 32rpx;
  428. background-color: #ffffff;
  429. border-radius: 0 0 20rpx 20rpx;
  430. text-align: center;
  431. .delivery {
  432. font-size: 40rpx;
  433. color: #333333;
  434. display: flex;
  435. align-items: center;
  436. flex-direction: column;
  437. image {
  438. margin-top: 48rpx;
  439. width: 172rpx;
  440. height: 160rpx;
  441. }
  442. }
  443. .nocancel {
  444. font-size: 32rpx;
  445. color: #333333;
  446. margin-top: 14rpx;
  447. }
  448. .comfirm-box {
  449. margin-top: 52rpx;
  450. display: flex;
  451. // margin-bottom: 32rpx;
  452. // justify-content: space-around;
  453. .cancel {
  454. display: flex;
  455. align-items: center;
  456. justify-content: center;
  457. width: 197rpx;
  458. height: 74rpx;
  459. border: 1px solid #dcc786;
  460. border-radius: 38rpx;
  461. font-size: 32rpx;
  462. color: #605128;
  463. }
  464. .comfirm {
  465. margin-left: 32rpx;
  466. display: flex;
  467. align-items: center;
  468. justify-content: center;
  469. width: 197rpx;
  470. height: 74rpx;
  471. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  472. border-radius: 38px;
  473. font-size: 32rpx;
  474. color: #605128;
  475. }
  476. }
  477. }
  478. }
  479. .popup {
  480. width: 560rpx;
  481. padding-bottom: 45rpx;
  482. background-color: #ffffff;
  483. border-radius: 15rpx;
  484. text-align: center;
  485. line-height: 1;
  486. .popup-dox {
  487. position: relative;
  488. .popup-logo {
  489. margin: -160rpx auto 0;
  490. width: 400rpx;
  491. height: 200rpx;
  492. }
  493. }
  494. .popup-title {
  495. margin-top: 85rpx;
  496. font-size: 40rpx;
  497. font-family: PingFang SC;
  498. font-weight: bold;
  499. color: #2a2a2a;
  500. text {
  501. font-size: 56rpx;
  502. color: #e83f30;
  503. }
  504. }
  505. .popup-tip {
  506. margin-top: 20rpx;
  507. font-size: 28rpx;
  508. font-family: PingFang SC;
  509. font-weight: 500;
  510. color: #8c8c8c;
  511. text {
  512. color: #e83f30;
  513. }
  514. }
  515. .popup-btn {
  516. margin: 58rpx auto 0;
  517. width: 270rpx;
  518. height: 66rpx;
  519. background: #f0c838;
  520. border-radius: 34rpx;
  521. text-align: center;
  522. line-height: 66rpx;
  523. font-size: 36rpx;
  524. font-family: Source Han Sans CN;
  525. font-weight: 500;
  526. color: #ffffff;
  527. }
  528. }
  529. .user-wrap {
  530. position: relative;
  531. z-index: 10;
  532. width: 690rpx;
  533. height: 283rpx;
  534. background: #ffffff;
  535. box-shadow: 0px 4rpx 13rpx 0px rgba(229, 229, 229, 0.46);
  536. border-radius: 20rpx;
  537. padding: 34rpx 0 40rpx;
  538. margin: auto;
  539. .info-left {
  540. padding-left: 34rpx;
  541. .user-name {
  542. display: flex;
  543. align-items: center;
  544. image {
  545. width: 120rpx;
  546. height: 120rpx;
  547. border-radius: 50%;
  548. }
  549. .user-font {
  550. padding-left: 34rpx;
  551. .name {
  552. width: 250rpx;
  553. font-size: 40rpx;
  554. font-family: Source Han Sans CN;
  555. font-weight: 400;
  556. color: #333333;
  557. }
  558. .phone {
  559. margin-top: 10rpx;
  560. font-size: 20rpx;
  561. font-family: PingFang SC;
  562. font-weight: 500;
  563. color: #999999;
  564. }
  565. }
  566. }
  567. .kpi {
  568. background: #f5eede;
  569. border-radius: 30rpx 0px 0px 30rpx;
  570. padding: 18rpx 24rpx;
  571. font-size: 26rpx;
  572. font-family: PingFang SC;
  573. font-weight: bold;
  574. color: #c6914e;
  575. }
  576. }
  577. .info-right {
  578. display: flex;
  579. justify-content: space-around;
  580. align-items: center;
  581. margin: 30rpx 0;
  582. padding: 0 34rpx;
  583. .item-item {
  584. padding-bottom: 20rpx;
  585. width: 33%;
  586. display: flex;
  587. justify-content: center;
  588. flex-direction: column;
  589. align-items: center;
  590. .item-num {
  591. font-size: 36rpx;
  592. font-weight: bold;
  593. color: #333333;
  594. }
  595. .item-font {
  596. margin-top: 18rpx;
  597. font-size: 22rpx;
  598. font-weight: 500;
  599. color: #666666;
  600. }
  601. }
  602. }
  603. }
  604. .user-set {
  605. justify-content: flex-end;
  606. view {
  607. flex-shrink: 0;
  608. }
  609. padding: 30rpx;
  610. image {
  611. height: 40rpx;
  612. width: 40rpx;
  613. }
  614. }
  615. .main-box {
  616. margin: 20rpx auto 0;
  617. width: 690rpx;
  618. background: #ffffff;
  619. box-shadow: 0px 4rpx 14rpx 0px rgba(229, 229, 229, 0.46);
  620. border-radius: 20rpx;
  621. .title {
  622. display: flex;
  623. justify-content: space-between;
  624. align-items: center;
  625. padding: 24rpx;
  626. border-bottom: 1px solid #EEEEEE;
  627. .title-left {
  628. display: flex;
  629. align-items: center;
  630. .title-icon {
  631. width: 32rpx;
  632. height: 32rpx;
  633. }
  634. .title-font {
  635. margin-left: 20rpx;
  636. font-size: 28rpx;
  637. font-family: PingFang SC;
  638. font-weight: bold;
  639. color: #333333;
  640. }
  641. }
  642. .title-right {
  643. width: 14rpx;
  644. height: 24rpx;
  645. }
  646. }
  647. .main {
  648. padding: 30rpx 0 20rpx;
  649. .oitem {
  650. width: 25%;
  651. display: flex;
  652. flex-direction: column;
  653. align-items: center;
  654. .oitem-image {
  655. height: 50rpx;
  656. width: 48rpx;
  657. }
  658. .oitem-font {
  659. margin-top: 20rpx;
  660. font-size: 24rpx;
  661. font-family: PingFang SC;
  662. font-weight: 500;
  663. color: #333333;
  664. }
  665. }
  666. }
  667. }
  668. </style>