games.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <view class="games-page">
  3. <!-- 页面内容 -->
  4. <scroll-view class="page-content" scroll-y>
  5. <!-- 游戏列表 -->
  6. <view class="games-list">
  7. <view class="game-item" v-for="(item, index) in gameList" :key="index" @tap="detail(item)">
  8. <image class="image" :src="item.image" mode=""></image>
  9. </view>
  10. <view class="game-item" v-for="(game, index) in gamesList" :key="index" v-if="false">
  11. <!-- 大横幅卡片 -->
  12. <view class="game-banner" :class="'banner-' + game.id">
  13. <view class="banner-content">
  14. <view class="banner-title" :style="{ color: game.titleColor }">
  15. {{ game.title }}
  16. </view>
  17. <view class="banner-buttons" v-if="game.bannerButtons">
  18. <view class="banner-btn" v-for="(btn, btnIndex) in game.bannerButtons" :key="btnIndex"
  19. @click.stop="handleBannerBtnClick(game, btn)">
  20. {{ btn.text }}
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 信息卡片 -->
  26. <view class="game-info-card"
  27. :style="{ borderColor: game.themeColor + '40',background: game.themeColor }">
  28. <view class="card-icon">
  29. <view class="icon-placeholder">
  30. <text class="icon-emoji">{{ game.icon }}</text>
  31. </view>
  32. </view>
  33. <view class="card-content">
  34. <view class="card-title">{{ game.title }}</view>
  35. <view class="card-desc">{{ game.desc }}</view>
  36. </view>
  37. <view class="card-action">
  38. <view class="play-btn" :style="{ color: game.themeColor }" @click="handlePlay(game)">
  39. 玩一玩
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <!-- 底部安全区域 -->
  46. <view class="safe-area-bottom" :style="{ height: safeAreaBottom + 'px' }"></view>
  47. </scroll-view>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. getConfigByKey
  53. } from '@/api/common.js'
  54. export default {
  55. data() {
  56. return {
  57. statusBarHeight: 0,
  58. safeAreaBottom: 0,
  59. gameList:[],
  60. gamesList: [{
  61. id: 1,
  62. title: '果蔬连连看',
  63. desc: '休闲放松类游戏',
  64. icon: '🍉',
  65. themeColor: '#1B88EF',
  66. titleColor: '#FF6B35',
  67. bannerButtons: [{
  68. text: '果蔬连连看游戏',
  69. action: 'play'
  70. },
  71. {
  72. text: '游戏说明',
  73. action: 'help'
  74. }
  75. ]
  76. },
  77. {
  78. id: 2,
  79. title: '开心消消乐',
  80. desc: '益智类休闲游戏',
  81. icon: '🎵',
  82. themeColor: '#7A48FF',
  83. titleColor: '#FFD700',
  84. bannerButtons: null
  85. },
  86. {
  87. id: 3,
  88. title: '保卫萝卜2',
  89. desc: '益智类休闲游戏',
  90. icon: '🥕',
  91. themeColor: '#3DA270',
  92. titleColor: '#FF6B35',
  93. bannerButtons: [{
  94. text: '开始冒险',
  95. action: 'start'
  96. },
  97. {
  98. text: '天天向上',
  99. action: 'daily'
  100. }
  101. ]
  102. }
  103. ]
  104. }
  105. },
  106. onLoad() {
  107. this.getSystemInfo();
  108. },
  109. methods: {
  110. detail(e){
  111. let user = JSON.parse(uni.getStorageSync('userInfo'));
  112. let userId = user.userId
  113. uni.redirectTo({
  114. url:`/pages_im/pages/common/webviewWrapper/index?url=${encodeURIComponent(e.url)}?userId=${userId}`
  115. })
  116. },
  117. async getSystemInfo() {
  118. const systemInfo = uni.getSystemInfoSync();
  119. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  120. if (systemInfo.safeArea) {
  121. this.safeAreaBottom = systemInfo.screenHeight - systemInfo.safeArea.bottom;
  122. }
  123. const result = await getConfigByKey({
  124. key: 'app.config'
  125. })
  126. if (result.code == 200 && result.data) {
  127. const resData = JSON.parse(result.data)
  128. this.gameList = resData.gameList
  129. }
  130. },
  131. handleBack() {
  132. uni.navigateBack();
  133. },
  134. handlePlay(game) {
  135. uni.showToast({
  136. title: `开始玩${game.title}`,
  137. icon: 'none'
  138. });
  139. // 这里可以跳转到具体的游戏页面
  140. },
  141. handleBannerBtnClick(game, btn) {
  142. uni.showToast({
  143. title: btn.text,
  144. icon: 'none'
  145. });
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss" scoped>
  151. .games-page {
  152. width: 100%;
  153. min-height: 100vh;
  154. background-color: #ffffff;
  155. display: flex;
  156. flex-direction: column;
  157. }
  158. .status-bar {
  159. width: 100%;
  160. background-color: #ffffff;
  161. }
  162. .nav-bar {
  163. width: 100%;
  164. height: 88rpx;
  165. background-color: #ffffff;
  166. display: flex;
  167. align-items: center;
  168. justify-content: center;
  169. position: relative;
  170. border-bottom: 1rpx solid #f0f0f0;
  171. .nav-back {
  172. position: absolute;
  173. left: 30rpx;
  174. width: 60rpx;
  175. height: 60rpx;
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. }
  180. .nav-title {
  181. font-size: 36rpx;
  182. font-weight: 500;
  183. color: #333333;
  184. }
  185. }
  186. .page-content {
  187. flex: 1;
  188. width: 100%;
  189. }
  190. .games-list {
  191. width: 100%;
  192. padding: 30rpx;
  193. }
  194. .game-item {
  195. width: 100%;
  196. margin-bottom: 24rpx;
  197. &:last-child {
  198. margin-bottom: 0;
  199. }
  200. }
  201. // 游戏横幅
  202. .game-banner {
  203. width: 100%;
  204. height: 400rpx;
  205. border-radius: 24rpx 24rpx 0 0;
  206. overflow: hidden;
  207. position: relative;
  208. .banner-content {
  209. width: 100%;
  210. height: 100%;
  211. display: flex;
  212. flex-direction: column;
  213. align-items: center;
  214. justify-content: center;
  215. position: relative;
  216. z-index: 2;
  217. }
  218. .banner-title {
  219. font-size: 64rpx;
  220. font-weight: bold;
  221. text-align: center;
  222. margin-bottom: 30rpx;
  223. text-shadow:
  224. 2rpx 2rpx 0rpx #ffffff,
  225. 4rpx 4rpx 8rpx rgba(0, 0, 0, 0.3);
  226. position: relative;
  227. z-index: 3;
  228. }
  229. .banner-buttons {
  230. display: flex;
  231. gap: 20rpx;
  232. margin-top: 20rpx;
  233. }
  234. .banner-btn {
  235. background-color: rgba(173, 216, 230, 0.95);
  236. color: #4A90E2;
  237. padding: 12rpx 24rpx;
  238. border-radius: 30rpx;
  239. font-size: 24rpx;
  240. font-weight: 500;
  241. white-space: nowrap;
  242. }
  243. }
  244. // 游戏1:果蔬连连看
  245. .banner-1 {
  246. background: linear-gradient(180deg, #87CEEB 0%, #B0E0E6 50%, #98D8C8 100%);
  247. position: relative;
  248. &::before {
  249. content: '';
  250. position: absolute;
  251. top: 0;
  252. left: 0;
  253. right: 0;
  254. bottom: 0;
  255. background-image:
  256. radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.4) 3rpx, transparent 3rpx),
  257. radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.3) 2rpx, transparent 2rpx);
  258. background-size: 120rpx 120rpx, 100rpx 100rpx;
  259. background-position: 0 0, 60rpx 60rpx;
  260. }
  261. .banner-title {
  262. color: #FF6B35;
  263. text-shadow:
  264. 2rpx 2rpx 0rpx #ffffff,
  265. 4rpx 4rpx 8rpx rgba(0, 0, 0, 0.2);
  266. }
  267. }
  268. // 游戏2:开心消消乐
  269. .banner-2 {
  270. background: linear-gradient(135deg, #9B59B6 0%, #8E44AD 50%, #7D3C98 100%);
  271. position: relative;
  272. &::before {
  273. content: '';
  274. position: absolute;
  275. top: 0;
  276. left: 0;
  277. right: 0;
  278. bottom: 0;
  279. background-image:
  280. radial-gradient(circle at 30% 40%, rgba(255, 192, 203, 0.5) 4rpx, transparent 4rpx),
  281. radial-gradient(circle at 70% 60%, rgba(173, 216, 230, 0.5) 4rpx, transparent 4rpx);
  282. background-size: 120rpx 120rpx, 100rpx 100rpx;
  283. background-position: 0 0, 60rpx 60rpx;
  284. animation: sparkle 3s ease-in-out infinite;
  285. }
  286. .banner-title {
  287. color: #FFD700;
  288. text-shadow:
  289. 2rpx 2rpx 0rpx #ffffff,
  290. 4rpx 4rpx 8rpx rgba(0, 0, 0, 0.3);
  291. }
  292. }
  293. // 游戏3:保卫萝卜2
  294. .banner-3 {
  295. background: linear-gradient(180deg, #87CEEB 0%, #B0E0E6 50%, #98D8C8 100%);
  296. position: relative;
  297. &::before {
  298. content: '';
  299. position: absolute;
  300. top: 0;
  301. left: 0;
  302. right: 0;
  303. bottom: 0;
  304. background-image:
  305. radial-gradient(circle at 25% 35%, rgba(255, 255, 255, 0.4) 3rpx, transparent 3rpx),
  306. radial-gradient(circle at 75% 65%, rgba(255, 255, 255, 0.3) 2rpx, transparent 2rpx);
  307. background-size: 120rpx 120rpx, 100rpx 100rpx;
  308. background-position: 0 0, 60rpx 60rpx;
  309. }
  310. .banner-title {
  311. color: #FF6B35;
  312. text-shadow:
  313. 2rpx 2rpx 0rpx #ffffff,
  314. 4rpx 4rpx 8rpx rgba(0, 0, 0, 0.2);
  315. }
  316. .banner-buttons {
  317. flex-direction: column;
  318. gap: 16rpx;
  319. align-items: center;
  320. }
  321. .banner-btn {
  322. background-color: rgba(255, 218, 185, 0.95);
  323. color: #FF6B35;
  324. padding: 16rpx 40rpx;
  325. width: 240rpx;
  326. text-align: center;
  327. }
  328. }
  329. @keyframes sparkle {
  330. 0%,
  331. 100% {
  332. opacity: 0.6;
  333. }
  334. 50% {
  335. opacity: 1;
  336. }
  337. }
  338. // 信息卡片
  339. .game-info-card {
  340. width: 100%;
  341. background-color: #ffffff;
  342. border-radius: 0 0 24rpx 24rpx;
  343. padding: 28rpx;
  344. display: flex;
  345. align-items: center;
  346. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
  347. border: 2rpx solid;
  348. transition: all 0.3s ease;
  349. .card-icon {
  350. width: 100rpx;
  351. height: 100rpx;
  352. margin-right: 24rpx;
  353. flex-shrink: 0;
  354. .icon-placeholder {
  355. width: 100%;
  356. height: 100%;
  357. border-radius: 16rpx;
  358. display: flex;
  359. align-items: center;
  360. justify-content: center;
  361. .icon-emoji {
  362. font-size: 60rpx;
  363. }
  364. }
  365. }
  366. .card-content {
  367. flex: 1;
  368. display: flex;
  369. flex-direction: column;
  370. justify-content: center;
  371. }
  372. .card-title {
  373. font-family: PingFang SC, PingFang SC;
  374. font-weight: 600;
  375. font-size: 36rpx;
  376. color: #FFFFFF;
  377. margin-bottom: 8rpx;
  378. }
  379. .card-desc {
  380. font-family: PingFang SC, PingFang SC;
  381. font-weight: 400;
  382. font-size: 26rpx;
  383. color: #FFFFFF;
  384. }
  385. .card-action {
  386. margin-left: 20rpx;
  387. flex-shrink: 0;
  388. .play-btn {
  389. background-color: #fff;
  390. padding: 20rpx 50rpx;
  391. border-radius: 50rpx;
  392. font-family: PingFang SC, PingFang SC;
  393. font-weight: 600;
  394. font-size: 36rpx;
  395. }
  396. }
  397. }
  398. .safe-area-bottom {
  399. width: 100%;
  400. height: 40rpx;
  401. }
  402. .image {
  403. width: calc(100vw - 48rpx);
  404. height: 544rpx;
  405. }
  406. </style>