index.vue 11 KB

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