Browse Source

连通cate

pujiaming 2 years ago
parent
commit
56436d7df1
3 changed files with 32 additions and 3 deletions
  1. 12 0
      src/style.css
  2. 11 2
      src/views/category.vue
  3. 9 1
      src/views/home.vue

+ 12 - 0
src/style.css

@@ -55,6 +55,18 @@ input[type="number"] {
 *{
   user-select: none;
 }
+/* 谷歌与苹果自带浏览器,隐藏办法如下代码。 */
+*::-webkit-scrollbar {
+	display: none;
+}
+/* 火狐浏览器,隐藏办法如下代码。 */
+* {
+	scrollbar-width: none;
+}
+/* IE 与微软浏览器,隐藏办法如下代码。 */
+* {
+	-ms-overflow-style: none;
+}
 /* ------------------------------------------------------------------------- */
 @font-face {
   font-family: 'zihunchaoji';

+ 11 - 2
src/views/category.vue

@@ -87,7 +87,9 @@ import { getGameType, getGameTag, getGameList } from '@/api/index'
 import Message from '@/utils/Message'
 import { bytesChange } from '@/utils/bytesFormatter'
 import type { DropdownMenuInstance } from 'vant'
+import { useRoute } from 'vue-router'
 
+const route = useRoute()
 const img:any = inject('img')
 const typeIndex = ref<number>(0)
 const tag_idIndex = ref<number>(0)
@@ -121,7 +123,12 @@ onMounted(async() => {
     tagArr.value = res.data.data
     tagArr.value.unshift({ id: 0, name: '全部' })
   })
-  getGameLists(params)
+  if (route.query.tag_id) {
+    const id = parseInt(route.query.tag_id as string)
+    selectType('tag_id', id)
+  } else {
+    getGameLists(params)
+  }
 })
 
 // 初始化列表数据
@@ -142,7 +149,9 @@ const getGameLists = async(params:any) => {
 }
 const menuRef = ref<DropdownMenuInstance>()
 // 点击类型、标签、排序
-const selectType = (type: any, index: any) => {
+const selectType = (type: 'type' | 'tag_id', index: any) => {
+  console.log(index)
+
   gameLis.value = []
   params.page = 1
 

+ 9 - 1
src/views/home.vue

@@ -100,7 +100,7 @@
         <div>热门标签</div>
       </div>
       <el-divider />
-      <el-button v-for="(item,index) in tagArr" round :key="index" type="primary" size="small" style="margin-bottom: .3rem;">{{ item.name }}</el-button>
+      <el-button v-for="(item,index) in tagArr" round :key="index" type="primary" size="small" style="margin-bottom: .3rem;" @click="toCate(item.id)">{{ item.name }}</el-button>
     </div>
     <div class="action-item">
       <div class="service">
@@ -242,6 +242,14 @@ const posterErrorFun = (event:any) => {
   imgDom.src = img('defaultPoster.png')
   imgDom.onerror = null
 }
+const toCate = (id:number) => {
+  router.push({
+    path: '/cate',
+    query: {
+      tag_id: id
+    }
+  })
+}
 const downGame = (url: string, disabled:boolean) => {
   if (disabled) return
   // 下载游戏