_type.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <!-- <product-index :p-type="type" :p-product="products"/>-->
  3. <solution-index :p-type="type" :p-solution="solutions"></solution-index>
  4. </template>
  5. <script>
  6. import productIndex from '@/pages/product/index.vue'
  7. import handle from "~/until/handle";
  8. import axios from "axios";
  9. import qs from "qs";
  10. import SolutionIndex from "@/pages/solution/index";
  11. const pageLimit = 5;
  12. export default {
  13. name: "typeSolutionPage",
  14. props:[],
  15. async asyncData(ctx){
  16. // ctx.searchProduct();
  17. const queryData = {};
  18. // console.log(ctx)
  19. queryData['key']=ctx.key;
  20. queryData['type']=ctx.params.type?ctx.params.type:'all';
  21. queryData['page']=1;
  22. queryData['limit']=pageLimit;
  23. // 获取数据
  24. let url = 'http://szhfy.com.cn/api/searchSolution.php';
  25. let [err,res] = await handle(axios.post(
  26. url,
  27. qs.stringify(queryData)
  28. ));
  29. if(err){
  30. console.log(err);
  31. return {};
  32. }
  33. let result = res.data;
  34. if(result.rcode === 1){
  35. return {solutions:result.data}
  36. }else{
  37. console.error(result.msg);
  38. console.log(result);
  39. return {solutions:[]}
  40. }
  41. },
  42. data(){
  43. return {
  44. type: 'all',
  45. solutions: []
  46. }
  47. },
  48. beforeMount() {
  49. // console.log('动态页面执行');
  50. this.type = this.$route.params.type?this.$route.params.type:'all';
  51. // console.log(this.type);
  52. },
  53. components:{
  54. SolutionIndex,
  55. }
  56. }
  57. </script>
  58. <style scoped>
  59. </style>