<template>
<!--  <product-index :p-type="type" :p-product="products"/>-->
<!--  <solution-index :p-type="type" :p-solution="solutions"></solution-index>-->
  <news-index :p-type="type" :p-news="solutions"></news-index>
</template>

<script>
import productIndex from '@/pages/product/index.vue'
import handle from "~/until/handle";
import axios from "axios";
import qs from "qs";
import SolutionIndex from "@/pages/solution/index";
const pageLimit = 5;
export default {
  name: "typeNewsPage",
  props:[],
  async asyncData(ctx){
    // ctx.searchProduct();
    const queryData = {};
    // console.log(ctx)
    queryData['key']=ctx.key;

    queryData['type']=ctx.params.type?ctx.params.type:'all';
    queryData['page']=1;
    queryData['limit']=pageLimit;
    // 获取数据
    let url = 'http://szhfy.com.cn/api/searchNews.php';
    let [err,res] = await handle(axios.post(
      url,
      qs.stringify(queryData)
    ));
    if(err){
      console.log(err);
      return {};
    }
    let result = res.data;
    if(result.rcode === 1){
      return {solutions:result.data}
    }else{
      console.error(result.msg);
      console.log(result);
      return {solutions:[]}
    }
  },
  data(){
    return {
      type:  'all',
      solutions: []
    }
  },
  beforeMount() {
    // console.log('动态页面执行');
    this.type = this.$route.params.type?this.$route.params.type:'all';
    // console.log(this.type);
  },
  components:{
    SolutionIndex,
  }
}
</script>

<style scoped>

</style>
