index.vue 18 KB

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