index.vue 13 KB

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