list.vue 4.1 KB

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