展品维保小程序前端代码接口
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.

374 lines
9.0 KiB

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