user.vue 13 KB

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