木邻有你前端代码仓库
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.

361 lines
8.6 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month 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">
  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">
  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. collection: 5,
  89. score: 41
  90. }
  91. }
  92. },
  93. methods: {
  94. navigateTo(page) {
  95. console.log('导航到:', page)
  96. // 根据不同页面进行导航
  97. switch(page) {
  98. case 'profile':
  99. uni.navigateTo({
  100. url: '/subPages/my/myProfile'
  101. })
  102. break
  103. case 'reports':
  104. uni.navigateTo({
  105. url: '/subPages/my/myRegistrations'
  106. })
  107. break
  108. case 'records':
  109. uni.navigateTo({
  110. url: '/subPages/my/exchangeRecord'
  111. })
  112. break
  113. case 'favorites':
  114. uni.navigateTo({
  115. url: '/subPages/my/productFavorites'
  116. })
  117. break
  118. case 'favoritesActivity':
  119. uni.navigateTo({
  120. url: '/subPages/my/activityFavorites'
  121. })
  122. break
  123. case 'about':
  124. // 关于我们页面
  125. uni.navigateTo({
  126. url: '/subPages/index/organizationIntroduction'
  127. })
  128. break
  129. case 'checkin':
  130. uni.navigateTo({
  131. url: '/subPages/my/activityCheckin'
  132. })
  133. break
  134. case 'points':
  135. uni.navigateTo({
  136. url: '/subPages/my/exchangeRecord'
  137. })
  138. break
  139. default:
  140. break
  141. }
  142. },
  143. logout() {
  144. uni.showModal({
  145. title: '提示',
  146. content: '确定要退出登录吗?',
  147. success: (res) => {
  148. if (res.confirm) {
  149. // 清除用户信息
  150. uni.removeStorageSync('token')
  151. uni.showToast({
  152. title: '已退出登录',
  153. icon: 'success'
  154. })
  155. // 跳转到登录页面
  156. setTimeout(() => {
  157. uni.reLaunch({
  158. url: '/subPages/login/login'
  159. })
  160. }, 1000)
  161. }
  162. }
  163. })
  164. },
  165. async getUser() {
  166. const res = await this.$api.user.queryUser()
  167. this.userInfo = res.result
  168. }
  169. },
  170. onShow() {
  171. this.getUser()
  172. }
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. .my-page {
  177. min-height: 100vh;
  178. background-color: #FFFFFF;
  179. }
  180. // 顶部渐变背景区域
  181. .header-section {
  182. // background: linear-gradient(180deg, #1488db, #98b5f1);
  183. background-image: url('/static/我的_背景.png');
  184. box-sizing: border-box;
  185. // background-color: #FFFFFF;
  186. background-size: 100% 100%;
  187. padding-top: 260rpx;
  188. height: 400rpx;
  189. margin-bottom: 50px;
  190. position: relative;
  191. }
  192. .header-icons {
  193. display: flex;
  194. justify-content: flex-end;
  195. gap: 32rpx;
  196. margin-bottom: 40rpx;
  197. }
  198. // 用户信息区域
  199. .user-info {
  200. display: flex;
  201. flex-direction: column;
  202. align-items: center;
  203. }
  204. .avatar-container {
  205. width: 120rpx;
  206. height: 120rpx;
  207. border-radius: 50%;
  208. overflow: hidden;
  209. margin-bottom: 20rpx;
  210. border: 4rpx solid rgba(255, 255, 255, 0.3);
  211. }
  212. .avatar {
  213. width: 100%;
  214. height: 100%;
  215. }
  216. .username {
  217. font-size: 30rpx;
  218. color: #000000;
  219. // font-weight: bold;
  220. }
  221. // 积分信息区域
  222. .points-section {
  223. display: flex;
  224. justify-content: space-between;
  225. margin: 30rpx 30rpx;
  226. gap: 24rpx;
  227. }
  228. .points-item {
  229. border-radius: 12rpx;
  230. padding: 0rpx 24rpx;
  231. flex: 1;
  232. display: flex;
  233. align-items: center;
  234. justify-content: space-between;
  235. position: relative;
  236. box-shadow: 0px 1.5px 3px 0px rgba(0,0,0,0.16);
  237. &.yellow {
  238. background: #FEF4D1;
  239. }
  240. &.blue {
  241. background: #C7E6FF;
  242. }
  243. }
  244. .points-content {
  245. display: flex;
  246. flex-direction: column;
  247. align-items: flex-start;
  248. }
  249. .points-number {
  250. font-size: 32rpx;
  251. color: #000000;
  252. // font-weight: bold;
  253. line-height: 1;
  254. }
  255. .points-label {
  256. font-size: 24rpx;
  257. color: #000000;
  258. font-size: 24rpx;
  259. // color: white;
  260. margin-top: 8rpx;
  261. &.yellow{
  262. color: #DEB31B;
  263. }
  264. &.blue{
  265. color: #1488db;
  266. }
  267. }
  268. .points-icon {
  269. display: flex;
  270. align-items: center;
  271. justify-content: center;
  272. &-img{
  273. width: 140rpx;
  274. height: 140rpx;
  275. }
  276. }
  277. // 常用功能区域
  278. .functions-container {
  279. height: 319px;
  280. background: #ffffff;
  281. border-radius: 8px;
  282. box-shadow: 0px 1.5px 3px 0px rgba(0,0,0,0.16);
  283. margin: 20rpx 30rpx;
  284. padding: 40rpx;
  285. }
  286. .section-title {
  287. font-size: 32rpx;
  288. color: #333;
  289. font-weight: bold;
  290. margin-bottom: 40rpx;
  291. display: block;
  292. }
  293. .functions-grid {
  294. display: grid;
  295. grid-template-columns: repeat(4, 1fr);
  296. gap: 40rpx 10rpx;
  297. }
  298. .function-item {
  299. display: flex;
  300. flex-direction: column;
  301. align-items: center;
  302. gap: 16rpx;
  303. padding: 20rpx;
  304. border-radius: 12rpx;
  305. transition: all 0.3s ease;
  306. &:active {
  307. background-color: #F0F8FF;
  308. transform: scale(0.95);
  309. }
  310. }
  311. .function-icon {
  312. width: 48rpx;
  313. height: 48rpx;
  314. }
  315. .function-icon-wrapper {
  316. width: 48rpx;
  317. height: 48rpx;
  318. display: flex;
  319. align-items: center;
  320. justify-content: center;
  321. }
  322. .function-text {
  323. font-size: 24rpx;
  324. color: #000000;
  325. text-align: center;
  326. }
  327. </style>