木邻有你前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

385 lines
9.3 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
3 months ago
1 month ago
1 month ago
3 months ago
1 month ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
1 month ago
3 months ago
1 month ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
1 month ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="my-page">
  3. <!-- 顶部渐变背景区域 -->
  4. <view class="header-section">
  5. <!-- 右上角图标 -->
  6. <!-- <view class="header-icons">
  7. <uv-icon name="more-dot-fill" size="20" color="white"></uv-icon>
  8. <uv-icon name="setting" size="20" color="white"></uv-icon>
  9. </view> -->
  10. <!-- 用户信息区域 -->
  11. <view class="user-info" @click="navigateTo('profile')">
  12. <view class="avatar-container">
  13. <image class="avatar" :src="userInfo.headImage || '/static/默认头像.png'" mode="aspectFill"></image>
  14. </view>
  15. <text class="username">{{ userInfo.nickName }}</text>
  16. </view>
  17. </view>
  18. <!-- 积分信息区域 -->
  19. <view class="points-section">
  20. <view class="points-item yellow" @click="navigateTo('favoritesActivity')">
  21. <view class="points-content">
  22. <text class="points-number">{{ userInfo.collectionNum }}</text>
  23. <text class="points-label yellow">我的收藏</text>
  24. </view>
  25. <view class="points-icon">
  26. <!-- <uv-icon name="star-fill" size="28" color="#FFD700"></uv-icon> -->
  27. <image class="points-icon-img" src="/static/我的_活动收藏.png" mode="aspectFit"></image>
  28. </view>
  29. </view>
  30. <view class="points-item blue" @click="navigateTo('points')">
  31. <view class="points-content">
  32. <text class="points-number">{{ userInfo.score }}</text>
  33. <text class="points-label blue">可用积分</text>
  34. </view>
  35. <view class="points-icon">
  36. <image class="points-icon-img" src="/static/我的_积分.png" mode="aspectFit"></image>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 常用功能区域 -->
  41. <view class="functions-container">
  42. <text class="section-title">常用功能</text>
  43. <view class="functions-grid">
  44. <!-- 第一行 -->
  45. <view class="function-item" @click="navigateTo('profile')">
  46. <image class="function-icon" src="/static/我的_我的资料.png" mode="aspectFit"></image>
  47. <text class="function-text">我的资料</text>
  48. </view>
  49. <view class="function-item" @click="navigateTo('reports')">
  50. <image class="function-icon" src="/static/我的_我的报名.png" mode="aspectFit"></image>
  51. <text class="function-text">我的报名</text>
  52. </view>
  53. <view class="function-item" @click="navigateTo('records')">
  54. <image class="function-icon" src="/static/我的_兑换记录.png" mode="aspectFit"></image>
  55. <text class="function-text">兑换记录</text>
  56. </view>
  57. <view class="function-item" @click="navigateTo('favorites')">
  58. <image class="function-icon" src="/static/我的_商品收藏.png" mode="aspectFit"></image>
  59. <text class="function-text">商品收藏</text>
  60. </view>
  61. <!-- 第二行 -->
  62. <view class="function-item" @click="logout" v-if="isLogin">
  63. <image class="function-icon" src="/static/我的_退出登录.png" mode="aspectFit"></image>
  64. <text class="function-text">退出登录</text>
  65. </view>
  66. <view class="function-item" @click="navigateTo('about')">
  67. <image class="function-icon" src="/static/我的_关于我们.png" mode="aspectFit"></image>
  68. <text class="function-text">关于我们</text>
  69. </view>
  70. <view class="function-item" @click="navigateTo('checkin')" v-if="userInfo.role === 1">
  71. <view class="function-icon-wrapper">
  72. <uv-icon name="file-text-fill" size="32" color="#218cdd"></uv-icon>
  73. </view>
  74. <text class="function-text">活动签到</text>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. export default {
  82. name: 'MyPage',
  83. data() {
  84. return {
  85. userInfo: {
  86. name: '小精灵',
  87. headImage: '/static/默认头像.png',
  88. collectionNum: 5,
  89. score: 41
  90. },
  91. isLogin: false
  92. }
  93. },
  94. methods: {
  95. navigateTo(page) {
  96. console.log('导航到:', page)
  97. // 根据不同页面进行导航
  98. switch(page) {
  99. case 'profile':
  100. if (uni.getStorageSync('token')) {
  101. uni.navigateTo({
  102. url: '/subPages/my/myProfile'
  103. })
  104. }else{
  105. uni.navigateTo({
  106. url: '/subPages/login/login'
  107. })
  108. }
  109. break
  110. case 'reports':
  111. uni.navigateTo({
  112. url: '/subPages/my/myRegistrations'
  113. })
  114. break
  115. case 'records':
  116. uni.navigateTo({
  117. url: '/subPages/my/exchangeRecord'
  118. })
  119. break
  120. case 'favorites':
  121. uni.navigateTo({
  122. url: '/subPages/my/productFavorites'
  123. })
  124. break
  125. case 'favoritesActivity':
  126. uni.navigateTo({
  127. url: '/subPages/my/activityFavorites'
  128. })
  129. break
  130. case 'about':
  131. // 关于我们页面
  132. uni.navigateTo({
  133. url: '/subPages/index/organizationIntroduction'
  134. })
  135. break
  136. case 'checkin':
  137. uni.navigateTo({
  138. url: '/subPages/my/activityCheckin'
  139. })
  140. break
  141. case 'points':
  142. uni.navigateTo({
  143. url: '/subPages/shop/pointsDetail'
  144. })
  145. break
  146. default:
  147. break
  148. }
  149. },
  150. logout() {
  151. uni.showModal({
  152. title: '提示',
  153. content: '确定要退出登录吗?',
  154. success: (res) => {
  155. if (res.confirm) {
  156. // 清除用户信息
  157. uni.removeStorageSync('token')
  158. this.isLogin = false
  159. uni.showToast({
  160. title: '已退出登录',
  161. icon: 'success'
  162. })
  163. // 跳转到登录页面
  164. setTimeout(() => {
  165. uni.reLaunch({
  166. url: '/subPages/login/login'
  167. })
  168. }, 1000)
  169. }
  170. }
  171. })
  172. },
  173. async getUser() {
  174. if (uni.getStorageSync('token')) {
  175. const res = await this.$api.user.queryUser()
  176. this.userInfo = res?.result
  177. }else{
  178. this.userInfo = {
  179. nickName: '未登录',
  180. headImage: '/static/默认头像.png',
  181. collectionNum: '0',
  182. score: '0'
  183. }
  184. }
  185. }
  186. },
  187. onShow() {
  188. this.getUser()
  189. this.isLogin = uni.getStorageSync('token') ? true : false
  190. },
  191. async onPullDownRefresh() {
  192. await this.getUser()
  193. uni.stopPullDownRefresh()
  194. }
  195. }
  196. </script>
  197. <style lang="scss" scoped>
  198. .my-page {
  199. min-height: 100vh;
  200. background-color: #FFFFFF;
  201. }
  202. // 顶部渐变背景区域
  203. .header-section {
  204. // background: linear-gradient(180deg, #1488db, #98b5f1);
  205. background-image: url('/static/我的_背景.png');
  206. box-sizing: border-box;
  207. // background-color: #FFFFFF;
  208. background-size: 100% 100%;
  209. padding-top: 260rpx;
  210. height: 400rpx;
  211. margin-bottom: 50px;
  212. position: relative;
  213. }
  214. .header-icons {
  215. display: flex;
  216. justify-content: flex-end;
  217. gap: 32rpx;
  218. margin-bottom: 40rpx;
  219. }
  220. // 用户信息区域
  221. .user-info {
  222. display: flex;
  223. flex-direction: column;
  224. align-items: center;
  225. }
  226. .avatar-container {
  227. width: 120rpx;
  228. height: 120rpx;
  229. border-radius: 50%;
  230. overflow: hidden;
  231. margin-bottom: 20rpx;
  232. border: 4rpx solid rgba(255, 255, 255, 0.3);
  233. }
  234. .avatar {
  235. width: 100%;
  236. height: 100%;
  237. }
  238. .username {
  239. font-size: 30rpx;
  240. color: #000000;
  241. // font-weight: bold;
  242. }
  243. // 积分信息区域
  244. .points-section {
  245. display: flex;
  246. justify-content: space-between;
  247. margin: 30rpx 30rpx;
  248. gap: 24rpx;
  249. }
  250. .points-item {
  251. border-radius: 12rpx;
  252. padding: 0rpx 24rpx;
  253. flex: 1;
  254. display: flex;
  255. align-items: center;
  256. justify-content: space-between;
  257. position: relative;
  258. box-shadow: 0px 1.5px 3px 0px rgba(0,0,0,0.16);
  259. &.yellow {
  260. background: #FEF4D1;
  261. }
  262. &.blue {
  263. background: #C7E6FF;
  264. }
  265. }
  266. .points-content {
  267. display: flex;
  268. flex-direction: column;
  269. align-items: flex-start;
  270. }
  271. .points-number {
  272. font-size: 32rpx;
  273. color: #000000;
  274. // font-weight: bold;
  275. line-height: 1;
  276. }
  277. .points-label {
  278. font-size: 24rpx;
  279. color: #000000;
  280. font-size: 24rpx;
  281. // color: white;
  282. margin-top: 8rpx;
  283. &.yellow{
  284. color: #DEB31B;
  285. }
  286. &.blue{
  287. color: #1488db;
  288. }
  289. }
  290. .points-icon {
  291. display: flex;
  292. align-items: center;
  293. justify-content: center;
  294. &-img{
  295. width: 140rpx;
  296. height: 140rpx;
  297. }
  298. }
  299. // 常用功能区域
  300. .functions-container {
  301. height: 319px;
  302. background: #ffffff;
  303. border-radius: 8px;
  304. box-shadow: 0px 1.5px 3px 0px rgba(0,0,0,0.16);
  305. margin: 20rpx 30rpx;
  306. padding: 40rpx;
  307. }
  308. .section-title {
  309. font-size: 32rpx;
  310. color: #333;
  311. font-weight: bold;
  312. margin-bottom: 40rpx;
  313. display: block;
  314. }
  315. .functions-grid {
  316. display: grid;
  317. grid-template-columns: repeat(4, 1fr);
  318. gap: 40rpx 10rpx;
  319. }
  320. .function-item {
  321. display: flex;
  322. flex-direction: column;
  323. align-items: center;
  324. gap: 16rpx;
  325. padding: 20rpx;
  326. border-radius: 12rpx;
  327. transition: all 0.3s ease;
  328. &:active {
  329. background-color: #F0F8FF;
  330. transform: scale(0.95);
  331. }
  332. }
  333. .function-icon {
  334. width: 48rpx;
  335. height: 48rpx;
  336. }
  337. .function-icon-wrapper {
  338. width: 48rpx;
  339. height: 48rpx;
  340. display: flex;
  341. align-items: center;
  342. justify-content: center;
  343. }
  344. .function-text {
  345. font-size: 24rpx;
  346. color: #000000;
  347. text-align: center;
  348. }
  349. </style>