user.vue 15 KB

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