list.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view class="container" :style="{ '--font-scale': fontScale }">
  3. <view class="header">
  4. <text class="title">🎮 益智小游戏</text>
  5. <text class="subtitle">完成游戏获得积分奖励</text>
  6. </view>
  7. <view class="game-list">
  8. <view
  9. class="game-card"
  10. v-for="game in gameList"
  11. :key="game.id"
  12. @click="playGame(game)"
  13. >
  14. <view class="game-icon">{{ game.icon }}</view>
  15. <view class="game-info">
  16. <text class="game-name">{{ game.gameName }}</text>
  17. <text class="game-desc">{{ game.description }}</text>
  18. <view class="game-meta">
  19. <text class="duration">⏱️ {{ game.defaultDuration }}分钟</text>
  20. <text class="points">⭐ {{ game.defaultPoints }}积分</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="tips" v-if="gameList.length === 0">
  26. <text>暂无小游戏,请联系管理员添加</text>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { getMiniGameList, reportAppEnter
  32. } from '../../utils/api.js'
  33. import fontScaleMixin from '@/mixins/font-scale.js'
  34. export default {
  35. mixins: [fontScaleMixin],
  36. data() {
  37. return {
  38. gameList: []
  39. }
  40. },
  41. onLoad() {
  42. reportAppEnter('game');
  43. this.loadGames()
  44. },
  45. methods: {
  46. async loadGames() {
  47. try {
  48. const res = await getMiniGameList()
  49. this.gameList = res.data || []
  50. } catch (e) {
  51. console.error('加载游戏列表失败', e)
  52. }
  53. },
  54. goRecords() {
  55. uni.navigateTo({ url: '/pages/games/records' })
  56. },
  57. goStats() {
  58. uni.navigateTo({ url: '/pages/games/stats' })
  59. },
  60. playGame(game) {
  61. // 跳转到对应的游戏页面
  62. const pageMap = {
  63. 'schulte': '/pages/games/schulte',
  64. '1a2b': '/pages/games/1a2b',
  65. 'sudoku': '/pages/games/sudoku'
  66. }
  67. const url = pageMap[game.gameCode]
  68. if (url) {
  69. uni.navigateTo({ url })
  70. } else {
  71. uni.showToast({
  72. title: '游戏页面开发中',
  73. icon: 'none'
  74. })
  75. }
  76. }
  77. }
  78. }
  79. </script>
  80. <style scoped lang="scss">
  81. .container {
  82. padding: $uni-space-page;
  83. background: linear-gradient(135deg, $app-ink-night 0%, $app-ink-night-2 100%);
  84. min-height: 100vh;
  85. }
  86. .header {
  87. text-align: center;
  88. margin-bottom: 40rpx;
  89. }
  90. .title {
  91. display: block;
  92. font-size: calc(48rpx * var(--font-scale, 1));
  93. font-weight: bold;
  94. color: $accent-yellow-light;
  95. text-shadow: 2rpx 2rpx 4rpx rgba(0,0,0,0.5);
  96. }
  97. .subtitle {
  98. display: block;
  99. font-size: calc(28rpx * var(--font-scale, 1));
  100. color: rgba(255,255,255,0.7);
  101. margin-top: 10rpx;
  102. }
  103. .nav-item {
  104. flex: 1;
  105. background: rgba(255,255,255,0.15);
  106. border-radius: 16rpx;
  107. padding: 24rpx;
  108. display: flex;
  109. flex-direction: column;
  110. align-items: center;
  111. border: 1rpx solid rgba(255,255,255,0.1);
  112. }
  113. .nav-icon {
  114. font-size: calc(48rpx * var(--font-scale, 1));
  115. margin-bottom: 8rpx;
  116. }
  117. .nav-text {
  118. font-size: calc(24rpx * var(--font-scale, 1));
  119. color: rgba(255,255,255,0.8);
  120. }
  121. .game-list {
  122. display: flex;
  123. flex-direction: column;
  124. gap: $uni-space-lg;
  125. }
  126. .game-card {
  127. background: linear-gradient(135deg, $game-ink 0%, #1a1a3a 100%);
  128. border-radius: 24rpx;
  129. padding: $uni-space-lg;
  130. display: flex;
  131. align-items: center;
  132. box-shadow: 0 8rpx 16rpx rgba(0,0,0,0.3);
  133. border: 1rpx solid rgba(255,255,255,0.1);
  134. }
  135. .game-icon {
  136. font-size: calc($uni-font-size-5xl * var(--font-scale, 1));
  137. width: 120rpx;
  138. height: 120rpx;
  139. display: flex;
  140. align-items: center;
  141. justify-content: center;
  142. background: rgba(255,255,255,0.1);
  143. border-radius: 24rpx;
  144. margin-right: $uni-space-lg;
  145. }
  146. .game-info {
  147. flex: 1;
  148. }
  149. .game-name {
  150. display: block;
  151. font-size: calc(36rpx * var(--font-scale, 1));
  152. font-weight: bold;
  153. color: $app-surface;
  154. margin-bottom: 10rpx;
  155. }
  156. .game-desc {
  157. display: block;
  158. font-size: calc(26rpx * var(--font-scale, 1));
  159. color: rgba(255,255,255,0.6);
  160. margin-bottom: 16rpx;
  161. }
  162. .game-meta {
  163. display: flex;
  164. gap: $uni-space-lg;
  165. }
  166. .duration, .points {
  167. font-size: calc(24rpx * var(--font-scale, 1));
  168. color: $flat-teal;
  169. }
  170. .tips {
  171. text-align: center;
  172. color: rgba(255,255,255,0.5);
  173. margin-top: 100rpx;
  174. }
  175. </style>