natasha 1 rok pred
rodič
commit
2cb2dfe136
2 zmenil súbory, kde vykonal 57 pridanie a 40 odobranie
  1. 23 8
      src/views/bookStore/all.vue
  2. 34 32
      src/views/search/searchDetail.vue

+ 23 - 8
src/views/bookStore/all.vue

@@ -343,16 +343,31 @@ export default {
     },
     // 获取年份列表
     getYearList(){
-        let nowYear = new Date().getFullYear()
+        this.yearList = [
+            {
+                value: -1,
+                label: '全部'
+            }
+        ]
         let yearList = []
-        for(let i = 0; i < 20; i++){
-            let obj = {
-                value: nowYear - i,
-                label: nowYear - i
+        let MethodName = "/ShopServer/Client/ShopHomeQuery/GetIssueYearLabelList"
+        getLogin(MethodName, {})
+        .then((res) => {
+            if(res.status===1){
+                res.year_label_list.forEach(nowYear => {
+                    let obj = {
+                        value: nowYear,
+                        label: nowYear
+                    }
+                    yearList.push(obj)
+                })
+                this.yearList = this.yearList.concat(yearList)
             }
-            yearList.push(obj)
-        }
-        this.yearList = this.yearList.concat(yearList)
+        })
+        .catch(() => {
+            this.loading = false
+        });
+        
     }
   },
   //生命周期 - 创建完成(可以访问当前this实例)

+ 34 - 32
src/views/search/searchDetail.vue

@@ -34,7 +34,7 @@
             </ul>
             <ul v-if="yearList&&yearList.length>0" class="gradelist">
                 <li :class="['gradeitem',indeG===yearIndex?'active':'']" v-for="(itemG,indeG) in yearList" :key="indeG" @click="handleTypeIndex('yearIndex',indeG)">
-                    {{itemG.name}}
+                    {{itemG.label}}
                 </li>
             </ul>
             <p class="timeconsume">982条结果,耗时 300ms。</p>
@@ -116,6 +116,7 @@
 import Header from "../../components/Header.vue";
 import SearchInput from "./components/SearchInput.vue"
 import BookCard from "@/components/common/BookCard.vue"
+import { getLogin } from "@/api/ajax";
 export default {
   //import引入的组件需要注入到对象中才能使用
   components: { Header, SearchInput, BookCard },
@@ -198,37 +199,9 @@ export default {
       ],
       yearList:[
         {
-            name:'全部',
-            value: ''
-        },
-        {
-            name:'2016',
-            value: '2016'
-        },
-        {
-            name:'2017',
-            value: '2017'
-        },
-        {
-            name:'2018',
-            value: '2018'
-        },
-        {
-            name:'2019',
-            value: '2019'
-        },
-        {
-            name:'2020',
-            value: '2020'
-        },
-        {
-            name:'2021',
-            value: '2021'
-        },
-        {
-            name:'2022',
-            value: '2022'
-        },
+            label:'全部',
+            value: -1
+        }
       ],
       gradeIndex: 0,
       yearIndex: 0,
@@ -401,6 +374,34 @@ export default {
     handleCurrentChange(val) {
       this.currentPage = val;
     },
+    // 获取年份列表
+    getYearList(){
+        this.yearList = [
+            {
+                value: -1,
+                label: '全部'
+            }
+        ]
+        let yearList = []
+        let MethodName = "/ShopServer/Client/ShopHomeQuery/GetIssueYearLabelList"
+        getLogin(MethodName, {})
+        .then((res) => {
+            if(res.status===1){
+                res.year_label_list.forEach(nowYear => {
+                    let obj = {
+                        value: nowYear,
+                        label: nowYear
+                    }
+                    yearList.push(obj)
+                })
+                this.yearList = this.yearList.concat(yearList)
+            }
+        })
+        .catch(() => {
+            this.loading = false
+        });
+        
+    }
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
@@ -411,6 +412,7 @@ export default {
         this.headerBorder = arr[2]
         this.headerBg = arr[3]
     }
+    this.getYearList()
   },
   //生命周期 - 挂载完成(可以访问DOM元素)
   mounted() {