user.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. <template>
  2. <view class="container">
  3. <view class="vheigh"></view>
  4. <view class="top-image"><image src="../../static/img/user-top.png" mode=""></image></view>
  5. <view class="" style="height: 80rpx;"></view>
  6. <view class="user-box">
  7. <image class="avatar" :src="userInfo.avatar" mode="" v-if="userInfo.avatar"></image>
  8. <image class="avatar" src="../../static/error/missing-face.png" mode="" v-else></image>
  9. <!-- <view class="user-name">{{ userInfo.phone | phone }}</view> -->
  10. <view class="user-name">{{ userInfo.nickname }}</view>
  11. <view class="user-shop flex">
  12. <view class="user-shop-item" v-if="userInfo.alliance == 1">
  13. <image class="user-shop-icon" src="../../static/img/level.png" mode=""></image>
  14. <view class="user-shopname">老师</view>
  15. </view>
  16. <view class="user-shop-item" v-if="userInfo.shopkeeper == 1">
  17. <image class="user-shop-icon" src="../../static/img/level.png" mode=""></image>
  18. <view class="user-shopname">店家</view>
  19. </view>
  20. <view class="user-shop-item" v-if="userInfo.provinces == 1">
  21. <image class="user-shop-icon" src="../../static/img/level.png" mode=""></image>
  22. <view class="user-shopname">省盟</view>
  23. </view>
  24. <view class="user-shop-item" v-if="userInfo.group == 1">
  25. <image class="user-shop-icon" src="../../static/img/level.png" mode=""></image>
  26. <view class="user-shopname">团长</view>
  27. </view>
  28. </view>
  29. <view class="user-money flex">
  30. <view class="user-money-item" @click="navTo('/pages/user/yue')">
  31. <view class="user-money-num">{{ userInfo.now_money || 0 }}</view>
  32. <view class="user-money-font">我的余额</view>
  33. </view>
  34. <view class="user-xian"></view>
  35. <view class="user-money-item" @click="navTo('/pages/user/award')">
  36. <view class="user-money-num">{{ userInfo.brokerage_price || 0 }}</view>
  37. <view class="user-money-font">我的收益</view>
  38. </view>
  39. <view class="user-xian"></view>
  40. <view class="user-money-item" @click="navTo('/pages/user/extension')">
  41. <view class="user-money-num">{{ total || 0 }}</view>
  42. <view class="user-money-font">我的推广</view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="shop flex" @click="navTo('/pages/shop/order')" v-if="userInfo.shopkeeper == 1">
  47. <view class="shop-bg"><image src="../../static/img/shop.png" mode=""></image></view>
  48. <view class="shop-left">商家中心(进货/出货)</view>
  49. <view class="shop-right">立即进入</view>
  50. </view>
  51. <!-- 我的订单 -->
  52. <view class="order-box">
  53. <view class="my-order flex" @click="navTo('/pages/order/order')">
  54. <view class="order">我的订单</view>
  55. <view class="my-order-right">
  56. <view class="my-order-right-font">全部</view>
  57. <image src="../../static/img/xiangxia.png" mode="scaleToFill"></image>
  58. </view>
  59. </view>
  60. <!-- 订单栏 -->
  61. <view class="order-section">
  62. <view class="order-item" @click="navTo('/pages/order/order?state=0')">
  63. <image src="../../static/img/img19.png" mode="scaleToFill"></image>
  64. <view class="text">待付款</view>
  65. </view>
  66. <view class="order-item" @click="navTo('/pages/order/order?state=1')">
  67. <image src="../../static/img/img20.png" mode="scaleToFill"></image>
  68. <view class="text">待发货</view>
  69. </view>
  70. <view class="order-item" @click="navTo('/pages/order/order?state=2')">
  71. <image src="../../static/img/img21.png" mode="scaleToFill"></image>
  72. <view class="text">待收货</view>
  73. </view>
  74. <view class="order-item" @click="navTo('/pages/order/order?state=4')">
  75. <image src="../../static/img/img22.png" mode="scaleToFill"></image>
  76. <view class="text">已完成</view>
  77. </view>
  78. </view>
  79. </view>
  80. <!-- 我的工具 -->
  81. <view class="my-tool flex" @click="navTo('/pages/user/shareQrCode')">
  82. <view class="my-tool-left">
  83. <image class="my-tool-image1" src="../../static/icon/u1.png" mode=""></image>
  84. <view class="my-tool-font">推广海报</view>
  85. </view>
  86. <image class="my-tool-right" src="../../static/img/img39.png" mode=""></image>
  87. </view>
  88. <view class="my-tool flex" @click="navTo('/pages/set/address')">
  89. <view class="my-tool-left">
  90. <image class="my-tool-image2" src="../../static/icon/u2.png" mode=""></image>
  91. <view class="my-tool-font">收货地址</view>
  92. </view>
  93. <image class="my-tool-right" src="../../static/img/img39.png" mode=""></image>
  94. </view>
  95. <view class="my-tool flex" v-if="userInfo.pay_count > 0" @click="navTo('/pages/user/vip')">
  96. <view class="my-tool-left">
  97. <image class="my-tool-image3" src="../../static/icon/u3.png" mode=""></image>
  98. <view class="my-tool-font">身份认证</view>
  99. </view>
  100. <image class="my-tool-right" src="../../static/img/img39.png" mode=""></image>
  101. </view>
  102. <view class="my-tool flex" @click="openPopup">
  103. <view class="my-tool-left">
  104. <image class="my-tool-image4" src="../../static/icon/u4.png" mode=""></image>
  105. <view class="my-tool-font">客服</view>
  106. </view>
  107. <image class="my-tool-right" src="../../static/img/img39.png" mode=""></image>
  108. </view>
  109. <view class="my-tool flex" @click="navTo('/pages/set/set')">
  110. <view class="my-tool-left">
  111. <image class="my-tool-image5" src="../../static/icon/u5.png" mode=""></image>
  112. <view class="my-tool-font">设置</view>
  113. </view>
  114. <image class="my-tool-right" src="../../static/img/img39.png" mode=""></image>
  115. </view>
  116. <uni-popup ref="popup" type="center">
  117. <view class="popup-box">
  118. <view class="img"><image src="../../static/img/img009.png" mode=""></image></view>
  119. <view class="mian">
  120. <view class="delivery">
  121. <view class="title">已经为您定制专属客服</view>
  122. <image src="../../static/img/img010.png" mode=""></image>
  123. </view>
  124. <view class="nocancel">客服VX:{{ text }}</view>
  125. <view class="comfirm-box">
  126. <view class="cancel" @click="cancel">取消</view>
  127. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  128. </view>
  129. </view>
  130. </view>
  131. </uni-popup>
  132. </view>
  133. </template>
  134. <script>
  135. import uniCopy from '@/utils/uni-copy.js';
  136. import { mapState, mapMutations } from 'vuex';
  137. import uniList from '@/components/uni-list/uni-list.vue';
  138. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  139. import { orderData, getUserInfo, repurchase, getSpreadPeople } from '@/api/user.js';
  140. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  141. let startY = 0,
  142. moveY = 0,
  143. pageAtTop = true;
  144. export default {
  145. components: {
  146. uniList,
  147. uniListItem
  148. },
  149. // filters: {
  150. // phone(val) {
  151. // let str = '';
  152. // if (val) {
  153. // val = '' + val;
  154. // str = val.substr(0, 3) + '****' + val.substr(7);
  155. // }
  156. // return str;
  157. // }
  158. // },
  159. data() {
  160. return {
  161. total: '',
  162. coverTransform: 'translateY(0px)',
  163. coverTransition: '0s',
  164. moving: false,
  165. userDowm: 0, //卡片升级专属高度
  166. userMaxDowm: 0, //卡片最高高度
  167. text: '123456'
  168. };
  169. },
  170. onShow() {
  171. // 判断是否已经登录
  172. if (this.hasLogin) {
  173. this.loadBaseData();
  174. }
  175. },
  176. onReady() {
  177. // 初始化获取页面宽度
  178. uni.createSelectorQuery()
  179. .select('.container')
  180. .fields(
  181. {
  182. size: true
  183. },
  184. data => {
  185. // 计算最多下拉的高度
  186. this.userDowm = Math.floor((data.width / 750) * 185);
  187. // 计算最大触发修改高度事件
  188. this.userMaxDowm = Math.floor((data.width / 750) * 250);
  189. }
  190. )
  191. .exec();
  192. },
  193. computed: {
  194. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  195. },
  196. methods: {
  197. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  198. // 加载初始数据
  199. loadBaseData() {
  200. getSpreadPeople({
  201. page: 1,
  202. limit: 1
  203. })
  204. .then(({ data }) => {
  205. this.total = data.total;
  206. })
  207. .catch(e => {
  208. console.log(e);
  209. });
  210. getUserInfo({})
  211. .then(({ data }) => {
  212. this.setUserInfo(data);
  213. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  214. orderData({})
  215. .then(({ data }) => {
  216. this.setOrderInfo(data);
  217. })
  218. .catch(e => {
  219. this.setOrderInfo({
  220. complete_count: 0, //完成
  221. received_count: 0, //待收货
  222. unshipped_count: 0, //待发货
  223. order_count: 0, //订单总数
  224. unpaid_count: 0 //待付款
  225. });
  226. });
  227. })
  228. .catch(e => {
  229. console.log(e);
  230. });
  231. },
  232. /**
  233. * 统一跳转接口,拦截未登录路由
  234. * navigator标签现在默认没有转场动画,所以用view
  235. */
  236. navTo(url) {
  237. if (!this.hasLogin) {
  238. // 保存地址
  239. saveUrl();
  240. // 登录拦截
  241. interceptor();
  242. } else {
  243. uni.navigateTo({
  244. url
  245. });
  246. }
  247. },
  248. openPopup() {
  249. this.$refs.popup.open();
  250. },
  251. // 客服弹窗 - 复制微信
  252. comfirm(value) {
  253. let content = value; //需要复制的内容
  254. console.log('复制的内容:', content);
  255. // content = typeof content === 'string' ? content : content.toString(); // 复制内容,必须字符串,数字需要转换为字符串
  256. const result = uniCopy({ content });
  257. if (result === false) {
  258. uni.showToast({
  259. title: '不支持'
  260. });
  261. } else {
  262. uni.showToast({
  263. title: '复制成功',
  264. icon: 'none'
  265. });
  266. }
  267. this.$refs.popup.close();
  268. },
  269. // 客服弹窗 - 取消
  270. cancel() {
  271. this.$refs.popup.close();
  272. }
  273. }
  274. };
  275. </script>
  276. <style lang="scss">
  277. page {
  278. min-height: 100%;
  279. height: auto;
  280. }
  281. %flex-center {
  282. display: flex;
  283. flex-direction: column;
  284. justify-content: center;
  285. align-items: center;
  286. }
  287. %section {
  288. display: flex;
  289. justify-content: space-around;
  290. align-content: center;
  291. background: #fff;
  292. border-radius: 10rpx;
  293. }
  294. .container {
  295. min-height: 100%;
  296. height: auto;
  297. background-color: $page-color-base;
  298. }
  299. .vheigh {
  300. height: var(--status-bar-height);
  301. background-color: $base-color;
  302. }
  303. .top-image {
  304. position: absolute;
  305. top: 0;
  306. left: 0;
  307. right: 0;
  308. height: 230rpx;
  309. image {
  310. width: 100%;
  311. height: 100%;
  312. }
  313. }
  314. .user-box {
  315. position: relative;
  316. z-index: 2;
  317. width: 690rpx;
  318. margin: 0 auto;
  319. background: #ffffff;
  320. box-shadow: 0px 4rpx 13rpx 0px rgba(229, 229, 229, 0.46);
  321. border-radius: 20rpx;
  322. display: flex;
  323. flex-direction: column;
  324. align-items: center;
  325. padding: 54rpx 0 30rpx;
  326. line-height: 1;
  327. .avatar {
  328. border-radius: 50%;
  329. width: 132rpx;
  330. height: 132rpx;
  331. }
  332. .user-name {
  333. margin-top: 14rpx;
  334. font-size: 30rpx;
  335. font-family: PingFang SC;
  336. font-weight: bold;
  337. color: #333333;
  338. }
  339. .user-shop {
  340. margin-top: 10rpx;
  341. display: flex;
  342. justify-content: center;
  343. align-items: center;
  344. .user-shop-item {
  345. position: relative;
  346. margin: 0 10rpx;
  347. width: 105rpx;
  348. height: 42rpx;
  349. .user-shop-icon {
  350. position: absolute;
  351. top: 0;
  352. left: 0;
  353. right: 0;
  354. width: 105rpx;
  355. height: 42rpx;
  356. }
  357. .user-shopname {
  358. padding-left: 18rpx;
  359. position: relative;
  360. z-index: 2;
  361. font-size: 20rpx;
  362. font-family: PingFang SC;
  363. font-weight: 500;
  364. color: #977843;
  365. line-height: 42rpx;
  366. text-align: center;
  367. }
  368. }
  369. }
  370. .user-money {
  371. width: 100%;
  372. margin-top: 50rpx;
  373. justify-content: center;
  374. .user-money-item {
  375. width: 50%;
  376. display: flex;
  377. flex-direction: column;
  378. justify-content: center;
  379. align-items: center;
  380. .user-money-num {
  381. font-size: 36rpx;
  382. font-family: PingFang SC;
  383. font-weight: bold;
  384. color: #333333;
  385. }
  386. .user-money-font {
  387. margin-top: 20rpx;
  388. font-size: 22rpx;
  389. font-family: PingFang SC;
  390. font-weight: 500;
  391. color: #666666;
  392. }
  393. }
  394. .user-xian {
  395. width: 1px;
  396. height: 77rpx;
  397. background: #eeeeee;
  398. }
  399. }
  400. }
  401. .shop {
  402. width: 690rpx;
  403. height: 90rpx;
  404. margin: 18rpx auto 0;
  405. position: relative;
  406. padding: 0 20rpx 0 70rpx;
  407. .shop-bg {
  408. position: absolute;
  409. left: 0;
  410. right: 0;
  411. top: 0;
  412. width: 690rpx;
  413. height: 90rpx;
  414. image {
  415. width: 100%;
  416. height: 100%;
  417. }
  418. }
  419. .shop-left {
  420. position: relative;
  421. z-index: 2;
  422. font-size: 30rpx;
  423. font-family: PingFang SC;
  424. font-weight: bolder;
  425. color: #6a4714;
  426. }
  427. .shop-right {
  428. position: relative;
  429. z-index: 2;
  430. width: 148rpx;
  431. height: 50rpx;
  432. background: linear-gradient(-90deg, #8c5f1d 0%, #8c5f1c 77%, #875916 99%);
  433. border-radius: 25rpx;
  434. line-height: 50rpx;
  435. text-align: center;
  436. font-size: 28rpx;
  437. font-family: PingFang SC;
  438. font-weight: 500;
  439. color: #f0e1c9;
  440. }
  441. }
  442. .order-box {
  443. width: 690rpx;
  444. height: 221rpx;
  445. background: #ffffff;
  446. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  447. border-radius: 20rpx;
  448. margin: 15rpx auto 0;
  449. .my-order {
  450. height: 73rpx;
  451. width: 100%;
  452. border-bottom: 2rpx solid #f5f5f5;
  453. padding: 0 26rpx;
  454. .order {
  455. font-size: 30rpx;
  456. font-family: PingFang SC;
  457. font-weight: bold;
  458. color: #333333;
  459. }
  460. .my-order-right {
  461. display: flex;
  462. align-items: center;
  463. .my-order-right-font {
  464. font-size: 26rpx;
  465. font-family: SourceHanSansCN;
  466. font-weight: 400;
  467. color: #666666;
  468. margin-right: 10rpx;
  469. }
  470. image {
  471. width: 12rpx;
  472. height: 22rpx;
  473. }
  474. }
  475. }
  476. .order-section {
  477. display: flex;
  478. align-items: center;
  479. justify-content: space-between;
  480. .order-item {
  481. flex: 1;
  482. display: flex;
  483. flex-direction: column;
  484. align-items: center;
  485. justify-content: center;
  486. margin-top: 30rpx;
  487. image {
  488. width: 42rpx;
  489. height: 42rpx;
  490. }
  491. .text {
  492. margin-top: 20rpx;
  493. font-size: 24rpx;
  494. color: #333333;
  495. }
  496. }
  497. }
  498. }
  499. .my-tool {
  500. width: 690rpx;
  501. background: #ffffff;
  502. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  503. border-radius: 28rpx;
  504. padding: 34rpx 24rpx;
  505. margin: 15rpx auto 0;
  506. .my-tool-left {
  507. display: flex;
  508. align-items: center;
  509. .my-tool-image1 {
  510. width: 41rpx;
  511. height: 35rpx;
  512. }
  513. .my-tool-image2 {
  514. width: 43rpx;
  515. height: 40rpx;
  516. }
  517. .my-tool-image3 {
  518. width: 42rpx;
  519. height: 37rpx;
  520. }
  521. .my-tool-image4 {
  522. width: 38rpx;
  523. height: 40rpx;
  524. }
  525. .my-tool-image5 {
  526. width: 42rpx;
  527. height: 39rpx;
  528. }
  529. .my-tool-font {
  530. font-size: 29rpx;
  531. font-family: PingFang SC;
  532. font-weight: bold;
  533. color: #5d5d5d;
  534. margin-left: 14rpx;
  535. }
  536. }
  537. .my-tool-right {
  538. width: 18rpx;
  539. height: 22rpx;
  540. }
  541. }
  542. .popup-box {
  543. width: 522rpx;
  544. height: 605rpx;
  545. background-color: #ffffff;
  546. border-radius: 20rpx;
  547. position: relative;
  548. .img {
  549. position: relative;
  550. top: -56rpx;
  551. left: 0;
  552. width: 522rpx;
  553. height: 132rpx;
  554. display: flex;
  555. justify-content: center;
  556. image {
  557. border-radius: 20rpx 20rpx 0 0;
  558. width: 450rpx;
  559. height: 132rpx;
  560. }
  561. }
  562. .mian {
  563. margin-top: -44rpx;
  564. display: flex;
  565. flex-direction: column;
  566. align-items: center;
  567. // padding: 32rpx 32rpx;
  568. background-color: #ffffff;
  569. border-radius: 0 0 20rpx 20rpx;
  570. text-align: center;
  571. .delivery {
  572. font-size: 40rpx;
  573. color: #333333;
  574. display: flex;
  575. align-items: center;
  576. flex-direction: column;
  577. .title {
  578. }
  579. image {
  580. margin-top: 48rpx;
  581. width: 172rpx;
  582. height: 160rpx;
  583. }
  584. }
  585. .nocancel {
  586. font-size: 32rpx;
  587. color: #333333;
  588. margin-top: 14rpx;
  589. }
  590. .comfirm-box {
  591. margin-top: 52rpx;
  592. display: flex;
  593. // margin-bottom: 32rpx;
  594. // justify-content: space-around;
  595. .cancel {
  596. display: flex;
  597. align-items: center;
  598. justify-content: center;
  599. width: 197rpx;
  600. height: 74rpx;
  601. border: 1px solid #dcc786;
  602. border-radius: 38rpx;
  603. font-size: 32rpx;
  604. color: #605128;
  605. }
  606. .comfirm {
  607. margin-left: 32rpx;
  608. display: flex;
  609. align-items: center;
  610. justify-content: center;
  611. width: 197rpx;
  612. height: 74rpx;
  613. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  614. border-radius: 38px;
  615. font-size: 32rpx;
  616. color: #605128;
  617. }
  618. }
  619. }
  620. }
  621. </style>