user.vue 13 KB

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