user.vue 10 KB

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