user.vue 13 KB

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