index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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. </view>
  89. </template>
  90. <script>
  91. export default {
  92. data() {
  93. return {
  94. userInfo: {
  95. userId: 0,
  96. openid: "",
  97. imgPath: "",
  98. nickName: "这里是微信昵称.",
  99. mobile: "",
  100. tags: [],
  101. accountMoney: 0,
  102. couponNum: 0,
  103. point: 0,
  104. firstAuditNum: 0,
  105. pickUpNum: 0,
  106. auditNum: 0,
  107. payNum: 0,
  108. refundNum: 0,
  109. },
  110. orderTypes: [
  111. {
  112. name: "待初审",
  113. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/1.png",
  114. badge: 0,
  115. key: "firstAuditNum",
  116. path: "/pages-mine/pages/order-page?status=2",
  117. },
  118. {
  119. name: "待取件",
  120. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/2.png",
  121. badge: 0,
  122. key: "pickUpNum",
  123. path: "/pages-mine/pages/order-page?status=3",
  124. },
  125. {
  126. name: "待审核",
  127. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/3.png",
  128. badge: 0,
  129. key: "auditNum",
  130. path: "/pages-mine/pages/order-page?status=8",
  131. },
  132. {
  133. name: "待到款",
  134. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/4.png",
  135. badge: 0,
  136. key: "payNum",
  137. path: "/pages-mine/pages/order-page?status=10",
  138. },
  139. {
  140. name: "申请退回",
  141. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/5.png",
  142. badge: 0,
  143. key: "refundNum",
  144. path: "/pages-mine/pages/apply-return",
  145. },
  146. ],
  147. tools: [
  148. {
  149. name: "消息通知",
  150. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t1.png",
  151. path: "/pages-mine/pages/notice",
  152. },
  153. { name: "我的收藏", icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t2.png", path: "" },
  154. { name: "我的足迹", icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t3.png", path: "" },
  155. {
  156. name: "我的地址",
  157. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t4.png",
  158. path: "/pages-mine/pages/address/list",
  159. },
  160. { name: "我的优惠券", icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t5.png", path: "" },
  161. {
  162. name: "联系客服",
  163. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t6.png",
  164. path: "link-service",
  165. },
  166. {
  167. name: "意见反馈",
  168. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t7.png",
  169. path: "/pages-mine/pages/feedback",
  170. },
  171. {
  172. name: "到货提醒",
  173. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t8.png",
  174. path: "/pages/tools/arrival-notice",
  175. },
  176. {
  177. name: "合伙人计划",
  178. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t9.png",
  179. path: "/pages-mine/pages/partner/partner-rule",
  180. },
  181. {
  182. name: "买卖答疑",
  183. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t10.png",
  184. path: "/pages-mine/pages/rules-for-sellbooks",
  185. },
  186. {
  187. name: "关于书嗨",
  188. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t11.png",
  189. path: "/pages-home/pages/about-us",
  190. },
  191. {
  192. name: "我的余额",
  193. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t12.png",
  194. path: "/pages-mine/pages/wallet",
  195. },
  196. {
  197. name: "用户设置",
  198. icon: "https://shuhi.oss-cn-qingdao.aliyuncs.com/mini/t13.png",
  199. path: "/pages-mine/pages/setting",
  200. },
  201. ],
  202. };
  203. },
  204. methods: {
  205. //用户信息
  206. handleUpdateUserInfo() {
  207. uni.navigateTo({
  208. url: "/pages-mine/pages/setting",
  209. });
  210. },
  211. //查看全部订单
  212. viewAllOrders() {
  213. uni.navigateTo({
  214. url: "/pages-mine/pages/order-page?status=-1",
  215. });
  216. },
  217. //跳转订单
  218. navigateToOrder(path) {
  219. uni.navigateTo({
  220. url: path,
  221. });
  222. },
  223. //跳转工具
  224. navigateToTool(path) {
  225. if (!path)
  226. return uni.showToast({
  227. title: "开发中...",
  228. icon: "none",
  229. });
  230. if (path == "/pages-mine/pages/partner/partner-rule") {
  231. this.getPartnerStatus();
  232. } else {
  233. uni.navigateTo({
  234. url: path,
  235. });
  236. }
  237. },
  238. //获取用户信息
  239. getUserInfo() {
  240. uni.$u.http.get("/token/user/detail").then((res) => {
  241. console.log(res);
  242. if (res.code == 200) {
  243. this.userInfo = res.data;
  244. uni.setStorageSync("userInfo", this.userInfo);
  245. this.orderTypes.forEach((item) => {
  246. item.badge = this.userInfo[item.key];
  247. });
  248. }
  249. });
  250. },
  251. //获取合伙人状态
  252. getPartnerStatus() {
  253. let item = this.tools.find((item) => item.name == "合伙人计划");
  254. uni.$u.get("/token/getUserPartnerInfo").then((res) => {
  255. if (res.code == 200) {
  256. let { status } = res.data;
  257. if (status == -1 || status == 4) {
  258. item.path = "/pages-mine/pages/partner/partner-rule";
  259. } else if (status == 1) {
  260. item.path = "/pages-mine/pages/partner/partner-home";
  261. } else {
  262. item.path = "/pages-mine/pages/partner/partner-status";
  263. }
  264. } else {
  265. item.path = "/pages-mine/pages/partner/partner-status";
  266. }
  267. uni.navigateTo({
  268. url: item.path,
  269. });
  270. });
  271. },
  272. },
  273. onShow() {
  274. let token = uni.getStorageSync("token");
  275. if (token) {
  276. this.getUserInfo();
  277. }
  278. },
  279. };
  280. </script>
  281. <style lang="scss" scoped>
  282. .mine-page {
  283. min-height: 100vh;
  284. background-color: #f5f5f5;
  285. .link-service {
  286. background: transparent;
  287. border: none;
  288. padding: 0;
  289. margin: 0;
  290. width: 100%;
  291. height: 100%;
  292. line-height: 36rpx;
  293. }
  294. .user-info {
  295. background: url("/static/img/bg.png") no-repeat center center;
  296. background-size: 100% 100%;
  297. position: absolute;
  298. top: 0;
  299. left: 0;
  300. padding: 20rpx 50rpx 120rpx;
  301. color: #fff;
  302. position: relative;
  303. padding-top: 160rpx;
  304. &::after {
  305. width: 140%;
  306. position: absolute;
  307. left: -20%;
  308. top: 0;
  309. z-index: -1;
  310. content: "";
  311. border-radius: 0 0 50% 50%;
  312. background: #fd6954;
  313. }
  314. .user-header {
  315. display: flex;
  316. align-items: center;
  317. margin-bottom: 40rpx;
  318. .user-avatar {
  319. border-radius: 50%;
  320. margin-right: 20rpx;
  321. border: 4rpx solid #fff;
  322. width: 128rpx;
  323. height: 128rpx;
  324. overflow: hidden;
  325. flex-shrink: 0;
  326. background: #fff;
  327. .avatar {
  328. width: 100%;
  329. height: 100%;
  330. border-radius: 50%;
  331. object-fit: cover;
  332. }
  333. }
  334. .user-detail {
  335. .nickname {
  336. font-size: 32rpx;
  337. font-weight: 500;
  338. margin-bottom: 8rpx;
  339. }
  340. .user-tag {
  341. display: inline-block;
  342. font-size: 22rpx;
  343. padding: 4rpx 12rpx;
  344. background: linear-gradient(-90deg, #272321, #4b4542);
  345. border-radius: 4rpx;
  346. margin-top: 8rpx;
  347. margin-right: 10rpx;
  348. }
  349. }
  350. }
  351. .user-data {
  352. display: flex;
  353. justify-content: space-between;
  354. position: relative;
  355. z-index: 1;
  356. padding: 0 40rpx;
  357. .data-item {
  358. position: relative;
  359. text-align: center;
  360. .amount {
  361. font-size: 38rpx;
  362. font-weight: 500;
  363. margin-bottom: 8rpx;
  364. }
  365. .label {
  366. font-size: 24rpx;
  367. font-weight: 400;
  368. opacity: 0.9;
  369. }
  370. .badge {
  371. position: absolute;
  372. top: -15rpx;
  373. right: -120%;
  374. padding: 0 10rpx;
  375. font-size: 20rpx;
  376. line-height: 30rpx;
  377. height: 30rpx;
  378. background: #ff8400;
  379. border-radius: 15rpx 15rpx 15rpx 0rpx;
  380. }
  381. }
  382. }
  383. }
  384. .order-section {
  385. margin: -90rpx 30rpx 20rpx;
  386. background: #fff;
  387. border-radius: 12rpx;
  388. padding: 30rpx;
  389. position: relative;
  390. z-index: 2;
  391. .section-header {
  392. display: flex;
  393. justify-content: space-between;
  394. align-items: center;
  395. margin-bottom: 30rpx;
  396. .view-all {
  397. display: flex;
  398. align-items: center;
  399. color: #999;
  400. font-size: 26rpx;
  401. }
  402. }
  403. .order-types {
  404. display: flex;
  405. justify-content: space-between;
  406. .type-item {
  407. text-align: center;
  408. position: relative;
  409. .badge {
  410. position: absolute;
  411. top: -15rpx;
  412. right: -6px;
  413. padding: 0 10rpx;
  414. font-size: 20rpx;
  415. line-height: 30rpx;
  416. height: 30rpx;
  417. background: #f56c6c;
  418. color: #fff;
  419. border-radius: 15rpx 15rpx 15rpx 0rpx;
  420. }
  421. .type-icon {
  422. width: 60rpx;
  423. height: 60rpx;
  424. margin-bottom: 12rpx;
  425. }
  426. text {
  427. font-size: 26rpx;
  428. color: #333;
  429. }
  430. }
  431. }
  432. }
  433. .tools-section {
  434. margin: 30rpx;
  435. background: #fff;
  436. border-radius: 12rpx;
  437. padding: 30rpx;
  438. position: relative;
  439. z-index: 2;
  440. .section-title {
  441. font-size: 30rpx;
  442. font-weight: 500;
  443. margin-bottom: 30rpx;
  444. }
  445. .tools-grid {
  446. display: grid;
  447. grid-template-columns: repeat(4, 1fr);
  448. gap: 30rpx;
  449. .tool-item {
  450. text-align: center;
  451. .tool-icon {
  452. width: 60rpx;
  453. height: 60rpx;
  454. margin-bottom: 12rpx;
  455. }
  456. text {
  457. font-size: 24rpx;
  458. color: #333;
  459. }
  460. }
  461. }
  462. }
  463. }
  464. </style>