user.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <view class="container">
  3. <!-- <view class="vheigh"></view> -->
  4. <view class="top">
  5. <view class="bg">
  6. <image src="../../static/img/userBg.png" mode=""></image>
  7. </view>
  8. <view class="set">
  9. <image src="../../static/icon/set.png" mode=""></image>
  10. </view>
  11. </view>
  12. <view class="userInfo-box">
  13. <view class="avatar">
  14. <image src="../../static/icon/fire.png" mode=""></image>
  15. </view>
  16. <view class="name">
  17. 李丹丹
  18. </view>
  19. <view class="myId">
  20. 会员编号:12010 <text class="xian"></text> 推荐人:李丹丹
  21. </view>
  22. <view class="shareId">
  23. 推荐人编号:12010
  24. </view>
  25. </view>
  26. <view class="czzx-box flex">
  27. <view class="czzx-item">
  28. <view class="czzx-icon1">
  29. <image src="../../static/icon/czzx.png" mode=""></image>
  30. </view>
  31. </view>
  32. <view class="czzx-xian"></view>
  33. <view class="czzx-item">
  34. <view class="czzx-icon2">
  35. <image src="../../static/icon/user1.png" mode=""></image>
  36. </view>
  37. <view class="czzx-font">
  38. 草稿箱
  39. </view>
  40. </view>
  41. <view class="czzx-item">
  42. <view class="czzx-icon3">
  43. <image src="../../static/icon/user2.png" mode=""></image>
  44. </view>
  45. <view class="czzx-font">
  46. 审核中
  47. </view>
  48. </view>
  49. <view class="czzx-item">
  50. <view class="czzx-icon4">
  51. <image src="../../static/icon/user3.png" mode=""></image>
  52. </view>
  53. <view class="czzx-font">
  54. 已审核
  55. </view>
  56. </view>
  57. </view>
  58. <view class="box">
  59. <view class="box-title flex">
  60. <view class="box-title-left">
  61. 我的订单
  62. </view>
  63. <view class="box-title-right flex">
  64. <view class="box-title-right-font">
  65. 全部
  66. </view>
  67. <view class="jt">
  68. <image src="../../static/icon/jt.png" mode=""></image>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="box-main flex">
  73. <view class="box-main-item">
  74. <view class="box-main-item-icon1">
  75. <image src="../../static/icon/user4.png" mode=""></image>
  76. </view>
  77. <view class="box-main-item-font">
  78. 待付款
  79. </view>
  80. </view>
  81. <view class="box-main-item">
  82. <view class="box-main-item-icon2">
  83. <image src="../../static/icon/user5.png" mode=""></image>
  84. </view>
  85. <view class="box-main-item-font">
  86. 待发货
  87. </view>
  88. </view>
  89. <view class="box-main-item">
  90. <view class="box-main-item-icon3">
  91. <image src="../../static/icon/user6.png" mode=""></image>
  92. </view>
  93. <view class="box-main-item-font">
  94. 待收获
  95. </view>
  96. </view>
  97. <view class="box-main-item">
  98. <view class="box-main-item-icon4">
  99. <image src="../../static/icon/user7.png" mode=""></image>
  100. </view>
  101. <view class="box-main-item-font">
  102. 已完成
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. <view class="box">
  108. <view class="box-title flex">
  109. <view class="box-title-left">
  110. 我的应用
  111. </view>
  112. </view>
  113. <view class="box-main flex">
  114. <view class="box-main-item">
  115. <view class="box-main-item-icon5">
  116. <image src="../../static/icon/user8.png" mode=""></image>
  117. </view>
  118. <view class="box-main-item-font">
  119. 我的优惠券
  120. </view>
  121. </view>
  122. <view class="box-main-item">
  123. <view class="box-main-item-icon5">
  124. <image src="../../static/icon/user9.png" mode=""></image>
  125. </view>
  126. <view class="box-main-item-font">
  127. 购物车
  128. </view>
  129. </view>
  130. <view class="box-main-item">
  131. <view class="box-main-item-icon5">
  132. <image src="../../static/icon/user10.png" mode=""></image>
  133. </view>
  134. <view class="box-main-item-font">
  135. 收货地址
  136. </view>
  137. </view>
  138. <view class="box-main-item">
  139. <view class="box-main-item-icon5">
  140. <image src="../../static/icon/user11.png" mode=""></image>
  141. </view>
  142. <view class="box-main-item-font">
  143. 新品提醒
  144. </view>
  145. </view>
  146. </view>
  147. </view>
  148. <view class="box">
  149. <view class="box-title flex">
  150. <view class="box-title-left">
  151. 更多服务
  152. </view>
  153. </view>
  154. <view class="box-main flex">
  155. <view class="box-main-item">
  156. <view class="box-main-item-icon5">
  157. <image src="../../static/icon/user12.png" mode=""></image>
  158. </view>
  159. <view class="box-main-item-font">
  160. 直播广场
  161. </view>
  162. </view>
  163. <view class="box-main-item">
  164. <view class="box-main-item-icon5">
  165. <image src="../../static/icon/user13.png" mode=""></image>
  166. </view>
  167. <view class="box-main-item-font">
  168. 主播入口
  169. </view>
  170. </view>
  171. </view>
  172. </view>
  173. </view>
  174. </template>
  175. <script>
  176. import {
  177. mapState,
  178. mapMutations
  179. } from 'vuex';
  180. import uniList from '@/components/uni-list/uni-list.vue';
  181. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  182. import {
  183. orderData,
  184. getUserInfo
  185. } from '@/api/user.js';
  186. import {
  187. saveUrl,
  188. interceptor
  189. } from '@/utils/loginUtils.js';
  190. export default {
  191. data() {
  192. return {};
  193. },
  194. onShow() {
  195. // 判断是否已经登录
  196. if (this.hasLogin) {
  197. this.loadBaseData();
  198. }
  199. },
  200. computed: {
  201. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  202. },
  203. methods: {
  204. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  205. // 加载初始数据
  206. loadBaseData() {
  207. getUserInfo({})
  208. .then(({
  209. data
  210. }) => {
  211. this.setUserInfo(data);
  212. // 获取用户数据完毕后在获取订单数据防止多次跳转到登录页
  213. orderData({})
  214. .then(({
  215. data
  216. }) => {
  217. this.setOrderInfo(data);
  218. })
  219. .catch(e => {
  220. this.setOrderInfo({
  221. complete_count: 0, //完成
  222. received_count: 0, //待收货
  223. unshipped_count: 0, //待发货
  224. order_count: 0, //订单总数
  225. unpaid_count: 0 //待付款
  226. });
  227. });
  228. })
  229. .catch(e => {
  230. console.log(e);
  231. });
  232. },
  233. /**
  234. * 统一跳转接口,拦截未登录路由
  235. * navigator标签现在默认没有转场动画,所以用view
  236. */
  237. navTo(url) {
  238. if (!this.hasLogin) {
  239. // 保存地址
  240. saveUrl();
  241. // 登录拦截
  242. interceptor();
  243. } else {
  244. uni.navigateTo({
  245. url
  246. });
  247. }
  248. },
  249. }
  250. };
  251. </script>
  252. <style lang="scss">
  253. page {
  254. height: 100%;
  255. }
  256. %flex-center {
  257. display: flex;
  258. flex-direction: column;
  259. justify-content: center;
  260. align-items: center;
  261. }
  262. %section {
  263. display: flex;
  264. justify-content: space-around;
  265. align-content: center;
  266. background: #fff;
  267. border-radius: 10rpx;
  268. }
  269. .container {
  270. height: 100%;
  271. background-color: $page-color-base;
  272. }
  273. .content-box {
  274. height: 100%;
  275. }
  276. .vheigh {
  277. height: var(--status-bar-height);
  278. background-color: #ffffff;
  279. }
  280. .top {
  281. position: absolute;
  282. top: 0;
  283. left: 0;
  284. right: 0;
  285. width: 750rpx;
  286. height: 224rpx;
  287. .bg {
  288. position: absolute;
  289. top: 0;
  290. left: 0;
  291. right: 0;
  292. width: 750rpx;
  293. height: 224rpx;
  294. image {
  295. width: 100%;
  296. height: 100%;
  297. }
  298. }
  299. .set {
  300. position: absolute;
  301. z-index: 2;
  302. width: 44rpx;
  303. height: 44rpx;
  304. top: 96rpx;
  305. right: 40rpx;
  306. image {
  307. width: 100%;
  308. height: 100%;
  309. }
  310. }
  311. }
  312. .userInfo-box {
  313. display: flex;
  314. flex-direction: column;
  315. justify-content: center;
  316. align-items: center;
  317. padding-top: 117rpx;
  318. .avatar {
  319. width: 130rpx;
  320. height: 130rpx;
  321. background: #FFFFFF;
  322. border-radius: 50%;
  323. image {
  324. width: 100%;
  325. height: 100%;
  326. border-radius: 50%;
  327. }
  328. }
  329. .name {
  330. margin-top: 20rpx;
  331. font-size: 34rpx;
  332. font-family: PingFang SC;
  333. font-weight: 800;
  334. color: #000000;
  335. }
  336. .myId {
  337. margin-top: 20rpx;
  338. font-size: 20rpx;
  339. font-family: PingFang SC;
  340. font-weight: 500;
  341. color: #333333;
  342. .xian {
  343. display: inline-block;
  344. margin: 0 12rpx;
  345. width: 2rpx;
  346. height: 20rpx;
  347. background: #CBCDCF;
  348. }
  349. }
  350. .shareId {
  351. margin-top: 20rpx;
  352. font-size: 20rpx;
  353. font-family: PingFang SC;
  354. font-weight: 500;
  355. color: #333333;
  356. }
  357. }
  358. .czzx-box {
  359. margin: 50rpx auto 0;
  360. width: 708rpx;
  361. background: #FFFFFF;
  362. border-radius: 5rpx;
  363. padding: 28rpx 0 22rpx;
  364. .czzx-xian {
  365. width: 1px;
  366. height: 81rpx;
  367. background: #EBEBEB;
  368. }
  369. .czzx-item {
  370. width: 25%;
  371. display: flex;
  372. flex-direction: column;
  373. justify-content: center;
  374. align-items: center;
  375. image {
  376. width: 100%;
  377. height: 100%;
  378. }
  379. .czzx-icon1 {
  380. width: 58rpx;
  381. height: 64rpx;
  382. }
  383. .czzx-icon2 {
  384. width: 42rpx;
  385. height: 42rpx;
  386. }
  387. .czzx-icon3 {
  388. width: 44rpx;
  389. height: 36rpx;
  390. }
  391. .czzx-icon4 {
  392. width: 42rpx;
  393. height: 40rpx;
  394. }
  395. .czzx-font {
  396. margin-top: 20rpx;
  397. font-size: 22rpx;
  398. font-family: PingFang SC;
  399. font-weight: 500;
  400. color: #000000;
  401. }
  402. }
  403. }
  404. .box {
  405. margin: 20rpx auto 0;
  406. width: 708rpx;
  407. background: #FFFFFF;
  408. border-radius: 5rpx;
  409. .box-title {
  410. padding: 27rpx 36rpx 20rpx 28rpx;
  411. border-bottom: 1px solid #F5F5F5;
  412. .box-title-left {
  413. font-size: 28rpx;
  414. font-family: PingFang SC;
  415. font-weight: bold;
  416. color: #333333;
  417. }
  418. .box-title-right {
  419. justify-content: flex-end;
  420. align-items: center;
  421. .box-title-right-font {
  422. font-size: 26rpx;
  423. font-family: SourceHanSansCN;
  424. font-weight: 400;
  425. color: #666666;
  426. margin-right: 14rpx;
  427. }
  428. .jt {
  429. position: relative;
  430. top: -6rpx;
  431. width: 12rpx;
  432. height: 22rpx;
  433. image {
  434. width: 100%;
  435. height: 100%;
  436. }
  437. }
  438. }
  439. }
  440. .box-main {
  441. padding: 34rpx 0 30rpx;
  442. justify-content: start;
  443. .box-main-item {
  444. width: 25%;
  445. display: flex;
  446. flex-direction: column;
  447. align-items: center;
  448. justify-content: center;
  449. image {
  450. width: 100%;
  451. height: 100%;
  452. }
  453. .box-main-item-icon1 {
  454. width: 42rpx;
  455. height: 38rpx;
  456. }
  457. .box-main-item-icon2 {
  458. width: 47rpx;
  459. height: 40rpx;
  460. }
  461. .box-main-item-icon3 {
  462. width: 42rpx;
  463. height: 40rpx;
  464. }
  465. .box-main-item-icon4 {
  466. width: 42rpx;
  467. height: 42rpx;
  468. }
  469. .box-main-item-icon5 {
  470. width: 70rpx;
  471. height: 70rpx;
  472. }
  473. .box-main-item-font {
  474. margin-top: 23rpx;
  475. font-size: 24rpx;
  476. font-family: PingFang SC;
  477. font-weight: 500;
  478. color: #333333;
  479. }
  480. }
  481. }
  482. }
  483. </style>