index.vue 18 KB

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