user.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. <template>
  2. <view class="container">
  3. <!-- 用户信息 -->
  4. <view class="user">
  5. <!-- 背景图片 -->
  6. <image src="../../static/img/img17.png" mode="scaleToFill"></image>
  7. <!-- 用户头像和信息 -->
  8. <view class="infor">
  9. <!-- 用户信息 -->
  10. <view class="infor-left">
  11. <image :src=" userInfo.avatar || '../../static/error/missing-face.png' "></image>
  12. <view class="info-box">
  13. <view class="username">{{ userInfo.nickname || '游客' }}</view>
  14. <view class="phone" v-if="userInfo.phone">{{userInfo.phone | phone}}</view>
  15. </view>
  16. </view>
  17. <!-- 设置 -->
  18. <view class="infor-right" @click="nav('/pages/set/userinfo')">
  19. <image src="../../static/img/img18.png" mode="scaleToFill"></image>
  20. <view class="setting">设置</view>
  21. </view>
  22. </view>
  23. <!-- 我的订单 -->
  24. <view class="order-box">
  25. <view class="my-order" @click="nav('/pages/order/order')">
  26. <view class="order">我的订单</view>
  27. <image src="../../static/img/xiangxia.png" mode="scaleToFill"></image>
  28. </view>
  29. <!-- 订单栏 -->
  30. <view class="order-section">
  31. <view class="order-item" @click="nav('/pages/order/order?state=0')">
  32. <image src="../../static/img/img19.png" mode="scaleToFill"></image>
  33. <view class="text">待付款</view>
  34. </view>
  35. <view class="order-item" @click="nav('/pages/order/order?state=1')">
  36. <image src="../../static/img/img20.png" mode="scaleToFill"></image>
  37. <view class="text">待发货</view>
  38. </view>
  39. <view class="order-item" @click="nav('/pages/order/order?state=2')">
  40. <image src="../../static/img/img21.png" mode="scaleToFill"></image>
  41. <view class="text">待收货</view>
  42. </view>
  43. <view class="order-item" @click="nav('/pages/order/order?state=4')">
  44. <image src="../../static/img/img22.png" mode="scaleToFill"></image>
  45. <view class="text">已完成</view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 下部分 -->
  51. <view class="item-box">
  52. <!-- 我的余额 -->
  53. <view class="order-section">
  54. <view class="order-item" @click="nav('/pages/money/wallet')">
  55. <image src="../../static/img/img26.png" mode="scaleToFill"></image>
  56. <view class="text">我的余额</view>
  57. </view>
  58. <view class="order-item" @click="nav('/pages/user/award')">
  59. <image src="../../static/img/img23.png" mode="scaleToFill"></image>
  60. <view class="text">我的佣金</view>
  61. </view>
  62. <view class="order-item" @click="nav('/pages/user/integral')">
  63. <image src="../../static/img/img24.png" mode="scaleToFill"></image>
  64. <view class="text">我的积分</view>
  65. </view>
  66. <view class="order-item" @click="nav('/pages/user/extension')">
  67. <image src="../../static/img/img25.png" mode="scaleToFill"></image>
  68. <view class="text">我的推广</view>
  69. </view>
  70. </view>
  71. <!-- 底部列表 -->
  72. <view class="btm">
  73. <view class="ul-btm" @click="nav('/pages/user/jiedian')">
  74. <image src="../../static/img/img27.png" mode="scaleToFill"></image>
  75. <view class="text">我的接点</view>
  76. <image class="jiantou" src="../../static/img/img32.png" mode="scaleToFill"></image>
  77. </view>
  78. <view class="ul-btm" @click="nav('/pages/user/shareQrCode')">
  79. <image src="../../static/img/img28.png" mode="scaleToFill"></image>
  80. <view class="text">邀请海报</view>
  81. <image class="jiantou" src="../../static/img/img32.png" mode="scaleToFill"></image>
  82. </view>
  83. <view class="ul-btm" @click="nav('/pages/public/register')">
  84. <image src="../../static/img/img29.png" mode="scaleToFill"></image>
  85. <view class="text">会员注册</view>
  86. <image class="jiantou" src="../../static/img/img32.png" mode="scaleToFill"></image>
  87. </view>
  88. <view class="ul-btm" @click="nav('/pages/set/address')">
  89. <image src="../../static/img/img30.png" mode="scaleToFill"></image>
  90. <view class="text">收货地址</view>
  91. <image class="jiantou" src="../../static/img/img32.png" mode="scaleToFill"></image>
  92. </view>
  93. <view class="ul-btm" @click="open()">
  94. <image src="../../static/img/img31.png" mode="scaleToFill"></image>
  95. <view class="text">联系客服</view>
  96. <image class="jiantou" src="../../static/img/img32.png" mode="scaleToFill"></image>
  97. </view>
  98. </view>
  99. </view>
  100. <uni-popup ref="popup" type="center">
  101. <view class="popup-box">
  102. <view class="img"><image src="../../static/img/img009.png" mode=""></image></view>
  103. <view class="mian">
  104. <view class="delivery">
  105. <view class="title">已经为您定制专属客服</view>
  106. <image src="../../static/img/img010.png" mode=""></image>
  107. </view>
  108. <view class="nocancel">客服VX:{{ text }}</view>
  109. <view class="comfirm-box">
  110. <view class="cancel" @click="cancel">取消</view>
  111. <view class="comfirm" @click="comfirm(text)">复制微信</view>
  112. </view>
  113. </view>
  114. </view>
  115. </uni-popup>
  116. </view>
  117. </template>
  118. <script>
  119. import { orderData, getUserInfo,service } from '@/api/user.js';
  120. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  121. import uniCopy from '@/utils/uni-copy.js';
  122. import { mapState, mapMutations } from 'vuex';
  123. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  124. export default {
  125. components: {
  126. uniPopup
  127. },
  128. data() {
  129. return {
  130. text:'123465'
  131. }
  132. },
  133. filters: {
  134. phone(val) {
  135. let str = ''
  136. if(val) {
  137. val = "" + val;
  138. str = val.substr(0,3) + "****" + val.substr(7)
  139. }
  140. return str
  141. }
  142. },
  143. onShow() {
  144. //判断是否已经登录
  145. if (this.hasLogin) {
  146. this.loadBaseData();
  147. } else {
  148. uni.showModal({
  149. title: '登录',
  150. content: '您未登录,是否马上登陆?',
  151. success: e => {
  152. if (e.confirm) {
  153. interceptor();
  154. }
  155. },
  156. fail: e => {
  157. console.log(e);
  158. }
  159. });
  160. }
  161. },
  162. computed: {
  163. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  164. },
  165. methods: {
  166. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  167. loadBaseData() {
  168. getUserInfo({})
  169. .then(({ data }) => {
  170. console.log(data)
  171. this.setUserInfo(data);
  172. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  173. orderData({})
  174. .then(({ data }) => {
  175. this.setOrderInfo(data);
  176. })
  177. .catch(e => {
  178. this.setOrderInfo({
  179. complete_count: 0, //完成
  180. received_count: 0, //待收货
  181. unshipped_count: 0, //待发货
  182. order_count: 0, //订单总数
  183. unpaid_count: 0 //待付款
  184. });
  185. });
  186. })
  187. .catch(e => {
  188. console.log(e);
  189. });
  190. },
  191. nav(url) {
  192. console.log(url)
  193. if(!this.hasLogin) {
  194. // 保存地址
  195. saveUrl();
  196. // 登录拦截
  197. interceptor();
  198. }else {
  199. uni.navigateTo({
  200. url
  201. })
  202. }
  203. },
  204. open(){
  205. console.log('点击出现弹窗');
  206. this.$refs.popup.open();
  207. },
  208. // 客服弹窗 - 复制微信
  209. comfirm(value) {
  210. let content = value; //需要复制的内容
  211. console.log('复制的内容:', content);
  212. // content = typeof content === 'string' ? content : content.toString(); // 复制内容,必须字符串,数字需要转换为字符串
  213. const result = uniCopy({content,success});
  214. if (result === false) {
  215. uni.showToast({
  216. title: '不支持'
  217. });
  218. } else {
  219. uni.showToast({
  220. title: '复制成功',
  221. icon: 'none'
  222. });
  223. }
  224. this.$refs.popup.close();
  225. },
  226. // 客服弹窗 - 取消
  227. cancel() {
  228. this.$refs.popup.close();
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="scss">
  234. .container {
  235. background-color: #fff;
  236. }
  237. .user {
  238. image {
  239. width: 750rpx;
  240. height: 480rpx;
  241. position: relative;
  242. }
  243. .infor {
  244. height: 126.5rpx;
  245. width: 100%;
  246. // background-color: pink;
  247. display: flex;
  248. position: absolute;
  249. top: 0;
  250. display: flex;
  251. justify-content: space-around; // 水平平均分布
  252. align-items: center; // 垂直居中
  253. margin-top: 138rpx;
  254. .infor-left {
  255. width: 100%;
  256. height: 126.5rpx;
  257. display: flex;
  258. align-items: center;
  259. padding-left: 23rpx;
  260. image {
  261. width: 126.5rpx;
  262. height: 126.5rpx;
  263. border-radius: 50%;
  264. flex-shrink: 0;
  265. }
  266. .info-box {
  267. margin-left: 21rpx;
  268. }
  269. .username {
  270. font-size: 34rpx;
  271. font-family: PingFang SC;
  272. font-weight: bold;
  273. color: #3F7C1F;
  274. }
  275. .phone {
  276. padding-top: 10rpx;
  277. font-size: 26rpx;
  278. font-family: PingFang SC;
  279. font-weight: 500;
  280. color: #3F7C1F;
  281. }
  282. }
  283. .infor-right {
  284. width: 165rpx;
  285. height: 64rpx;
  286. background: #FFFFFF;
  287. border-radius: 32px 0px 0px 32px;
  288. display: flex;
  289. align-items: center; // 垂直居中
  290. padding-left: 20rpx;
  291. image {
  292. width: 32rpx;
  293. height: 31rpx;
  294. }
  295. .setting {
  296. font-size: 28rpx;
  297. font-family: PingFang SC;
  298. font-weight: 500;
  299. color: #3F7C1F;
  300. padding-left: 10rpx;
  301. }
  302. }
  303. }
  304. // 我的订单
  305. .order-box {
  306. width: 710rpx;
  307. height: 221rpx;
  308. background: #FFFFFF;
  309. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  310. border-radius: 20rpx;
  311. position: absolute;
  312. top: 335rpx;
  313. // display: flex;
  314. // justify-content: center; // 水平居中
  315. margin-left: 20rpx;
  316. .my-order {
  317. height: 73rpx;
  318. width: 100%;
  319. border-bottom: 2rpx solid #F5F5F5;
  320. display: flex;
  321. align-items: center;
  322. justify-content: flex-start;
  323. .order {
  324. font-size: 30rpx;
  325. font-family: PingFang SC;
  326. font-weight: bold;
  327. color: #333333;
  328. margin-left: 36rpx;
  329. margin-right: 520rpx;
  330. }
  331. image {
  332. width: 12rpx;
  333. height: 22rpx;
  334. }
  335. }
  336. .order-section {
  337. display: flex;
  338. align-items: center;
  339. justify-content: space-between;
  340. .order-item {
  341. flex: 1;
  342. display: flex;
  343. flex-direction: column;
  344. align-items: center;
  345. justify-content: center;
  346. margin-top: 30rpx;
  347. image {
  348. width: 42rpx;
  349. height: 42rpx;
  350. }
  351. .text {
  352. margin-top: 20rpx;
  353. font-size: 24rpx;
  354. color: #333333;
  355. }
  356. }
  357. }
  358. }
  359. }
  360. .item-box {
  361. padding-top: 80rpx;
  362. height: 900rpx;
  363. // background-color: #fff;
  364. // background-color: pink;
  365. .order-section {
  366. display: flex;
  367. align-items: center;
  368. justify-content: space-between; // 水平平均分布
  369. .order-item {
  370. flex: 1;
  371. display: flex;
  372. flex-direction: column;
  373. align-items: center;
  374. justify-content: center;
  375. margin-top: 30rpx;
  376. image {
  377. width: 90rpx;
  378. height: 90rpx;
  379. }
  380. .text {
  381. margin-top: 10rpx;
  382. font-size: 26rpx;
  383. color: #3B3B3B;
  384. }
  385. }
  386. }
  387. }
  388. .btm {
  389. margin-top: 40rpx;
  390. padding-bottom: 200rpx;
  391. margin-left: 42rpx;
  392. .ul-btm {
  393. width: 100%;
  394. height: 100rpx;
  395. display: flex;
  396. // justify-content: center; // 水平居中
  397. align-items: center; // 水平居中
  398. // justify-content: center; // 垂直居中
  399. image {
  400. width: 35rpx;
  401. height: 35rpx;
  402. }
  403. .text {
  404. margin-right: 468rpx;
  405. margin-left: 30rpx;
  406. }
  407. .jiantou {
  408. width: 16rpx;
  409. height: 30rpx;
  410. }
  411. }
  412. }
  413. .popup-box {
  414. width: 522rpx;
  415. height: 605rpx;
  416. background-color: #ffffff;
  417. border-radius: 20rpx;
  418. position: relative;
  419. .img {
  420. position: relative;
  421. top: -56rpx;
  422. left: 0;
  423. width: 522rpx;
  424. height: 132rpx;
  425. display: flex;
  426. justify-content: center;
  427. image {
  428. border-radius: 20rpx 20rpx 0 0;
  429. width: 450rpx;
  430. height: 132rpx;
  431. }
  432. }
  433. .mian {
  434. margin-top: -44rpx;
  435. display: flex;
  436. flex-direction: column;
  437. align-items: center;
  438. // padding: 32rpx 32rpx;
  439. background-color: #ffffff;
  440. border-radius: 0 0 20rpx 20rpx;
  441. text-align: center;
  442. .delivery {
  443. font-size: 40rpx;
  444. color: #333333;
  445. display: flex;
  446. align-items: center;
  447. flex-direction: column;
  448. .title {
  449. }
  450. image {
  451. margin-top: 48rpx;
  452. width: 172rpx;
  453. height: 160rpx;
  454. }
  455. }
  456. .nocancel {
  457. font-size: 32rpx;
  458. color: #333333;
  459. margin-top: 14rpx;
  460. }
  461. .comfirm-box {
  462. margin-top: 52rpx;
  463. display: flex;
  464. // margin-bottom: 32rpx;
  465. // justify-content: space-around;
  466. .cancel {
  467. display: flex;
  468. align-items: center;
  469. justify-content: center;
  470. width: 197rpx;
  471. height: 74rpx;
  472. border: 1px solid #dcc786;
  473. border-radius: 38rpx;
  474. font-size: 32rpx;
  475. color: #605128;
  476. }
  477. .comfirm {
  478. margin-left: 32rpx;
  479. display: flex;
  480. align-items: center;
  481. justify-content: center;
  482. width: 197rpx;
  483. height: 74rpx;
  484. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  485. border-radius: 38px;
  486. font-size: 32rpx;
  487. color: #605128;
  488. }
  489. }
  490. }
  491. }
  492. </style>