index.vue 15 KB

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