user.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. <template>
  2. <view class="container">
  3. <!-- 用户信息 -->
  4. <view class="user">
  5. <!-- 背景图片 -->
  6. <image src="../../static/user/user19.png" mode="scaleToFill"></image>
  7. <!-- 用户头像和信息 -->
  8. <view class="infor">
  9. <!-- 用户信息 -->
  10. <view class="infor-left">
  11. <view class="info-img">
  12. <image :src=" userInfo.avatar || '../../static/error/missing-face.png'"></image>
  13. </view>
  14. <view class="vip-img1" v-if="userInfo.vip_info.name=='银卡' ">
  15. <!-- <image src="../../static/user/vip1.png" mode=""></image> -->
  16. 银卡
  17. </view>
  18. <view class="vip-img1" v-if="userInfo.vip_info.name=='金卡' ">
  19. <!-- <image src="../../static/user/vip2.png" mode=""></image> -->
  20. 金卡
  21. </view>
  22. <view class="vip-img1" v-if="userInfo.vip_info.name=='钻卡' ">
  23. <!-- <image src="../../static/user/vip3.png" mode=""></image> -->
  24. 钻卡
  25. </view>
  26. <view class="username">{{ userInfo.nickname || '游客' }}</view>
  27. <view class="info-box">
  28. <view class="phone" v-if="userInfo.uid">ID:{{userInfo.uid | phone}}</view>
  29. </view>
  30. </view>
  31. <!-- 设置 -->
  32. <!-- <view class="infor-right" @click="nav('/pages/set/userinfo')">
  33. <image src="../../static/img/img18.png" mode="scaleToFill"></image>
  34. <view class="setting">设置</view>
  35. </view> -->
  36. </view>
  37. <!-- 我的订单 -->
  38. <view class="order-box">
  39. <view class="my-order" @click="nav('/pages/order/order')">
  40. <view class="order">我的订单</view>
  41. <image src="../../static/img/xiangxia.png" mode="scaleToFill"></image>
  42. </view>
  43. <!-- 订单栏 -->
  44. <view class="order-section">
  45. <view class="order-item" @click="nav('/pages/order/order?state=0')">
  46. <image src="../../static/img/img19.png" mode="scaleToFill"></image>
  47. <view class="text">待付款</view>
  48. </view>
  49. <view class="order-item" @click="nav('/pages/order/order?state=1')">
  50. <image src="../../static/img/img20.png" mode="scaleToFill"></image>
  51. <view class="text">待发货</view>
  52. </view>
  53. <view class="order-item" @click="nav('/pages/order/order?state=2')">
  54. <image src="../../static/img/img21.png" mode="scaleToFill"></image>
  55. <view class="text">待收货</view>
  56. </view>
  57. <view class="order-item" @click="nav('/pages/order/order?state=4')">
  58. <image src="../../static/img/img22.png" mode="scaleToFill"></image>
  59. <view class="text">已完成</view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 下部分 -->
  65. <view class="item-box">
  66. <!-- 我的余额 -->
  67. <view class="item-box-box">
  68. <view class="item-box-title">
  69. 我的资产
  70. </view>
  71. <view class="order-section">
  72. <view class="order-item" @click="nav('/pages/money/wallet')">
  73. <image src="../../static/user/user03.png" mode="scaleToFill" style="width:62rpx;height: 51rpx;">
  74. </image>
  75. <view class="text">余额</view>
  76. </view>
  77. <view class="order-item" @click="nav('/pages/user/jiangjin')">
  78. <image src="../../static/user/user18.png" mode="scaleToFill" style="width:71rpx;height: 62rpx;">
  79. </image>
  80. <view class="text">奖金</view>
  81. </view>
  82. <view class="order-item" @click="nav('/pages/user/integral')">
  83. <image src="../../static/user/user17.png" mode="scaleToFill" style="width:55rpx;height: 56rpx;">
  84. </image>
  85. <view class="text">积分</view>
  86. </view>
  87. <view class="order-item" @click="nav('/pages/user/contribution')">
  88. <image src="../../static/user/user05.png" mode="scaleToFill" style="width:51rpx;height: 66rpx;">
  89. </image>
  90. <view class="text">贡献值</view>
  91. </view>
  92. <!-- <view class="order-item" @click="nav('/pages/user/packet')">
  93. <image src="../../static/user/user16.png" mode="scaleToFill" style="width:46rpx;height: 56rpx;"></image>
  94. <view class="text">红包</view>
  95. </view> -->
  96. </view>
  97. </view>
  98. <!-- 底部列表 -->
  99. <view class="btm">
  100. <view class="ul-btm" @click="nav('/pages/user/jiedian')">
  101. <image src="../../static/user/user09.png" mode="scaleToFill"></image>
  102. <view class="btm-right">
  103. <view class="text">我的推广</view>
  104. <image class="jiantou" src="../../static/img/img32.png" mode="scaleToFill"></image>
  105. </view>
  106. </view>
  107. <view class="ul-btm" @click="nav('/pages/user/shareQrCode')">
  108. <image src="../../static/user/user13.png" mode="scaleToFill"></image>
  109. <view class="btm-right">
  110. <view class="text">邀请海报</view>
  111. <image class="jiantou" src="../../static/img/img32.png" mode="scaleToFill"></image>
  112. </view>
  113. </view>
  114. <view class="ul-btm" @click="nav('/pages/set/address')">
  115. <image src="../../static/user/user12.png" mode="scaleToFill"></image>
  116. <view class="btm-right">
  117. <view class="text">收货地址</view>
  118. <image class="jiantou" src="../../static/img/img32.png" mode="scaleToFill"></image>
  119. </view>
  120. </view>
  121. <view class="ul-btm" @click="open()">
  122. <image src="../../static/user/user11.png" mode="scaleToFill"></image>
  123. <view class="btm-right">
  124. <view class="text">客服</view>
  125. <image class="jiantou" src="../../static/img/img32.png" mode="scaleToFill"></image>
  126. </view>
  127. </view>
  128. <view class="ul-btm" @click="nav('/pages/set/userinfo')">
  129. <image src="../../static/user/user07.png" mode="scaleToFill"></image>
  130. <view class="btm-right">
  131. <view class="text">设置</view>
  132. <image class="jiantou" src="../../static/img/img32.png" mode="scaleToFill"></image>
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. <view class="u-tabbar">
  138. <text>普丽惠莱企业管理(台州)有限公司</text>
  139. <text>版权所有</text>
  140. </view>
  141. <uni-popup ref="popup" type="center">
  142. <view class="popup-box">
  143. <view class="img">
  144. <image src="../../static/img/img009.png" mode=""></image>
  145. </view>
  146. <view class="mian">
  147. <view class="delivery">
  148. <view class="title">已经为您定制专属客服</view>
  149. <image src="../../static/img/img010.png" mode=""></image>
  150. </view>
  151. <view class="nocancel">客服VX:{{ text }}</view>
  152. <view class="comfirm-box">
  153. <view class="cancel" @click="cancel">取消</view>
  154. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  155. </view>
  156. </view>
  157. </view>
  158. </uni-popup>
  159. </view>
  160. </template>
  161. <script>
  162. import {
  163. orderData,
  164. getUserInfo,
  165. service
  166. } from '@/api/user.js';
  167. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  168. import uniCopy from '@/utils/uni-copy.js';
  169. import {
  170. mapState,
  171. mapMutations
  172. } from 'vuex';
  173. import {
  174. saveUrl,
  175. interceptor
  176. } from '@/utils/loginUtils.js';
  177. export default {
  178. components: {
  179. uniPopup
  180. },
  181. data() {
  182. return {
  183. text: '123465',
  184. vipDj: 3,
  185. }
  186. },
  187. filters: {
  188. phone(val) {
  189. let str = ''
  190. if (val) {
  191. val = "" + val;
  192. str = val.substr(0, 3) + "****" + val.substr(7)
  193. }
  194. return str
  195. }
  196. },
  197. onShow() {
  198. //判断是否已经登录
  199. if (this.hasLogin) {
  200. this.loadBaseData();
  201. } else {
  202. uni.showModal({
  203. title: '登录',
  204. content: '您未登录,是否马上登陆?',
  205. success: e => {
  206. if (e.confirm) {
  207. interceptor();
  208. }
  209. },
  210. fail: e => {
  211. console.log(e);
  212. }
  213. });
  214. }
  215. },
  216. computed: {
  217. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  218. },
  219. methods: {
  220. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  221. loadBaseData() {
  222. getUserInfo({})
  223. .then(({
  224. data
  225. }) => {
  226. console.log(data)
  227. this.setUserInfo(data);
  228. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  229. orderData({})
  230. .then(({
  231. data
  232. }) => {
  233. this.setOrderInfo(data);
  234. })
  235. .catch(e => {
  236. this.setOrderInfo({
  237. complete_count: 0, //完成
  238. received_count: 0, //待收货
  239. unshipped_count: 0, //待发货
  240. order_count: 0, //订单总数
  241. unpaid_count: 0 //待付款
  242. });
  243. });
  244. })
  245. .catch(e => {
  246. console.log(e);
  247. });
  248. },
  249. nav(url) {
  250. // console.log(url)
  251. if (!this.hasLogin) {
  252. // 保存地址
  253. saveUrl();
  254. // 登录拦截
  255. interceptor();
  256. } else {
  257. uni.navigateTo({
  258. url,
  259. fail(e) {
  260. console.log(e);
  261. }
  262. })
  263. }
  264. },
  265. open() {
  266. console.log('点击出现弹窗');
  267. this.$refs.popup.open();
  268. },
  269. // 客服弹窗 - 复制微信
  270. comfirm(value) {
  271. let content = value; //需要复制的内容
  272. console.log('复制的内容:', content);
  273. // content = typeof content === 'string' ? content : content.toString(); // 复制内容,必须字符串,数字需要转换为字符串
  274. const result = uniCopy({
  275. content
  276. });
  277. if (result === false) {
  278. uni.showToast({
  279. title: '不支持'
  280. });
  281. } else {
  282. uni.showToast({
  283. title: '复制成功',
  284. icon: 'none'
  285. });
  286. }
  287. this.$refs.popup.close();
  288. },
  289. // 客服弹窗 - 取消
  290. cancel() {
  291. this.$refs.popup.close();
  292. }
  293. }
  294. }
  295. </script>
  296. <style lang="scss">
  297. .container,
  298. page {
  299. background: #FFFFFF;
  300. height: auto;
  301. min-height: 100%;
  302. }
  303. .u-tabbar {
  304. display: flex;
  305. flex-direction: column;
  306. align-items: center;
  307. width: 750rpx;
  308. position: relative;
  309. background: #FFFFFF;
  310. bottom: 0;
  311. text {
  312. font-size: 26rpx;
  313. color: #DCDFE6;
  314. }
  315. }
  316. .user {
  317. image {
  318. width: 750rpx;
  319. height: 480rpx;
  320. position: relative;
  321. }
  322. .infor {
  323. height: 126.5rpx;
  324. width: 100%;
  325. // background-color: pink;
  326. display: flex;
  327. position: absolute;
  328. top: 0;
  329. display: flex;
  330. justify-content: center; // 水平平均分布
  331. align-items: center; // 垂直居中
  332. margin-top: 138rpx;
  333. .infor-left {
  334. position: relative;
  335. width: 100%;
  336. height: 126.5rpx;
  337. display: flex;
  338. flex-direction: column;
  339. align-items: center;
  340. justify-content: center;
  341. .info-img {
  342. image {
  343. width: 126rpx;
  344. height: 126rpx;
  345. border-radius: 50%;
  346. overflow: hidden;
  347. flex-shrink: 0;
  348. }
  349. }
  350. .vip-img1 {
  351. border-radius: 20rpx;
  352. position: absolute;
  353. width: 100rpx;
  354. height: 35rpx;
  355. font-size: 24rpx;
  356. color: #C4A774;
  357. line-height: 35rpx;
  358. text-align: center;
  359. background: #1F2125;
  360. // image {
  361. // width: 100%;
  362. // height: 100%;
  363. // }
  364. }
  365. .vip-img2 {
  366. position: absolute;
  367. width: 91rpx;
  368. height: 32rpx;
  369. image {
  370. width: 100%;
  371. height: 100%;
  372. }
  373. }
  374. .vip-img3 {
  375. position: absolute;
  376. width: 117rpx;
  377. height: 32rpx;
  378. image {
  379. width: 100%;
  380. height: 100%;
  381. }
  382. }
  383. .info-box {
  384. margin-left: 21rpx;
  385. display: flex;
  386. align-items: center;
  387. }
  388. .username {
  389. font-size: 34rpx;
  390. font-family: PingFang SC;
  391. font-weight: bold;
  392. color: #FFFFFF;
  393. }
  394. .phone {
  395. padding-top: 10rpx;
  396. font-size: 26rpx;
  397. font-family: PingFang SC;
  398. font-weight: 500;
  399. color: #FFFFFF;
  400. }
  401. .image {
  402. width: 30rpx;
  403. height: 30rpx;
  404. image {
  405. width: 100%;
  406. height: 100%;
  407. }
  408. }
  409. }
  410. .infor-right {
  411. width: 165rpx;
  412. height: 64rpx;
  413. background: #FFFFFF;
  414. border-radius: 32px 0px 0px 32px;
  415. display: flex;
  416. align-items: center; // 垂直居中
  417. padding-left: 20rpx;
  418. image {
  419. width: 32rpx;
  420. height: 31rpx;
  421. }
  422. .setting {
  423. font-size: 28rpx;
  424. font-family: PingFang SC;
  425. font-weight: 500;
  426. color: #3F7C1F;
  427. padding-left: 10rpx;
  428. }
  429. }
  430. }
  431. // 我的订单
  432. .order-box {
  433. width: 710rpx;
  434. height: 221rpx;
  435. background: #FFFFFF;
  436. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  437. border-radius: 20rpx;
  438. position: absolute;
  439. top: 365rpx;
  440. // display: flex;
  441. // justify-content: center; // 水平居中
  442. margin-left: 20rpx;
  443. .my-order {
  444. height: 73rpx;
  445. width: 100%;
  446. border-bottom: 2rpx solid #F5F5F5;
  447. display: flex;
  448. align-items: center;
  449. justify-content: flex-start;
  450. .order {
  451. font-size: 30rpx;
  452. font-family: PingFang SC;
  453. font-weight: bold;
  454. color: #333333;
  455. margin-left: 36rpx;
  456. margin-right: 520rpx;
  457. }
  458. image {
  459. width: 12rpx;
  460. height: 22rpx;
  461. }
  462. }
  463. .order-section {
  464. display: flex;
  465. align-items: center;
  466. justify-content: space-between;
  467. .order-item {
  468. flex: 1;
  469. display: flex;
  470. flex-direction: column;
  471. align-items: center;
  472. justify-content: center;
  473. margin-top: 30rpx;
  474. image {
  475. width: 42rpx;
  476. height: 42rpx;
  477. }
  478. .text {
  479. margin-top: 20rpx;
  480. font-size: 24rpx;
  481. color: #333333;
  482. }
  483. }
  484. }
  485. }
  486. }
  487. .item-box {
  488. padding-top: 80rpx;
  489. height: 900rpx;
  490. background: #FFFFFF;
  491. .item-box-box {
  492. background: #FFFFFF;
  493. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  494. border-radius: 20rpx;
  495. margin: 20rpx;
  496. }
  497. .item-box-title {
  498. font-size: 30rpx;
  499. font-weight: bold;
  500. color: #333333;
  501. padding-top: 10rpx;
  502. margin: 30rpx 0 0 30rpx;
  503. }
  504. // background-color: #fff;
  505. // background-color: pink;
  506. .order-section {
  507. display: flex;
  508. align-items: center;
  509. justify-content: space-between; // 水平平均分布
  510. .order-item {
  511. flex: 1;
  512. display: flex;
  513. flex-direction: column;
  514. align-items: center;
  515. justify-content: center;
  516. margin-top: 30rpx;
  517. image {
  518. width: 70rpx;
  519. height: 60rpx;
  520. }
  521. .text {
  522. margin: 10rpx 0 30rpx;
  523. font-size: 26rpx;
  524. color: #3B3B3B;
  525. }
  526. }
  527. }
  528. }
  529. .btm {
  530. margin: 30rpx;
  531. border-radius: 20rpx;
  532. .ul-btm {
  533. width: 750rpx;
  534. height: 100rpx;
  535. display: flex;
  536. // justify-content: center; // 水平居中
  537. align-items: center; // 水平居中
  538. // justify-content: center; // 垂直居中
  539. image {
  540. width: 35rpx;
  541. height: 35rpx;
  542. }
  543. .text {
  544. margin-left: 30rpx;
  545. }
  546. .btm-right {
  547. width: 620rpx;
  548. display: flex;
  549. justify-content: space-between;
  550. align-items: center;
  551. }
  552. .jiantou {
  553. width: 16rpx;
  554. height: 30rpx;
  555. }
  556. }
  557. }
  558. .popup-box {
  559. width: 522rpx;
  560. height: 605rpx;
  561. background-color: #ffffff;
  562. border-radius: 20rpx;
  563. position: relative;
  564. .img {
  565. position: relative;
  566. top: -56rpx;
  567. left: 0;
  568. width: 522rpx;
  569. height: 132rpx;
  570. display: flex;
  571. justify-content: center;
  572. image {
  573. border-radius: 20rpx 20rpx 0 0;
  574. width: 450rpx;
  575. height: 132rpx;
  576. }
  577. }
  578. .mian {
  579. margin-top: -44rpx;
  580. display: flex;
  581. flex-direction: column;
  582. align-items: center;
  583. // padding: 32rpx 32rpx;
  584. background-color: #ffffff;
  585. border-radius: 0 0 20rpx 20rpx;
  586. text-align: center;
  587. .delivery {
  588. font-size: 40rpx;
  589. color: #333333;
  590. display: flex;
  591. align-items: center;
  592. flex-direction: column;
  593. .title {}
  594. image {
  595. margin-top: 48rpx;
  596. width: 172rpx;
  597. height: 160rpx;
  598. }
  599. }
  600. .nocancel {
  601. font-size: 32rpx;
  602. color: #333333;
  603. margin-top: 14rpx;
  604. }
  605. .comfirm-box {
  606. margin-top: 52rpx;
  607. display: flex;
  608. // margin-bottom: 32rpx;
  609. // justify-content: space-around;
  610. .cancel {
  611. display: flex;
  612. align-items: center;
  613. justify-content: center;
  614. width: 197rpx;
  615. height: 74rpx;
  616. border: 1px solid #dcc786;
  617. border-radius: 38rpx;
  618. font-size: 32rpx;
  619. color: #605128;
  620. }
  621. .comfirm {
  622. margin-left: 32rpx;
  623. display: flex;
  624. align-items: center;
  625. justify-content: center;
  626. width: 197rpx;
  627. height: 74rpx;
  628. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  629. border-radius: 38px;
  630. font-size: 32rpx;
  631. color: #605128;
  632. }
  633. }
  634. }
  635. }
  636. </style>