index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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. :initialPosition="buttonPosition"
  91. @click="navigateToWithdrawal"
  92. @position-change="onPositionChange"
  93. />
  94. <!-- 活动悬浮按钮 -->
  95. <floating-button
  96. :visible="true"
  97. :initialPosition="activityPosition"
  98. @click="contactCustomerService"
  99. @position-change="onActivityButtonPositionChange"
  100. />
  101. <!-- 提现进度弹窗 -->
  102. <withdrawal-progress
  103. :orderInfo="currentWithdrawalOrder"
  104. @confirm="confirmWithdrawal"
  105. ref="withdrawalRef"
  106. />
  107. </view>
  108. </template>
  109. <script>
  110. import WithdrawalProgress from "./components/withdrawal-progress.vue";
  111. import WithdrawalConfirm from "../../components/withdrawal-confirm.vue";
  112. import FloatingButton from "../../components/floating-activity.vue";
  113. export default {
  114. components: {
  115. WithdrawalProgress,
  116. WithdrawalConfirm,
  117. FloatingButton
  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. tools: [
  175. {
  176. name: "消息通知",
  177. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t1.png",
  178. path: "/pages-mine/pages/notice",
  179. },
  180. { name: "我的收藏", icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t2.png", path: "" },
  181. { name: "我的足迹", icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t3.png", path: "" },
  182. {
  183. name: "我的地址",
  184. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t4.png",
  185. path: "/pages-mine/pages/address/list",
  186. },
  187. { name: "我的优惠券", icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t5.png", path: "" },
  188. {
  189. name: "联系客服",
  190. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t6.png",
  191. path: "link-service",
  192. },
  193. {
  194. name: "意见反馈",
  195. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t7.png",
  196. path: "/pages-mine/pages/feedback",
  197. },
  198. {
  199. name: "到货提醒",
  200. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t8.png",
  201. path: "/pages/tools/arrival-notice",
  202. },
  203. {
  204. name: "合伙人计划",
  205. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t9.png",
  206. path: "/pages-mine/pages/partner/partner-rule",
  207. },
  208. {
  209. name: "买卖答疑",
  210. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t10.png",
  211. path: "/pages-mine/pages/rules-for-sellbooks",
  212. },
  213. {
  214. name: "关于书嗨",
  215. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t11.png",
  216. path: "/pages-home/pages/about-us",
  217. },
  218. {
  219. name: "我的余额",
  220. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t12.png",
  221. path: "/pages-mine/pages/wallet",
  222. },
  223. {
  224. name: "用户设置",
  225. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t13.png",
  226. path: "/pages-mine/pages/setting",
  227. },
  228. ],
  229. // 悬浮按钮位置
  230. buttonPosition: {
  231. left: "auto",
  232. right: 0,
  233. bottom: "20%",
  234. },
  235. // 客服按钮位置
  236. activityPosition: {
  237. left: "auto",
  238. right: 0,
  239. bottom: "40%",
  240. },
  241. withdrawalOrder: [],
  242. // 提现进度弹窗相关
  243. showWithdrawalModal: false,
  244. currentWithdrawalOrder: {},
  245. };
  246. },
  247. methods: {
  248. //获取是否存在待确认提现的订单
  249. getWithdrawalOrder() {
  250. uni.$u.http.get("/token/user/withdrawWindows").then((res) => {
  251. console.log(res);
  252. if (res.code == 200) {
  253. this.withdrawalOrder = res.data;
  254. }
  255. });
  256. },
  257. //用户信息
  258. handleUpdateUserInfo() {
  259. uni.navigateTo({
  260. url: "/pages-mine/pages/setting",
  261. });
  262. },
  263. //查看全部订单
  264. viewAllOrders() {
  265. uni.navigateTo({
  266. url: "/pages-mine/pages/order-page?status=-1",
  267. });
  268. },
  269. //跳转订单
  270. navigateToOrder(path) {
  271. uni.navigateTo({
  272. url: path,
  273. });
  274. },
  275. //跳转工具
  276. navigateToTool(path) {
  277. if (!path)
  278. return uni.showToast({
  279. title: "开发中...",
  280. icon: "none",
  281. });
  282. if (path == "/pages-mine/pages/partner/partner-rule") {
  283. this.getPartnerStatus();
  284. } else {
  285. uni.navigateTo({
  286. url: path,
  287. });
  288. }
  289. },
  290. // 导航到提现确认页面
  291. navigateToWithdrawal() {
  292. console.log('11111')
  293. if (this.withdrawalOrder && this.withdrawalOrder.length > 0) {
  294. // 显示提现进度弹窗,使用第一个提现订单
  295. this.currentWithdrawalOrder = this.withdrawalOrder[0];
  296. this.$refs.withdrawalRef.openModal();
  297. } else {
  298. // 如果没有待确认的提现订单,直接跳转到钱包页面
  299. uni.navigateTo({
  300. url: "/pages-mine/pages/wallet",
  301. });
  302. }
  303. },
  304. //获取用户信息
  305. getUserInfo() {
  306. uni.$u.http.get("/token/user/detail").then((res) => {
  307. console.log(res);
  308. if (res.code == 200) {
  309. this.userInfo = res.data;
  310. uni.setStorageSync("userInfo", this.userInfo);
  311. this.orderTypes.forEach((item) => {
  312. item.badge = this.userInfo[item.key];
  313. });
  314. }
  315. });
  316. },
  317. //获取合伙人状态
  318. getPartnerStatus() {
  319. let item = this.tools.find((item) => item.name == "合伙人计划");
  320. uni.$u.get("/token/getUserPartnerInfo").then((res) => {
  321. if (res.code == 200) {
  322. let { status } = res.data;
  323. if (status == -1 || status == 4) {
  324. item.path = "/pages-mine/pages/partner/partner-rule";
  325. } else if (status == 1) {
  326. item.path = "/pages-mine/pages/partner/partner-home";
  327. } else {
  328. item.path = "/pages-mine/pages/partner/partner-status";
  329. }
  330. } else {
  331. item.path = "/pages-mine/pages/partner/partner-status";
  332. }
  333. uni.navigateTo({
  334. url: item.path,
  335. });
  336. });
  337. },
  338. // 更新悬浮按钮位置
  339. onPositionChange(position) {
  340. this.buttonPosition = position;
  341. },
  342. // 更新活动按钮位置
  343. onActivityButtonPositionChange(position) {
  344. this.activityPosition = position;
  345. },
  346. // 联系客服
  347. contactCustomerService() {
  348. // 示例:打开客服会话
  349. // 实际情况下可能需要调用微信的客服接口
  350. uni.showToast({
  351. title: '正在连接客服...',
  352. icon: 'none'
  353. });
  354. // 这只是一个示例,实际应用中可能需要调用微信的客服功能
  355. // 比如可以跳转到联系客服的页面
  356. setTimeout(() => {
  357. let serviceItem = this.tools.find(item => item.name === "联系客服");
  358. if (serviceItem && serviceItem.path) {
  359. this.navigateToTool(serviceItem.path);
  360. }
  361. }, 500);
  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. },
  413. onReady() {
  414. // 获取屏幕宽度和高度
  415. uni.getSystemInfo({
  416. success: (res) => {
  417. this.screenWidth = res.windowWidth;
  418. this.screenHeight = res.windowHeight;
  419. },
  420. });
  421. },
  422. onShow() {
  423. let token = uni.getStorageSync("token");
  424. if (token) {
  425. this.getUserInfo();
  426. this.getWithdrawalOrder();
  427. }
  428. },
  429. };
  430. </script>
  431. <style lang="scss" scoped>
  432. .mine-page {
  433. min-height: 100vh;
  434. background-color: #f5f5f5;
  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>