_type.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 {handle} from "~/until/handle";
  7. import axios from "axios";
  8. import qs from "qs";
  9. import SolutionIndex from "@/pages/solution/index";
  10. import {apiMap, baseUrl} from "~/map/apiMap";
  11. import {isEmpty} from "@/until/typeTool";
  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. // 获取页面的seo优化关键字
  28. let types = ctx.store.getters.pTypes;
  29. let title = "合方圆-解决方案"
  30. let seo_key = "合方圆,合方圆科技,深圳合方圆";
  31. let seoDescription = "合方圆科技产品中心,定制化需求, 电网解决方案, 国标应用";
  32. // 判断是否有数据
  33. if(!isEmpty(types)){
  34. // console.log(`已经获取到类型数据`);
  35. // 获取当前类型的数据
  36. let typeData = types.find(item=>item.type_key === type);
  37. // console.log(typeData);
  38. if(typeData){
  39. seo_key += `,合方圆${typeData.type_name},${typeData.type_name},${typeData.seo_key}`;
  40. seoDescription = `深圳市合方圆科技${typeData.type_name}`;
  41. title = `合方圆-${typeData.type_name}`;
  42. }
  43. }
  44. if(result.code === 1){
  45. let pageData = {
  46. limit: result.limit,
  47. page: result.page,
  48. total: result.total,
  49. count: result.count,
  50. }
  51. return {
  52. solutions: result.data,
  53. basePageData: pageData,
  54. title,
  55. seo_key,
  56. seoDescription
  57. }
  58. }else{
  59. return {
  60. solutions:[],
  61. title,
  62. seo_key,
  63. seoDescription
  64. }
  65. }
  66. },
  67. head(){
  68. return {
  69. title: this.title,
  70. meta: [
  71. {
  72. hid: 'description',
  73. name: 'description',
  74. content: this.seoDescription
  75. },
  76. {
  77. hid: 'keywords',
  78. name: 'keywords',
  79. content: this.seo_key
  80. },
  81. ]
  82. }
  83. },
  84. data(){
  85. return {
  86. title: "",
  87. seo_key: "合方圆,合方圆科技",
  88. seoDescription: "合方圆科技,合天地方圆,解决方案",
  89. type: 'all',
  90. basePageData: {},
  91. solutions: []
  92. }
  93. },
  94. beforeMount() {
  95. this.type = this.$route.params.type?this.$route.params.type:'all';
  96. },
  97. components:{
  98. SolutionIndex,
  99. }
  100. }
  101. </script>
  102. <style scoped>
  103. </style>