banner-mobile.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import Service from "../common/service.js";
  2. new Vue({
  3. el: "#banner",
  4. data: {
  5. title: "产品中心",
  6. image: "",
  7. path_list: [
  8. { key: "web_about", path: "/about-mobile.html" },
  9. { key: "web_product", path: "/product-mobile.html" },
  10. { key: "web_news", path: "/news-mobile.html" },
  11. { key: "web_join", path: "/join-mobile.html" },
  12. { key: "web_contact", path: "/contact-mobile.html" },
  13. ],
  14. config: {},
  15. current: {},
  16. },
  17. mounted() {
  18. this.getConfig();
  19. },
  20. methods: {
  21. lan_key(val) {
  22. return `${val}${localStorage.getItem("language") == "en" ? "_en" : ""}`;
  23. },
  24. setTitle() {
  25. const path = this.path_list.find((item) =>
  26. location.href.includes(item.path)
  27. );
  28. if (path) {
  29. this.title = this.config[this.lan_key(path.key)];
  30. this.image = Service.baseURL + this.config[path.key + "_image"];
  31. }
  32. },
  33. getConfig() {
  34. Service.get_site()
  35. .then((res) => {
  36. this.config = res;
  37. this.setTitle();
  38. })
  39. .catch((err) => {
  40. console.log(err);
  41. });
  42. },
  43. },
  44. });