list.vue 3.7 KB

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