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

365 lines
8.7 KiB

10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 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">
  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/shop/pointsDetail'
  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. async onPullDownRefresh() {
  174. await this.getUser()
  175. uni.stopPullDownRefresh()
  176. }
  177. }
  178. </script>
  179. <style lang="scss" scoped>
  180. .my-page {
  181. min-height: 100vh;
  182. background-color: #FFFFFF;
  183. }
  184. // 顶部渐变背景区域
  185. .header-section {
  186. // background: linear-gradient(180deg, #1488db, #98b5f1);
  187. background-image: url('/static/我的_背景.png');
  188. box-sizing: border-box;
  189. // background-color: #FFFFFF;
  190. background-size: 100% 100%;
  191. padding-top: 260rpx;
  192. height: 400rpx;
  193. margin-bottom: 50px;
  194. position: relative;
  195. }
  196. .header-icons {
  197. display: flex;
  198. justify-content: flex-end;
  199. gap: 32rpx;
  200. margin-bottom: 40rpx;
  201. }
  202. // 用户信息区域
  203. .user-info {
  204. display: flex;
  205. flex-direction: column;
  206. align-items: center;
  207. }
  208. .avatar-container {
  209. width: 120rpx;
  210. height: 120rpx;
  211. border-radius: 50%;
  212. overflow: hidden;
  213. margin-bottom: 20rpx;
  214. border: 4rpx solid rgba(255, 255, 255, 0.3);
  215. }
  216. .avatar {
  217. width: 100%;
  218. height: 100%;
  219. }
  220. .username {
  221. font-size: 30rpx;
  222. color: #000000;
  223. // font-weight: bold;
  224. }
  225. // 积分信息区域
  226. .points-section {
  227. display: flex;
  228. justify-content: space-between;
  229. margin: 30rpx 30rpx;
  230. gap: 24rpx;
  231. }
  232. .points-item {
  233. border-radius: 12rpx;
  234. padding: 0rpx 24rpx;
  235. flex: 1;
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-between;
  239. position: relative;
  240. box-shadow: 0px 1.5px 3px 0px rgba(0,0,0,0.16);
  241. &.yellow {
  242. background: #FEF4D1;
  243. }
  244. &.blue {
  245. background: #C7E6FF;
  246. }
  247. }
  248. .points-content {
  249. display: flex;
  250. flex-direction: column;
  251. align-items: flex-start;
  252. }
  253. .points-number {
  254. font-size: 32rpx;
  255. color: #000000;
  256. // font-weight: bold;
  257. line-height: 1;
  258. }
  259. .points-label {
  260. font-size: 24rpx;
  261. color: #000000;
  262. font-size: 24rpx;
  263. // color: white;
  264. margin-top: 8rpx;
  265. &.yellow{
  266. color: #DEB31B;
  267. }
  268. &.blue{
  269. color: #1488db;
  270. }
  271. }
  272. .points-icon {
  273. display: flex;
  274. align-items: center;
  275. justify-content: center;
  276. &-img{
  277. width: 140rpx;
  278. height: 140rpx;
  279. }
  280. }
  281. // 常用功能区域
  282. .functions-container {
  283. height: 319px;
  284. background: #ffffff;
  285. border-radius: 8px;
  286. box-shadow: 0px 1.5px 3px 0px rgba(0,0,0,0.16);
  287. margin: 20rpx 30rpx;
  288. padding: 40rpx;
  289. }
  290. .section-title {
  291. font-size: 32rpx;
  292. color: #333;
  293. font-weight: bold;
  294. margin-bottom: 40rpx;
  295. display: block;
  296. }
  297. .functions-grid {
  298. display: grid;
  299. grid-template-columns: repeat(4, 1fr);
  300. gap: 40rpx 10rpx;
  301. }
  302. .function-item {
  303. display: flex;
  304. flex-direction: column;
  305. align-items: center;
  306. gap: 16rpx;
  307. padding: 20rpx;
  308. border-radius: 12rpx;
  309. transition: all 0.3s ease;
  310. &:active {
  311. background-color: #F0F8FF;
  312. transform: scale(0.95);
  313. }
  314. }
  315. .function-icon {
  316. width: 48rpx;
  317. height: 48rpx;
  318. }
  319. .function-icon-wrapper {
  320. width: 48rpx;
  321. height: 48rpx;
  322. display: flex;
  323. align-items: center;
  324. justify-content: center;
  325. }
  326. .function-text {
  327. font-size: 24rpx;
  328. color: #000000;
  329. text-align: center;
  330. }
  331. </style>