index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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-rule" },
  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. if (path == "/pages-mine/pages/partner/partner-rule") {
  169. this.getPartnerStatus();
  170. } else {
  171. uni.navigateTo({
  172. url: path,
  173. });
  174. }
  175. },
  176. //获取用户信息
  177. getUserInfo() {
  178. uni.$u.http.get("/token/user/detail").then((res) => {
  179. console.log(res);
  180. if (res.code == 200) {
  181. this.userInfo = res.data;
  182. this.orderTypes.forEach((item) => {
  183. item.badge = this.userInfo[item.key];
  184. });
  185. }
  186. });
  187. },
  188. //获取合伙人状态
  189. getPartnerStatus() {
  190. let item = this.tools.find((item) => item.name == "合伙人计划");
  191. uni.$u.get("/token/getUserPartnerInfo").then((res) => {
  192. if (res.code == 200) {
  193. let { status } = res.data;
  194. if (status == -1) {
  195. item.path = "/pages-mine/pages/partner/partner-rule";
  196. } else if (status == 1) {
  197. item.path = "/pages-mine/pages/partner/partner-home";
  198. } else {
  199. item.path = "/pages-mine/pages/partner/partner-status";
  200. }
  201. } else {
  202. item.path = "/pages-mine/pages/partner/partner-status";
  203. }
  204. uni.navigateTo({
  205. url: item.path,
  206. });
  207. });
  208. },
  209. },
  210. onShow() {
  211. let token = uni.getStorageSync("token");
  212. if (token) {
  213. this.getUserInfo();
  214. }
  215. },
  216. };
  217. </script>
  218. <style lang="scss" scoped>
  219. .mine-page {
  220. min-height: 100vh;
  221. background-color: #f5f5f5;
  222. .user-info {
  223. background-color: #38c148;
  224. padding: 20rpx 50rpx 120rpx;
  225. color: #fff;
  226. position: relative;
  227. &::after {
  228. width: 140%;
  229. position: absolute;
  230. left: -20%;
  231. top: 0;
  232. z-index: -1;
  233. content: "";
  234. border-radius: 0 0 50% 50%;
  235. background: #fd6954;
  236. }
  237. .user-header {
  238. display: flex;
  239. align-items: center;
  240. margin-bottom: 40rpx;
  241. .user-avatar {
  242. border-radius: 50%;
  243. margin-right: 20rpx;
  244. border: 4rpx solid #fff;
  245. width: 128rpx;
  246. height: 128rpx;
  247. .avatar {
  248. width: 120rpx;
  249. height: 120rpx;
  250. border-radius: 50%;
  251. }
  252. }
  253. .user-detail {
  254. .nickname {
  255. font-size: 32rpx;
  256. font-weight: 500;
  257. margin-bottom: 8rpx;
  258. }
  259. .user-tag {
  260. display: inline-block;
  261. font-size: 22rpx;
  262. padding: 4rpx 12rpx;
  263. background: linear-gradient(-90deg, #272321, #4b4542);
  264. border-radius: 4rpx;
  265. margin-top: 8rpx;
  266. margin-right: 10rpx;
  267. }
  268. }
  269. }
  270. .user-data {
  271. display: flex;
  272. justify-content: space-between;
  273. position: relative;
  274. z-index: 1;
  275. padding: 0 40rpx;
  276. .data-item {
  277. position: relative;
  278. text-align: center;
  279. .amount {
  280. font-size: 38rpx;
  281. font-weight: 500;
  282. margin-bottom: 8rpx;
  283. }
  284. .label {
  285. font-size: 24rpx;
  286. font-weight: 400;
  287. opacity: 0.9;
  288. }
  289. .badge {
  290. position: absolute;
  291. top: -15rpx;
  292. right: -120%;
  293. padding: 0 10rpx;
  294. font-size: 20rpx;
  295. line-height: 30rpx;
  296. height: 30rpx;
  297. background: #ff8400;
  298. border-radius: 15rpx 15rpx 15rpx 0rpx;
  299. }
  300. }
  301. }
  302. }
  303. .order-section {
  304. margin: -80rpx 30rpx 20rpx;
  305. background: #fff;
  306. border-radius: 12rpx;
  307. padding: 30rpx;
  308. position: relative;
  309. z-index: 2;
  310. .section-header {
  311. display: flex;
  312. justify-content: space-between;
  313. align-items: center;
  314. margin-bottom: 30rpx;
  315. .view-all {
  316. display: flex;
  317. align-items: center;
  318. color: #999;
  319. font-size: 26rpx;
  320. }
  321. }
  322. .order-types {
  323. display: flex;
  324. justify-content: space-between;
  325. .type-item {
  326. text-align: center;
  327. position: relative;
  328. .badge {
  329. position: absolute;
  330. top: -15rpx;
  331. right: -6px;
  332. padding: 0 10rpx;
  333. font-size: 20rpx;
  334. line-height: 30rpx;
  335. height: 30rpx;
  336. background: #f56c6c;
  337. color: #fff;
  338. border-radius: 15rpx 15rpx 15rpx 0rpx;
  339. }
  340. .type-icon {
  341. width: 60rpx;
  342. height: 60rpx;
  343. margin-bottom: 12rpx;
  344. }
  345. text {
  346. font-size: 26rpx;
  347. color: #333;
  348. }
  349. }
  350. }
  351. }
  352. .tools-section {
  353. margin: 30rpx;
  354. background: #fff;
  355. border-radius: 12rpx;
  356. padding: 30rpx;
  357. position: relative;
  358. z-index: 2;
  359. .section-title {
  360. font-size: 30rpx;
  361. font-weight: 500;
  362. margin-bottom: 30rpx;
  363. }
  364. .tools-grid {
  365. display: grid;
  366. grid-template-columns: repeat(4, 1fr);
  367. gap: 30rpx;
  368. .tool-item {
  369. text-align: center;
  370. .tool-icon {
  371. width: 60rpx;
  372. height: 60rpx;
  373. margin-bottom: 12rpx;
  374. }
  375. text {
  376. font-size: 24rpx;
  377. color: #333;
  378. }
  379. }
  380. }
  381. }
  382. }
  383. </style>