index.vue 16 KB

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