list.vue 3.7 KB

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