index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <template>
  2. <view>
  3. <!-- 状态栏高度 -->
  4. <view :style="{ height: `${statusBarHeight}px` }"></view>
  5. <!-- 导航栏 -->
  6. <view :style="{ height: `${navigationBarHeight}px`,lineHeight: `${navigationBarHeight}px`}" class="order-nav">
  7. 个人中心
  8. </view>
  9. <view style="background-color: #FF6702;height: 60rpx;"></view>
  10. <view class="card">
  11. <view class="card-left">
  12. <view class="name" v-if="!isLogin" @tap="openAuto">
  13. <image class="avatar tui-skeleton-rect" :src='userInfo.avatar' v-if="userInfo.avatar" @click="goEdit()"></image>
  14. <image v-else class="avatar tui-skeleton-rect" :src="urlDomain+'crmebimage/presets/morenT.png'" mode="" @click="goEdit()">
  15. </image>
  16. <view class="username">请点击登录</view>
  17. </view>
  18. <template v-else>
  19. <image class="avatar tui-skeleton-rect" :src='userInfo.avatar' v-if="userInfo.avatar" @click="goEdit()"></image>
  20. <image v-else class="avatar tui-skeleton-rect" :src="urlDomain+'crmebimage/presets/morenT.png'" mode="" @click="goEdit()">
  21. </image>
  22. <view class="username">
  23. {{userInfo.nickname}}
  24. <!-- <image src="/static/img/ic-code.png" class="code"></image> -->
  25. </view>
  26. <view class="phone-info">
  27. <text>绑定手机号:{{userInfo.phone}}</text>
  28. <image src="/static/img/ic-copy.png">
  29. </image>
  30. </view>
  31. </template>
  32. </view>
  33. <view class="card-right">
  34. <view class="card-content">
  35. <view class="content-item">
  36. <img class="content-icon" src="/static/img/ic-tickets.png" alt="我的票劵">
  37. <view class="content-text1">我的票劵</view>
  38. </view>
  39. <view class="content-item" @click="menusTap('/pages/goods/order_list/index')">
  40. <img class="content-icon" src="/static/img/ic-order.png" alt="我的订单">
  41. <view class="content-text2">我的订单</view>
  42. </view>
  43. <view class="content-item">
  44. <img class="content-icon" src="/static/img/ic-gold.png" alt="我的金币">
  45. <view class="content-text3">我的金币</view>
  46. </view>
  47. </view>
  48. <!-- <view class="profile-link">
  49. <text>个人中心</text>
  50. <img src="/static/img/ic-right.png" />
  51. </view> -->
  52. </view>
  53. </view>
  54. <view style="position: relative;top: -90rpx;">
  55. <view class="item-settled">
  56. <image @tap="menusTap('/pages/users/settled/index')" src="/static/img/ic-settled-left.png" style="width: 350rpx;height: 116rpx;"></image>
  57. <image src="/static/img/ic-bg-line.png" style="width: 10rpx;height: 154rpx;margin: 0 20rpx;"></image>
  58. <image v-if="!userInfo.isRider" @tap="menusRider('/pages/users/user_rider/index')" src="/static/img/ic-settled-right.png"
  59. style="width: 350rpx;height: 116rpx;"></image>
  60. <image v-else @tap="menusRider('/pages/rider_index/index', true)" src="/static/img/go-shipping.png" style="width: 350rpx;height: 116rpx;"></image>
  61. </view>
  62. <view class="order-box">
  63. <view class="order-hd flex">
  64. <view class="left">订单中心</view>
  65. <view class="right flex" @click="menusTap('/pages/goods/order_list/index')">查看全部
  66. <text class="iconfont icon-xiangyou"></text>
  67. </view>
  68. </view>
  69. <view class="order-bd">
  70. <block v-for="(item,index) in orderMenu" :key="index">
  71. <view class="order-item" @click="menusTap(item.url)">
  72. <view class="pic">
  73. <text class="iconfont pic_status" :class="item.img"></text>
  74. <text class="order-status-num" v-if="item.num > 0">{{ item.num }}</text>
  75. </view>
  76. <view class="txt tui-skeleton-rect">{{item.title}}</view>
  77. </view>
  78. </block>
  79. </view>
  80. </view>
  81. <view class="item-features" v-if="isLogin">
  82. <view class="item-features-title">我的功能</view>
  83. <div class="grid-container">
  84. <!-- 示例:12 个格子(3行x4列) -->
  85. <div class="grid-item" v-for="item in featuresList" :key="item.id" @click="menusTap(item.url)">
  86. <img class="grid-img" :src="item.icon">
  87. <div class="grid-text">{{item.text}}</div>
  88. </div>
  89. </div>
  90. </view>
  91. </view>
  92. </view>
  93. </template>
  94. <script>
  95. var statusBarHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
  96. let app = getApp();
  97. import {
  98. userCenterInfo,
  99. copyrightImageApi
  100. } from '@/api/user.js';
  101. import Cache from '@/utils/cache';
  102. import {
  103. orderNum
  104. } from '@/api/order.js';
  105. import {
  106. toLogin
  107. } from '@/libs/login.js';
  108. import {
  109. mapGetters
  110. } from "vuex";
  111. import {
  112. BACK_URL
  113. } from '@/config/cache';
  114. import animationType from '@/utils/animationType.js'
  115. export default {
  116. computed: mapGetters(['isLogin']),
  117. data() {
  118. return {
  119. statusBarHeight: app.globalData.statusBarHeight,
  120. navigationBarHeight: 0,
  121. userInfo: {},
  122. urlDomain: this.$Cache.get("imgHost"),
  123. orderMenu: [{
  124. img: 'icon-daifukuan',
  125. title: '待付款',
  126. url: '/pages/goods/order_list/index?status=0',
  127. num: 0
  128. },
  129. {
  130. img: 'icon-daifahuo',
  131. title: '待发货',
  132. url: '/pages/goods/order_list/index?status=1',
  133. num: 0
  134. },
  135. {
  136. img: 'icon-daihexiao',
  137. title: '待核销',
  138. url: '/pages/goods/order_list/index?status=3',
  139. num: 0
  140. },
  141. {
  142. img: 'icon-daishouhuo',
  143. title: '待收货',
  144. url: '/pages/goods/order_list/index?status=4',
  145. num: 0
  146. },
  147. {
  148. img: 'icon-daipingjia',
  149. title: '待评价',
  150. url: '/pages/goods/evaluation_list/index',
  151. num: 0
  152. },
  153. {
  154. img: 'icon-a-shouhoutuikuan',
  155. title: '售后/退款',
  156. url: '/pages/goods/user_return_list/index',
  157. num: 0
  158. },
  159. ],
  160. featuresList: [{
  161. id: 1,
  162. icon: '/static/img/ic-express.png',
  163. text: '我的快递',
  164. url: ''
  165. },
  166. {
  167. id: 2,
  168. icon: '/static/img/ic-address.png',
  169. text: '通用地址',
  170. url: '/pages/address/user_address_list/index'
  171. },
  172. {
  173. id: 3,
  174. icon: '/static/img/ic-comments.png',
  175. text: '我的评论',
  176. url: ''
  177. },
  178. {
  179. id: 4,
  180. icon: '/static/img/ic-collection.png',
  181. text: '我的收藏',
  182. url: '/pages/goods/user_goods_collection/index'
  183. },
  184. {
  185. id: 5,
  186. icon: '/static/img/ic-buy.png',
  187. text: '我的团购',
  188. url: ''
  189. },
  190. {
  191. id: 6,
  192. icon: '/static/img/ic-vouchers.png',
  193. text: '我的卡券',
  194. url: '/pages/users/user_coupon/index'
  195. },
  196. {
  197. id: 7,
  198. icon: '/static/img/ic-distribution.png',
  199. text: '我的分销',
  200. url: '/pages/users/user_spread_user/index'
  201. },
  202. {
  203. id: 8,
  204. icon: '/static/img/ic-friend.png',
  205. text: '邀请好友',
  206. url: ''
  207. },
  208. {
  209. id: 9,
  210. icon: '/static/img/ic-feedback.png',
  211. text: '帮助反馈',
  212. url: ''
  213. },
  214. {
  215. id: 10,
  216. icon: '/static/img/ic-security-settings.png',
  217. text: '安全设置',
  218. url: '/pages/users/user_setting/index'
  219. }
  220. ],
  221. }
  222. },
  223. onLoad(options) {
  224. let that = this;
  225. //首页数据加载
  226. // this.getIndexConfig();
  227. // #ifdef MP-WEIXIN
  228. // 获取微信胶囊的位置信息 width,height,top,right,left,bottom
  229. const custom = wx.getMenuButtonBoundingClientRect()
  230. // 导航栏高度(标题栏高度) = 胶囊高度 + (顶部距离 - 状态栏高度) * 2
  231. this.navigationBarHeight = custom.height + (custom.top - this.statusBarHeight) * 2
  232. // console.log("导航栏高度:"+this.globalData.navigationBarHeight)
  233. // #endif
  234. },
  235. onShow: function() {
  236. if (this.isLogin) {
  237. this.getUserCenterInfo();
  238. this.getOrderData();
  239. }
  240. },
  241. methods: {
  242. getOrderData() {
  243. let that = this;
  244. orderNum().then(res => {
  245. that.orderMenu.forEach((item, index) => {
  246. switch (item.title) {
  247. case '待付款':
  248. item.num = res.data.awaitPayCount
  249. break
  250. case '待发货':
  251. item.num = res.data.awaitShippedCount
  252. break
  253. case '待收货':
  254. item.num = res.data.receiptCount
  255. break
  256. case '待核销':
  257. item.num = res.data.verificationCount
  258. break
  259. case '待评价':
  260. item.num = res.data.awaitReplyCount
  261. break
  262. default:
  263. item.num = res.data.refundCount
  264. }
  265. })
  266. that.$set(that, 'orderMenu', that.orderMenu);
  267. })
  268. },
  269. /**
  270. *
  271. * 获取个人中心详情
  272. */
  273. getUserCenterInfo: function() {
  274. userCenterInfo().then(res => {
  275. let data = res.data;
  276. this.userInfo = data;
  277. console.log(this, UserInfo)
  278. // this.showSkeleton = false;
  279. }).catch(err => {
  280. // this.showSkeleton = false;
  281. });
  282. },
  283. menusTap(url) {
  284. if (!this.isLogin) {
  285. this.openAuto();
  286. } else {
  287. if (url === '') return
  288. this.$util.navigateTo(url);
  289. }
  290. },
  291. // 打开授权
  292. openAuto() {
  293. Cache.set(BACK_URL, '')
  294. toLogin();
  295. },
  296. // 跳转骑手
  297. menusRider(url, falg) {
  298. if (!this.isLogin) {
  299. this.openAuto();
  300. } else {
  301. if (url === '') return
  302. falg ? uni.reLaunch({
  303. url: url
  304. }) : this.$util.navigateTo(url)
  305. }
  306. },
  307. // 编辑页面
  308. goEdit() {
  309. if (this.isLogin == false) {
  310. this.openAuto();
  311. } else {
  312. uni.navigateTo({
  313. animationType: animationType.type,
  314. animationDuration: animationType.duration,
  315. url: '/pages/users/user_info/index'
  316. })
  317. }
  318. },
  319. },
  320. }
  321. </script>
  322. <style lang="scss" scoped>
  323. .order-nav {
  324. font-weight: 500;
  325. font-size: 35rpx;
  326. color: #FFFFFF;
  327. background-color: #FF6702;
  328. text-align: center;
  329. }
  330. .item-settled {
  331. background: linear-gradient(135deg, #FED0A7 0%, #FFF3E2 52%, #FAEDD3 100%);
  332. border-radius: 8rpx;
  333. padding: 20rpx;
  334. box-shadow: 0 0 0 2rpx rgba(255, 220, 135, 1);
  335. position: relative;
  336. // top: -90rpx;
  337. margin: 0 20rpx;
  338. display: flex;
  339. align-items: center;
  340. }
  341. .item-settled::after {
  342. content: "";
  343. position: absolute;
  344. top: -2rpx;
  345. left: -2rpx;
  346. right: -2rpx;
  347. bottom: -2rpx;
  348. background: linear-gradient(200deg, rgba(255, 220, 135, 1), rgba(255, 172, 33, 1), rgba(255, 201, 24, 1));
  349. border-radius: 10rpx;
  350. z-index: -1;
  351. pointer-events: none;
  352. }
  353. .card {
  354. position: relative;
  355. display: flex;
  356. /* 启用flex布局 */
  357. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  358. padding: 40rpx 30rpx 120rpx 30rpx;
  359. box-sizing: border-box;
  360. background: linear-gradient(225deg, #ECF3FE 0%, #FEFEFE 100%);
  361. border-radius: 23rpx;
  362. top: -20rpx;
  363. }
  364. .card-left {
  365. position: relative;
  366. }
  367. .card-right {
  368. flex: 1;
  369. }
  370. .avatar {
  371. position: absolute;
  372. top: -80rpx;
  373. left: 0;
  374. width: 131rpx;
  375. height: 131rpx;
  376. background-color: #D8D8D8;
  377. border: 4rpx solid #FFFFFF;
  378. border-radius: 50%;
  379. object-fit: cover;
  380. }
  381. .username {
  382. margin-top: 70rpx;
  383. color: #141414;
  384. font-size: 35rpx;
  385. font-weight: bold;
  386. }
  387. .code {
  388. width: 31rpx;
  389. height: 31rpx;
  390. margin-left: 20rpx;
  391. }
  392. .card-content {
  393. display: flex;
  394. justify-content: space-between;
  395. }
  396. .content-item {
  397. display: flex;
  398. flex-direction: column;
  399. align-items: center;
  400. width: 33%;
  401. }
  402. .content-icon {
  403. width: 70rpx;
  404. height: 70rpx;
  405. margin-bottom: 15rpx;
  406. }
  407. .content-text1 {
  408. font-size: 23rpx;
  409. background: linear-gradient(90deg, #FFB908 0%, #DC7A11 100%);
  410. -webkit-background-clip: text;
  411. background-clip: text;
  412. color: transparent;
  413. }
  414. .content-text2 {
  415. font-size: 23rpx;
  416. background: linear-gradient(90deg, #93B0FF 0%, #1B4EFF 100%);
  417. -webkit-background-clip: text;
  418. background-clip: text;
  419. color: transparent;
  420. }
  421. .content-text3 {
  422. font-size: 23rpx;
  423. background: linear-gradient(90deg, #F4D600 0%, #FF9100 100%);
  424. -webkit-background-clip: text;
  425. background-clip: text;
  426. color: transparent;
  427. }
  428. .phone-info {
  429. font-size: 21rpx;
  430. padding-top: 10rpx;
  431. }
  432. .phone-info text {
  433. margin-right: 14rpx;
  434. }
  435. .phone-info image {
  436. width: 27rpx;
  437. height: 27rpx;
  438. vertical-align: middle;
  439. }
  440. .profile-link {
  441. margin-top: 20rpx;
  442. font-size: 23rpx;
  443. font-weight: 600;
  444. line-height: 21rpx;
  445. text-align: right;
  446. }
  447. .profile-link img {
  448. width: 24rpx;
  449. height: 24rpx;
  450. vertical-align: middle;
  451. margin-left: 12rpx;
  452. }
  453. .grid-container {
  454. display: flex;
  455. flex-wrap: wrap;
  456. gap: 0;
  457. /* 改用 margin 控制间距 */
  458. padding: 20rpx;
  459. /* 父容器内边距 */
  460. box-sizing: border-box;
  461. /* 包含 padding 在宽度内 */
  462. }
  463. .grid-item {
  464. width: 25%;
  465. /* 直接 25% 无需 calc */
  466. display: flex;
  467. flex-direction: column;
  468. align-items: center;
  469. margin-bottom: 30rpx;
  470. /* 行间距 */
  471. padding: 0 10rpx;
  472. /* 左右间隙(替代 gap) */
  473. box-sizing: border-box;
  474. /* 关键 */
  475. }
  476. .grid-img {
  477. width: 58rpx;
  478. height: 58rpx;
  479. margin-bottom: 8rpx;
  480. }
  481. .grid-text {
  482. font-size: 24rpx;
  483. color: #333;
  484. }
  485. .item-features {
  486. background: #FFFFFF;
  487. border-radius: 23rpx;
  488. margin: 0rpx 20rpx;
  489. }
  490. .item-features-title {
  491. padding: 20rpx;
  492. font-weight: 600;
  493. font-size: 27rpx;
  494. color: #2E261E;
  495. line-height: 38rpx;
  496. }
  497. .go-img {
  498. background: linear-gradient(135deg, #FED0A7 0%, #FFF3E2 52%, #FAEDD3 100%);
  499. border-radius: 8rpx;
  500. padding: 20rpx;
  501. box-shadow: 0 0 0 2rpx rgba(255, 220, 135, 1);
  502. display: flex;
  503. align-items: center;
  504. justify-content: center;
  505. margin-top: 20rpx;
  506. }
  507. .order-box {
  508. background-color: #fff;
  509. border-radius: 14rpx;
  510. padding: 30rpx 16rpx;
  511. position: relative;
  512. z-index: 11;
  513. margin: 20rpx;
  514. .order-hd {
  515. justify-content: space-between;
  516. font-size: 30rpx;
  517. color: #282828;
  518. margin-bottom: 40rpx;
  519. padding: 0 16rpx;
  520. .left {
  521. color: #282828;
  522. font-size: 30rpx;
  523. font-weight: 600;
  524. }
  525. .right {
  526. align-items: center;
  527. color: #666666;
  528. font-size: 26rpx;
  529. .icon-xiangyou {
  530. margin-left: 5rpx;
  531. font-size: 24rpx;
  532. }
  533. }
  534. }
  535. .order-bd {
  536. display: flex;
  537. justify-content: space-between;
  538. padding: 0;
  539. .order-item {
  540. display: flex;
  541. flex-direction: column;
  542. justify-content: center;
  543. align-items: center;
  544. .pic {
  545. position: relative;
  546. text-align: center;
  547. image {
  548. width: 48rpx;
  549. height: 48rpx;
  550. }
  551. .order-status-num {
  552. min-width: 13rpx;
  553. background-color: #fff;
  554. color: $bg-color-primary;
  555. border-radius: 15px;
  556. position: absolute;
  557. right: -14rpx;
  558. top: -15rpx;
  559. font-size: 20rpx;
  560. padding: 0 8rpx;
  561. border: 2rpx solid $bg-color-primary;
  562. }
  563. }
  564. .txt {
  565. margin-top: 15rpx;
  566. font-size: 26rpx;
  567. color: #454545;
  568. }
  569. .pic_status {
  570. color: $bg-color-primary;
  571. }
  572. }
  573. }
  574. }
  575. </style>