index-mobile.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import language from "./common/language.js";
  2. import Service from "./common/service.js";
  3. new Vue({
  4. el: "#app",
  5. data: {
  6. swiper: {}, // 轮播图对象
  7. carousel_list: [], // 轮播图数据
  8. company_tab: 0, // 0 公司使命 1 公司愿景 2 未来设想
  9. company_list: [], // 公司图片列表
  10. product_tab: {}, // 当前产品tab
  11. product_tab_list: [], // 产品tab数据
  12. product_img: "", // 产品中心图
  13. new_list: [], // 新闻数据
  14. baseURL: Service.baseURL,
  15. config: {}, // 页面配置
  16. params: {
  17. realname: "", // 姓名
  18. tel: "", // 电话
  19. email: "", // 邮箱
  20. content: "", // 描述
  21. },
  22. },
  23. mounted() {
  24. this.getData();
  25. this.getConfig();
  26. },
  27. methods: {
  28. text(val) {
  29. return language[val][localStorage.getItem("language")];
  30. },
  31. lan_key(val) {
  32. return `${val}${localStorage.getItem("language") == "en" ? "_en" : ""}`;
  33. },
  34. // 初始化轮播图
  35. initSwiper() {
  36. this.swiper = new window.Swiper(".swiper", { autoplay: true });
  37. },
  38. // 获取数据
  39. getData() {
  40. Service.get_index()
  41. .then((res) => {
  42. this.carousel_list = res.banner;
  43. this.product_tab_list = res.product;
  44. this.product_tab = this.product_tab_list[0];
  45. this.new_list = res.news;
  46. this.initSwiper();
  47. })
  48. .catch((err) => {
  49. console.log(err);
  50. });
  51. },
  52. getConfig() {
  53. Service.get_site()
  54. .then((res) => {
  55. this.config = res;
  56. this.company_list = [
  57. res.web_about_image1,
  58. res.web_about_image2,
  59. res.web_about_image3,
  60. ];
  61. this.product_img = res.web_product_info_image;
  62. })
  63. .catch((err) => {
  64. console.log(err);
  65. });
  66. },
  67. submit() {
  68. if (!this.params.realname) return alert(this.text("请输入您的称呼"));
  69. if (!this.params.tel) return alert(this.text("请输入您的手机号"));
  70. if (!this.params.email) return alert(this.text("请输入您的邮箱地址"));
  71. Service.create_message(this.params)
  72. .then((res) => {
  73. Object.keys(this.params).forEach((key) => (this.params[key] = ""));
  74. alert(this.text("提交成功"));
  75. })
  76. .catch((err) => {
  77. console.log(err);
  78. });
  79. },
  80. },
  81. });