index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. <template>
  2. <view class="mine-page">
  3. <!-- <u-navbar title="我的" bgColor="transparent" titleBold></u-navbar> -->
  4. <!-- 顶部用户信息 -->
  5. <view class="user-info">
  6. <view class="user-header" @tap="handleUpdateUserInfo">
  7. <view class="user-avatar">
  8. <image class="avatar" :src="userInfo.imgPath" mode="aspectFill" v-if="userInfo.imgPath"
  9. style="width: 100%; height: 100%; display: block"></image>
  10. <image class="avatar" src="https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/logo3.png"
  11. mode="heightFix" v-else style="width: 100%; height: 116rpx; display: block; border-radius: 10%">
  12. </image>
  13. </view>
  14. <view class="user-detail">
  15. <view class="nickname">{{ userInfo.nickName }}</view>
  16. <view class="user-tag" v-for="(tag, index) in userInfo.tags" :key="index">{{ tag }}</view>
  17. </view>
  18. </view>
  19. <!-- 用户数据 -->
  20. <view class="user-data">
  21. <view class="data-item" @click="navigateToTool('/pages-mine/pages/wallet')">
  22. <view class="amount">{{ userInfo.accountMoney || 0 }}</view>
  23. <view class="label">我的钱包</view>
  24. </view>
  25. <view class="data-item">
  26. <view class="amount">{{ userInfo.couponNum || 0 }}</view>
  27. <view class="label">优惠券</view>
  28. <view class="badge" v-if="userInfo.couponNum">{{ userInfo.couponNum }}张可领</view>
  29. </view>
  30. <view class="data-item">
  31. <view class="amount">{{ userInfo.point || 0 }}</view>
  32. <view class="label">我的积分</view>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 卖书订单 -->
  37. <view class="order-section">
  38. <view class="section-header">
  39. <text>卖书订单</text>
  40. <view class="view-all" @click="viewAllOrders">
  41. <text>查看全部</text>
  42. <u-icon name="arrow-right" size="24" color="#999"></u-icon>
  43. </view>
  44. </view>
  45. <view class="order-types" style="padding: 0 20rpx">
  46. <view class="type-item flex-d flex-a-c" v-for="(item, index) in orderTypes" :key="index"
  47. @click="navigateToOrder(item.path)">
  48. <image class="type-icon" :src="item.icon" mode="aspectFit"></image>
  49. <text>{{ item.name }}</text>
  50. <view class="badge" v-if="item.badge">{{ item.badge }}</view>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 我的订单 -->
  55. <view class="order-section" style="margin-top: 30rpx;">
  56. <view class="section-header">
  57. <text>我的订单</text>
  58. <view class="view-all" @click="viewAllOrders">
  59. <text>查看全部</text>
  60. <u-icon name="arrow-right" size="24" color="#999"></u-icon>
  61. </view>
  62. </view>
  63. <view class="order-types" style="padding: 0 20rpx">
  64. <view class="type-item flex-d flex-a-c" v-for="(item, index) in myOrderTypes" :key="index"
  65. @click="navigateToOrder(item.path)">
  66. <image class="type-icon" :src="item.icon" mode="aspectFit"></image>
  67. <text>{{ item.name }}</text>
  68. <view class="badge" v-if="item.badge">{{ item.badge }}</view>
  69. </view>
  70. </view>
  71. </view>
  72. <!-- 实用工具 -->
  73. <view class="tools-section">
  74. <view class="section-title">实用工具</view>
  75. <view class="tools-grid">
  76. <view class="tool-item flex-d flex-a-c" v-for="(tool, index) in tools" :key="index"
  77. @click="navigateToTool(tool.path)">
  78. <!-- #ifdef MP-ALIPAY -->
  79. <button class="link-service flex-d flex-a-c" v-if="tool.path == 'link-service'"
  80. @click="navigateToCustomerService">
  81. <image class="tool-icon" :src="tool.icon" mode="aspectFit"></image>
  82. <text>联系客服</text>
  83. </button>
  84. <!-- #endif -->
  85. <!-- #ifndef MP-ALIPAY -->
  86. <button class="link-service flex-d flex-a-c" open-type="contact" v-if="tool.path == 'link-service'">
  87. <image class="tool-icon" :src="tool.icon" mode="aspectFit"></image>
  88. <text>联系客服</text>
  89. </button>
  90. <!-- #endif -->
  91. <block v-else>
  92. <image class="tool-icon" :src="tool.icon" mode="aspectFit"></image>
  93. <text>{{ tool.name }}</text>
  94. </block>
  95. </view>
  96. </view>
  97. </view>
  98. <!-- 悬浮提现确认按钮 -->
  99. <withdrawal-confirm :visible="withdrawalOrder && withdrawalOrder.length > 0" :initialPosition="buttonPosition"
  100. @click="navigateToWithdrawal" @position-change="onPositionChange" />
  101. <!-- 活动悬浮按钮 -->
  102. <floating-activity :img="activityInfo.img" :visible="activityInfo.frequency && activityInfo.frequency == 3"
  103. :initialPosition="activityPosition" @click="contactCustomerService"
  104. @position-change="onActivityButtonPositionChange" />
  105. <!-- 提现进度弹窗 -->
  106. <withdrawal-progress :orderInfo="currentWithdrawalOrder" @confirm="confirmWithdrawal" ref="withdrawalRef" />
  107. </view>
  108. </template>
  109. <script>
  110. import WithdrawalProgress from './components/withdrawal-progress.vue';
  111. import WithdrawalConfirm from '../../components/withdrawal-confirm.vue';
  112. import floatingActivity from '../../components/floating-activity.vue';
  113. export default {
  114. components: {
  115. WithdrawalProgress,
  116. WithdrawalConfirm,
  117. floatingActivity
  118. },
  119. data() {
  120. return {
  121. userInfo: {
  122. userId: 0,
  123. openid: '',
  124. imgPath: '',
  125. nickName: '这里是昵称.',
  126. mobile: '',
  127. tags: [],
  128. accountMoney: 0,
  129. couponNum: 0,
  130. point: 0,
  131. firstAuditNum: 0,
  132. pickUpNum: 0,
  133. auditNum: 0,
  134. payNum: 0,
  135. refundNum: 0
  136. },
  137. orderTypes: [
  138. {
  139. name: '待初审',
  140. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/1.png',
  141. badge: 0,
  142. key: 'firstAuditNum',
  143. path: '/pages-mine/pages/order-page?status=2'
  144. },
  145. {
  146. name: '待取件',
  147. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/2.png',
  148. badge: 0,
  149. key: 'pickUpNum',
  150. path: '/pages-mine/pages/order-page?status=3'
  151. },
  152. {
  153. name: '待审核',
  154. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/3.png',
  155. badge: 0,
  156. key: 'auditNum',
  157. path: '/pages-mine/pages/order-page?status=8'
  158. },
  159. {
  160. name: '待到款',
  161. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/4.png',
  162. badge: 0,
  163. key: 'payNum',
  164. path: '/pages-mine/pages/order-page?status=10'
  165. },
  166. {
  167. name: '申请退回',
  168. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/5.png',
  169. badge: 0,
  170. key: 'refundNum',
  171. path: '/pages-mine/pages/apply-return'
  172. }
  173. ],
  174. myOrderTypes: [
  175. {
  176. name: '待付款',
  177. icon: '/pages-car/static/my-order/icon-1.png',
  178. badge: 0,
  179. key: 'payNum',
  180. path: '/pages-car/pages/my-order?status=1'
  181. },
  182. {
  183. name: '待发货',
  184. icon: '/pages-car/static/my-order/icon-2.png',
  185. badge: 0,
  186. key: 'sendNum',
  187. path: '/pages-car/pages/my-order?status=2'
  188. },
  189. {
  190. name: '待收货',
  191. icon: '/pages-car/static/my-order/icon-3.png',
  192. badge: 0,
  193. key: 'receiveNum',
  194. path: '/pages-car/pages/my-order?status=3'
  195. },
  196. {
  197. name: '退款中',
  198. icon: '/pages-car/static/my-order/icon-4.png',
  199. badge: 0,
  200. key: 'refundNum',
  201. path: '/pages-car/pages/my-order?status=6'
  202. },
  203. {
  204. name: '已完成',
  205. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/5.png',
  206. badge: 0,
  207. key: 'completeNum',
  208. path: '/pages-car/pages/my-order?status=4'
  209. }
  210. ],
  211. tools: [
  212. {
  213. name: '消息通知',
  214. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t1.png',
  215. path: '/pages-mine/pages/notice'
  216. },
  217. {
  218. name: '我的收藏',
  219. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t2.png',
  220. path: '/pages-car/pages/my-fav'
  221. },
  222. {
  223. name: '我的足迹',
  224. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t3.png',
  225. path: '/pages-car/pages/my-footprint'
  226. },
  227. {
  228. name: '我的地址',
  229. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t4.png',
  230. path: '/pages-mine/pages/address/list'
  231. },
  232. {
  233. name: '我的红包',
  234. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t5.png',
  235. path: '/pages-car/pages/red-packet'
  236. },
  237. {
  238. name: '联系客服',
  239. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t6.png',
  240. path: 'link-service'
  241. },
  242. {
  243. name: '意见反馈',
  244. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t7.png',
  245. path: '/pages-mine/pages/feedback'
  246. },
  247. {
  248. name: '到货提醒',
  249. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t8.png',
  250. path: '/pages-car/pages/arrival-reminder'
  251. },
  252. {
  253. name: '合伙人计划',
  254. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t9.png',
  255. path: '/pages-mine/pages/partner/partner-rule'
  256. },
  257. {
  258. name: '买卖答疑',
  259. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t10.png',
  260. path: '/pages-mine/pages/rules-for-sellbooks'
  261. },
  262. {
  263. name: '关于书嗨',
  264. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t11.png',
  265. path: '/pages-home/pages/about-us'
  266. },
  267. {
  268. name: '我的余额',
  269. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t12.png',
  270. path: '/pages-mine/pages/wallet'
  271. },
  272. {
  273. name: '用户设置',
  274. icon: 'https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t13.png',
  275. path: '/pages-mine/pages/setting'
  276. }
  277. ],
  278. // 悬浮按钮位置
  279. buttonPosition: {
  280. left: 'auto',
  281. right: 0,
  282. bottom: '10%'
  283. },
  284. // 客服按钮位置
  285. activityPosition: {
  286. left: 'auto',
  287. right: 0,
  288. bottom: '25%'
  289. },
  290. withdrawalOrder: [],
  291. // 提现进度弹窗相关
  292. showWithdrawalModal: false,
  293. currentWithdrawalOrder: {},
  294. //活动弹窗信息
  295. activityInfo: {}
  296. };
  297. },
  298. methods: {
  299. //获取是否显示活动弹窗
  300. getActivityStatus() {
  301. uni.$u.http.post('/token/home/activity/dialog').then((res) => {
  302. if (res.code == 200) {
  303. this.activityInfo = res.data;
  304. }
  305. });
  306. },
  307. //获取是否存在待确认提现的订单
  308. getWithdrawalOrder() {
  309. uni.$u.http.get('/token/user/withdrawWindows').then((res) => {
  310. console.log(res);
  311. if (res.code == 200) {
  312. this.withdrawalOrder = res.data;
  313. }
  314. });
  315. },
  316. //用户信息
  317. handleUpdateUserInfo() {
  318. uni.navigateTo({
  319. url: '/pages-mine/pages/setting'
  320. });
  321. },
  322. //查看全部订单
  323. viewAllOrders() {
  324. uni.navigateTo({
  325. url: '/pages-mine/pages/order-page?status=-1'
  326. });
  327. },
  328. //跳转订单
  329. navigateToOrder(path) {
  330. uni.navigateTo({
  331. url: path
  332. });
  333. },
  334. //跳转工具
  335. navigateToTool(path) {
  336. if (path === 'link-service') return
  337. if (!path)
  338. return uni.showToast({
  339. title: '开发中...',
  340. icon: 'none'
  341. });
  342. if (path == '/pages-mine/pages/partner/partner-rule') {
  343. this.getPartnerStatus();
  344. } else {
  345. uni.navigateTo({
  346. url: path
  347. });
  348. }
  349. },
  350. // 导航到提现确认页面
  351. navigateToWithdrawal() {
  352. if (this.withdrawalOrder && this.withdrawalOrder.length > 0) {
  353. // 显示提现进度弹窗,使用第一个提现订单
  354. this.currentWithdrawalOrder = this.withdrawalOrder[0];
  355. this.$refs.withdrawalRef.openModal();
  356. } else {
  357. // 如果没有待确认的提现订单,直接跳转到钱包页面
  358. uni.navigateTo({
  359. url: '/pages-mine/pages/wallet'
  360. });
  361. }
  362. },
  363. //获取用户信息
  364. getUserInfo() {
  365. uni.$u.http.get('/token/user/detail').then((res) => {
  366. console.log(res);
  367. if (res.code == 200) {
  368. this.userInfo = res.data;
  369. uni.setStorageSync('userInfo', this.userInfo);
  370. this.orderTypes.forEach((item) => {
  371. item.badge = this.userInfo[item.key];
  372. });
  373. }
  374. });
  375. },
  376. //获取合伙人状态
  377. getPartnerStatus() {
  378. let item = this.tools.find((item) => item.name == '合伙人计划');
  379. uni.$u.get('/token/getUserPartnerInfo').then((res) => {
  380. if (res.code == 200) {
  381. let { status } = res.data;
  382. if (status == -1 || status == 4) {
  383. item.path = '/pages-mine/pages/partner/partner-rule';
  384. } else if (status == 1) {
  385. item.path = '/pages-mine/pages/partner/partner-home';
  386. } else {
  387. item.path = '/pages-mine/pages/partner/partner-status';
  388. }
  389. } else {
  390. item.path = '/pages-mine/pages/partner/partner-status';
  391. }
  392. uni.navigateTo({
  393. url: item.path
  394. });
  395. });
  396. },
  397. // 更新悬浮按钮位置
  398. onPositionChange(position) {
  399. this.buttonPosition = position;
  400. },
  401. // 更新活动按钮位置
  402. onActivityButtonPositionChange(position) {
  403. this.activityPosition = position;
  404. },
  405. // 联系客服
  406. contactCustomerService() {
  407. uni.navigateTo({
  408. url: this.activityInfo.jumpPage
  409. });
  410. },
  411. // 关闭提现进度弹窗
  412. closeWithdrawalModal() {
  413. this.$refs.withdrawalRef.handleClose();
  414. },
  415. confirmWithdrawal(item) {
  416. uni.$u.http
  417. .post('/token/user/withdrawConfirm', {
  418. orderNo: item.orderNo
  419. })
  420. .then((res) => {
  421. if (res.code === 200) {
  422. this.handleConfirmReceipt(res.data);
  423. }
  424. })
  425. .catch((err) => {
  426. uni.showToast({
  427. title: err.message || '确认失败',
  428. icon: 'none'
  429. });
  430. });
  431. },
  432. //执行微信确认收款操作
  433. handleConfirmReceipt(data) {
  434. if (wx.canIUse('requestMerchantTransfer')) {
  435. wx.requestMerchantTransfer({
  436. mchId: data.mchId,
  437. appId: data.appId,
  438. package: data.packageStr,
  439. success: (res) => {
  440. // res.err_msg将在页面展示成功后返回应用时返回ok,并不代表付款成功
  441. uni.showToast({
  442. title: '确认收款成功',
  443. icon: 'none'
  444. });
  445. this.closeWithdrawalModal();
  446. // 刷新列表
  447. this.getWithdrawalOrder();
  448. },
  449. fail: (res) => {
  450. console.log('fail:', res);
  451. }
  452. });
  453. } else {
  454. wx.showModal({
  455. content: '你的微信版本过低,请更新至最新版本。',
  456. showCancel: false
  457. });
  458. }
  459. },
  460. navigateToCustomerService() {
  461. uni.navigateTo({
  462. url: '/pages-mine/pages/customer-service'
  463. });
  464. }
  465. },
  466. onReady() {
  467. // 获取屏幕宽度和高度
  468. uni.getSystemInfo({
  469. success: (res) => {
  470. this.screenWidth = res.windowWidth;
  471. this.screenHeight = res.windowHeight;
  472. }
  473. });
  474. this.getActivityStatus();
  475. },
  476. onShow() {
  477. let token = uni.getStorageSync('token');
  478. if (token) {
  479. this.getUserInfo();
  480. this.getWithdrawalOrder();
  481. }
  482. }
  483. };
  484. </script>
  485. <style lang="scss" scoped>
  486. .mine-page {
  487. min-height: 100vh;
  488. background-color: #f5f5f5;
  489. position: relative;
  490. .link-service {
  491. background: transparent;
  492. border: none;
  493. padding: 0;
  494. margin: 0;
  495. width: 100%;
  496. height: 100%;
  497. line-height: 36rpx;
  498. }
  499. .user-info {
  500. background: url('/static/img/bg.png') no-repeat center center;
  501. background-size: 100% 100%;
  502. position: absolute;
  503. top: 0;
  504. left: 0;
  505. padding: 20rpx 50rpx 120rpx;
  506. color: #fff;
  507. position: relative;
  508. padding-top: 160rpx;
  509. &::after {
  510. width: 140%;
  511. position: absolute;
  512. left: -20%;
  513. top: 0;
  514. z-index: -1;
  515. content: '';
  516. border-radius: 0 0 50% 50%;
  517. background: #fd6954;
  518. }
  519. .user-header {
  520. display: flex;
  521. align-items: center;
  522. margin-bottom: 40rpx;
  523. .user-avatar {
  524. border-radius: 50%;
  525. margin-right: 20rpx;
  526. border: 4rpx solid #fff;
  527. width: 128rpx;
  528. height: 128rpx;
  529. overflow: hidden;
  530. flex-shrink: 0;
  531. background: #fff;
  532. .avatar {
  533. width: 100%;
  534. height: 100%;
  535. border-radius: 50%;
  536. object-fit: cover;
  537. }
  538. }
  539. .user-detail {
  540. .nickname {
  541. font-size: 32rpx;
  542. font-weight: 500;
  543. margin-bottom: 8rpx;
  544. }
  545. .user-tag {
  546. display: inline-block;
  547. font-size: 22rpx;
  548. padding: 4rpx 12rpx;
  549. background: linear-gradient(-90deg, #272321, #4b4542);
  550. border-radius: 4rpx;
  551. margin-top: 8rpx;
  552. margin-right: 10rpx;
  553. }
  554. }
  555. }
  556. .user-data {
  557. display: flex;
  558. justify-content: space-between;
  559. position: relative;
  560. z-index: 1;
  561. padding: 0 40rpx;
  562. .data-item {
  563. position: relative;
  564. text-align: center;
  565. .amount {
  566. font-size: 38rpx;
  567. font-weight: 500;
  568. margin-bottom: 8rpx;
  569. }
  570. .label {
  571. font-size: 24rpx;
  572. font-weight: 400;
  573. opacity: 0.9;
  574. }
  575. .badge {
  576. position: absolute;
  577. top: -15rpx;
  578. right: -120%;
  579. padding: 0 10rpx;
  580. font-size: 20rpx;
  581. line-height: 30rpx;
  582. height: 30rpx;
  583. background: #ff8400;
  584. border-radius: 15rpx 15rpx 15rpx 0rpx;
  585. }
  586. }
  587. }
  588. }
  589. .order-section {
  590. margin: -90rpx 30rpx 20rpx;
  591. background: #fff;
  592. border-radius: 12rpx;
  593. padding: 30rpx;
  594. position: relative;
  595. z-index: 2;
  596. .section-header {
  597. display: flex;
  598. justify-content: space-between;
  599. align-items: center;
  600. margin-bottom: 30rpx;
  601. .view-all {
  602. display: flex;
  603. align-items: center;
  604. color: #999;
  605. font-size: 26rpx;
  606. }
  607. }
  608. .order-types {
  609. display: flex;
  610. justify-content: space-between;
  611. .type-item {
  612. text-align: center;
  613. position: relative;
  614. .badge {
  615. position: absolute;
  616. top: -15rpx;
  617. right: -6px;
  618. padding: 0 10rpx;
  619. font-size: 20rpx;
  620. line-height: 30rpx;
  621. height: 30rpx;
  622. background: #f56c6c;
  623. color: #fff;
  624. border-radius: 15rpx 15rpx 15rpx 0rpx;
  625. }
  626. .type-icon {
  627. width: 60rpx;
  628. height: 60rpx;
  629. margin-bottom: 12rpx;
  630. }
  631. text {
  632. font-size: 26rpx;
  633. color: #333;
  634. }
  635. }
  636. }
  637. }
  638. .tools-section {
  639. margin: 30rpx;
  640. background: #fff;
  641. border-radius: 12rpx;
  642. padding: 30rpx;
  643. position: relative;
  644. z-index: 2;
  645. .section-title {
  646. font-size: 30rpx;
  647. font-weight: 500;
  648. margin-bottom: 30rpx;
  649. }
  650. .tools-grid {
  651. display: grid;
  652. grid-template-columns: repeat(4, 1fr);
  653. gap: 30rpx;
  654. .tool-item {
  655. text-align: center;
  656. .tool-icon {
  657. width: 60rpx;
  658. height: 60rpx;
  659. margin-bottom: 12rpx;
  660. }
  661. text {
  662. font-size: 24rpx;
  663. color: #333;
  664. }
  665. }
  666. }
  667. }
  668. }
  669. </style>