user.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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=1')">
  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=2')">
  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=3')">
  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/accounts')">
  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. uni.navigateTo({
  183. url
  184. })
  185. },
  186. open(){
  187. console.log('点击出现弹窗');
  188. this.$refs.popup.open();
  189. },
  190. // 客服弹窗 - 复制微信
  191. comfirm(value) {
  192. let content = value; //需要复制的内容
  193. console.log('复制的内容:', content);
  194. // content = typeof content === 'string' ? content : content.toString(); // 复制内容,必须字符串,数字需要转换为字符串
  195. const result = uniCopy({content,success});
  196. if (result === false) {
  197. uni.showToast({
  198. title: '不支持'
  199. });
  200. } else {
  201. uni.showToast({
  202. title: '复制成功',
  203. icon: 'none'
  204. });
  205. }
  206. this.$refs.popup.close();
  207. },
  208. // 客服弹窗 - 取消
  209. cancel() {
  210. this.$refs.popup.close();
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss">
  216. .container {
  217. background-color: #fff;
  218. }
  219. .user {
  220. image {
  221. width: 750rpx;
  222. height: 480rpx;
  223. position: relative;
  224. }
  225. .infor {
  226. height: 126.5rpx;
  227. width: 100%;
  228. // background-color: pink;
  229. display: flex;
  230. position: absolute;
  231. top: 0;
  232. display: flex;
  233. justify-content: space-around; // 水平平均分布
  234. align-items: center; // 垂直居中
  235. margin-top: 138rpx;
  236. .infor-left {
  237. width: 100%;
  238. height: 126.5rpx;
  239. display: flex;
  240. align-items: center;
  241. padding-left: 23rpx;
  242. image {
  243. width: 126.5rpx;
  244. height: 126.5rpx;
  245. }
  246. .info-box {
  247. margin-left: 21rpx;
  248. }
  249. .username {
  250. font-size: 34rpx;
  251. font-family: PingFang SC;
  252. font-weight: bold;
  253. color: #3F7C1F;
  254. }
  255. .phone {
  256. font-size: 26rpx;
  257. font-family: PingFang SC;
  258. font-weight: 500;
  259. color: #3F7C1F;
  260. }
  261. }
  262. .infor-right {
  263. width: 165rpx;
  264. height: 64rpx;
  265. background: #FFFFFF;
  266. border-radius: 32px 0px 0px 32px;
  267. display: flex;
  268. align-items: center; // 垂直居中
  269. padding-left: 20rpx;
  270. image {
  271. width: 32rpx;
  272. height: 31rpx;
  273. }
  274. .setting {
  275. font-size: 28rpx;
  276. font-family: PingFang SC;
  277. font-weight: 500;
  278. color: #3F7C1F;
  279. padding-left: 10rpx;
  280. }
  281. }
  282. }
  283. // 我的订单
  284. .order-box {
  285. width: 710rpx;
  286. height: 221rpx;
  287. background: #FFFFFF;
  288. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  289. border-radius: 20rpx;
  290. position: absolute;
  291. top: 335rpx;
  292. // display: flex;
  293. // justify-content: center; // 水平居中
  294. margin-left: 20rpx;
  295. .my-order {
  296. height: 73rpx;
  297. width: 100%;
  298. border-bottom: 2rpx solid #F5F5F5;
  299. display: flex;
  300. align-items: center;
  301. justify-content: flex-start;
  302. .order {
  303. font-size: 30rpx;
  304. font-family: PingFang SC;
  305. font-weight: bold;
  306. color: #333333;
  307. margin-left: 36rpx;
  308. margin-right: 520rpx;
  309. }
  310. image {
  311. width: 12rpx;
  312. height: 22rpx;
  313. }
  314. }
  315. .order-section {
  316. display: flex;
  317. align-items: center;
  318. justify-content: space-between;
  319. .order-item {
  320. flex: 1;
  321. display: flex;
  322. flex-direction: column;
  323. align-items: center;
  324. justify-content: center;
  325. margin-top: 30rpx;
  326. image {
  327. width: 42rpx;
  328. height: 42rpx;
  329. }
  330. .text {
  331. margin-top: 20rpx;
  332. font-size: 24rpx;
  333. color: #333333;
  334. }
  335. }
  336. }
  337. }
  338. }
  339. .item-box {
  340. padding-top: 80rpx;
  341. height: 900rpx;
  342. // background-color: #fff;
  343. // background-color: pink;
  344. .order-section {
  345. display: flex;
  346. align-items: center;
  347. justify-content: space-between; // 水平平均分布
  348. .order-item {
  349. flex: 1;
  350. display: flex;
  351. flex-direction: column;
  352. align-items: center;
  353. justify-content: center;
  354. margin-top: 30rpx;
  355. image {
  356. width: 90rpx;
  357. height: 90rpx;
  358. }
  359. .text {
  360. margin-top: 10rpx;
  361. font-size: 26rpx;
  362. color: #3B3B3B;
  363. }
  364. }
  365. }
  366. }
  367. .btm {
  368. margin-top: 40rpx;
  369. padding-bottom: 200rpx;
  370. margin-left: 42rpx;
  371. .ul-btm {
  372. width: 100%;
  373. height: 100rpx;
  374. display: flex;
  375. // justify-content: center; // 水平居中
  376. align-items: center; // 水平居中
  377. // justify-content: center; // 垂直居中
  378. image {
  379. width: 35rpx;
  380. height: 35rpx;
  381. }
  382. .text {
  383. margin-right: 468rpx;
  384. margin-left: 30rpx;
  385. }
  386. .jiantou {
  387. width: 16rpx;
  388. height: 30rpx;
  389. }
  390. }
  391. }
  392. .popup-box {
  393. width: 522rpx;
  394. height: 605rpx;
  395. background-color: #ffffff;
  396. border-radius: 20rpx;
  397. position: relative;
  398. .img {
  399. position: relative;
  400. top: -56rpx;
  401. left: 0;
  402. width: 522rpx;
  403. height: 132rpx;
  404. display: flex;
  405. justify-content: center;
  406. image {
  407. border-radius: 20rpx 20rpx 0 0;
  408. width: 450rpx;
  409. height: 132rpx;
  410. }
  411. }
  412. .mian {
  413. margin-top: -44rpx;
  414. display: flex;
  415. flex-direction: column;
  416. align-items: center;
  417. // padding: 32rpx 32rpx;
  418. background-color: #ffffff;
  419. border-radius: 0 0 20rpx 20rpx;
  420. text-align: center;
  421. .delivery {
  422. font-size: 40rpx;
  423. color: #333333;
  424. display: flex;
  425. align-items: center;
  426. flex-direction: column;
  427. .title {
  428. }
  429. image {
  430. margin-top: 48rpx;
  431. width: 172rpx;
  432. height: 160rpx;
  433. }
  434. }
  435. .nocancel {
  436. font-size: 32rpx;
  437. color: #333333;
  438. margin-top: 14rpx;
  439. }
  440. .comfirm-box {
  441. margin-top: 52rpx;
  442. display: flex;
  443. // margin-bottom: 32rpx;
  444. // justify-content: space-around;
  445. .cancel {
  446. display: flex;
  447. align-items: center;
  448. justify-content: center;
  449. width: 197rpx;
  450. height: 74rpx;
  451. border: 1px solid #dcc786;
  452. border-radius: 38rpx;
  453. font-size: 32rpx;
  454. color: #605128;
  455. }
  456. .comfirm {
  457. margin-left: 32rpx;
  458. display: flex;
  459. align-items: center;
  460. justify-content: center;
  461. width: 197rpx;
  462. height: 74rpx;
  463. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  464. border-radius: 38px;
  465. font-size: 32rpx;
  466. color: #605128;
  467. }
  468. }
  469. }
  470. }
  471. </style>