list.vue 3.8 KB

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