index.vue 14 KB

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