index.vue 22 KB

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