index.vue 15 KB

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