index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <div class="">
  3. <lucency-header :lang="lang" page-key="product" />
  4. <!-- 推荐广告-->
  5. <product-banner :lang="lang" />
  6. <!-- 产品类别 -->
  7. <product-types :lang="lang" :type="type"></product-types>
  8. </div>
  9. </template>
  10. <script>
  11. import langMap from "@/map/langMap";
  12. import productBanner from "@/components/banner/productBanner";
  13. export default {
  14. name: "index",
  15. props:['uLang','pType','pKey'],
  16. components:{
  17. productBanner
  18. },
  19. data(){
  20. return {
  21. lang: this.uLang?this.uLang:langMap.lang.cn,
  22. type: this.pType?this.pType:'all',
  23. key: this.pKey?this.pKey:'',
  24. page: 1,
  25. productTypes: [],
  26. }
  27. },
  28. mounted() {
  29. this.$root.$on('changeLang',this.switchLang);
  30. this.$root.$on('searchProductKey',this.changeProductKeyHandle);
  31. this.$root.$on('changeProductType',this.selectType);
  32. // this.loadData();
  33. },
  34. methods:{
  35. switchLang(nextLang){
  36. if(nextLang){
  37. this.lang = nextLang;
  38. }else{
  39. if(this.lang === langMap.lang.cn){
  40. this.lang = langMap.lang.en
  41. }else{
  42. this.lang = langMap.lang.cn
  43. }
  44. }
  45. },
  46. selectType(nextType){
  47. console.log(nextType)
  48. this.type = nextType;
  49. this.searchProduct();
  50. },
  51. changeProductKeyHandle(key){
  52. if(this.key === key){
  53. return 0;
  54. }
  55. this.key = key;
  56. this.searchProduct();
  57. },
  58. async searchProduct(){
  59. const formData = new FormData();
  60. formData.append('key',this.key);
  61. formData.append('type',this.type);
  62. formData.append('page',this.page);
  63. // 获取数据
  64. let [err,res] = await handle(this.$axios.get())
  65. }
  66. }
  67. }
  68. </script>
  69. <style scoped>
  70. </style>