_type.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <!-- <product-index :p-type="type" :p-product="products"/>-->
  3. <solution-index :p-type="type" :p-solution="solutions" :p-page-data="basePageData"></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. import {apiMap, baseUrl} from "~/map/apiMap";
  12. const pageLimit = 5;
  13. export default {
  14. name: "typeSolutionPage",
  15. props:[],
  16. async asyncData(ctx){
  17. // 获取数据
  18. let url = baseUrl + apiMap.searchSolution.path;
  19. let type = ctx.params.type?ctx.params.type:'all';
  20. url += `?type=${type}&p=1&l=5`
  21. let [err,res] = await handle(axios.get( url));
  22. if(err){
  23. console.log(err);
  24. return {};
  25. }
  26. let result = res.data;
  27. if(result.code === 1){
  28. let pageData = {
  29. limit: result.limit,
  30. page: result.page,
  31. total: result.total,
  32. count: result.count,
  33. }
  34. return {
  35. solutions: result.data,
  36. basePageData: pageData,
  37. }
  38. }else{
  39. return {solutions:[]}
  40. }
  41. },
  42. data(){
  43. return {
  44. type: 'all',
  45. basePageData: {},
  46. solutions: []
  47. }
  48. },
  49. beforeMount() {
  50. this.type = this.$route.params.type?this.$route.params.type:'all';
  51. },
  52. components:{
  53. SolutionIndex,
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. </style>