index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <div id="index">
  3. <!-- 顶部搜索栏 -->
  4. <div class="top_nav df aic jcsb">
  5. <div class="left_title df aic">
  6. <img v-if="VITEPLA === 'QingQue'" src="http://gm.nkfzs.com/favicon.ico" />
  7. <span v-if="VITEPLA === 'QingQue'">朱雀游戏中心</span>
  8. <span v-else>游戏中心</span>
  9. </div>
  10. <van-search shape='round' @click="router.push({ path: 'm_search' })" />
  11. </div>
  12. <div class="df aic jcc" style="color: #ed8c0f;margin: 10px auto; font-size: 14px;">客服qq:386501046</div>
  13. <!-- 轮播图 -->
  14. <van-swipe class="my-swipe" indicator-color="white" :autoplay="3000">
  15. <van-swipe-item v-for="item in listSwiper" :key="item.game_id" class="psr">
  16. <img :src="prefix + item.screenshot">
  17. <div class="game_card psa df fdc aic">
  18. <img :src="prefix + item.logopic">
  19. <p class="title elli">{{ item.screen_name }}</p>
  20. <van-button :disabled="item.download_url === '' ? true : false" round color="#ed8c0f"
  21. @click="downGame(item.download_url)">下载</van-button>
  22. </div>
  23. </van-swipe-item>
  24. </van-swipe>
  25. <!-- 菜单栏 -->
  26. <div class="menu_cate df aic jcsa">
  27. <div v-for="(item, index) in cateList" :key="index" class="cate_card df fdc aic jcc"
  28. @click="toPath(item.pathUrl)">
  29. <van-icon :name="item.icon" size="20" class="icon"></van-icon>
  30. <span class="title">{{ item.title }}</span>
  31. </div>
  32. </div>
  33. <!-- 游戏列表 -->
  34. <div class="games">
  35. <h3>热门游戏</h3>
  36. <MobList :gameLis="list" :prefix="prefix"></MobList>
  37. <h3 style="margin-top: 30px;">推荐游戏</h3>
  38. <MobList :gameLis="listRecommand" :prefix="prefix"></MobList>
  39. </div>
  40. </div>
  41. <van-back-top style="background-color: #ed8c0f;" />
  42. <!-- <m_footer></m_footer> -->
  43. </template>
  44. <script setup lang="ts">
  45. import { getIndexGameHot, getIndexGameRecommand } from '@/api/index';
  46. import MobList from '@/components/MobList.vue';
  47. import { onMounted, ref } from 'vue';
  48. import { useRouter } from 'vue-router';
  49. import Message from '@/utils/Message'
  50. const router = useRouter()
  51. const list: any = ref([])
  52. const listRecommand: any = ref([])
  53. const listSwiper: any = ref([])
  54. const prefix = ref<string>('')
  55. const VITEPLA:'QingQue'|'KuPai' = import.meta.env.VITE_LOGO_VISIBLE
  56. interface ICate {
  57. title: string,
  58. icon: string,
  59. pathUrl: string
  60. }
  61. const cateList = ref<Array<ICate>>([
  62. // { title: '排行', icon: 'medal-o', pathUrl: 'm_rank' },
  63. { title: '分类', icon: 'description', pathUrl: 'm_categroy' },
  64. { title: '我的游戏', icon: 'user-o', pathUrl: 'm_mine' }
  65. ])
  66. onMounted(async () => {
  67. // 热门游戏
  68. await getIndexGameHot().then(res => {
  69. if (res.data.code === 200 && res.data.data) {
  70. list.value = res.data.data.lists
  71. prefix.value = res.data.data.prefix
  72. }
  73. }).catch(err => {
  74. Message.error(err.data)
  75. })
  76. // 推荐游戏
  77. await getIndexGameRecommand().then(res => {
  78. if (res.data.code === 200 && res.data.data) {
  79. listRecommand.value = res.data.data.lists
  80. prefix.value = res.data.data.prefix
  81. }
  82. }).catch(err => {
  83. Message.error(err.data)
  84. })
  85. // 轮播图数据
  86. await getIndexGameHot().then(res => {
  87. // console.log(res);
  88. if (res.data.code === 200 && res.data.data) {
  89. prefix.value = res.data.data.prefix
  90. listSwiper.value = res.data.data.lists.splice(0, 5)
  91. // console.log('listSwiper.value', listSwiper.value);
  92. }
  93. }).catch(err => {
  94. Message.error(err.data)
  95. })
  96. })
  97. const toPath = (url: string) => {
  98. router.push({ path: url })
  99. }
  100. const downGame = (url: string) => {
  101. // 下载游戏
  102. window.open(url)
  103. // window.location.href = url;
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. #index {
  108. box-sizing: border-box;
  109. padding: 15px;
  110. // background: radial-gradient(circle at 0 -10%,#dcf4f7,rgba(220,244,247,0) 50%),radial-gradient(circle at 100% 10%,#e8ebfc,rgba(232,235,252,0) 50%);
  111. background: radial-gradient(circle at 0 -20%, #ed8c0f, rgba(255, 255, 255, .6) 25%), radial-gradient(circle at 100% 10%, #eabf85, rgba(255, 255, 255, .6) 50%);
  112. .top_nav {
  113. margin-bottom: 10px;
  114. .left_title {
  115. font-size: 22px;
  116. }
  117. }
  118. .game_card {
  119. bottom: 10px;
  120. right: 10px;
  121. width: 80px;
  122. box-sizing: border-box;
  123. img {
  124. width: 35px;
  125. height: 35px;
  126. border-radius: 10px;
  127. }
  128. .title {
  129. font-size: 12px;
  130. color: #323332;
  131. line-height: 14px;
  132. margin: 5px 0;
  133. width: 95%;
  134. }
  135. .van-button {
  136. width: 60px;
  137. height: 25px;
  138. font-size: 12px;
  139. }
  140. }
  141. .menu_cate {
  142. margin-top: 10px;
  143. .cate_card {
  144. height: 80px;
  145. .icon {
  146. margin-bottom: 10px;
  147. }
  148. .title {
  149. font-size: 16px;
  150. }
  151. }
  152. }
  153. .games {
  154. margin-top: 10px;
  155. box-sizing: border-box;
  156. h3 {
  157. font-size: 20px;
  158. font-weight: normal;
  159. margin-bottom: 8px;
  160. }
  161. }
  162. }
  163. :deep(.van-search) {
  164. width: 50%;
  165. background-color: transparent;
  166. border-color: #b1d5ec;
  167. }
  168. .my-swipe {
  169. border-radius: 20px;
  170. }
  171. .van-swipe-item {
  172. color: #fff;
  173. font-size: 20px;
  174. line-height: 150px;
  175. text-align: center;
  176. background-color: rgba(237, 140, 15, .3);
  177. width: 100%;
  178. height: 180px;
  179. img {
  180. display: block;
  181. width: 100%;
  182. height: 100%;
  183. border-radius: 20px;
  184. // background-size: cover;
  185. // background-position: center;
  186. // background-repeat: no-repeat;
  187. }
  188. }
  189. </style>