1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import language from "./common/language.js";
- import Service from "./common/service.js";
- new Vue({
- el: "#app",
- data: {
- swiper: {},
- carousel_list: [],
- company_tab: 0,
- company_list: [],
- product_tab: {},
- product_tab_list: [],
- product_img: "",
- new_list: [],
- baseURL: Service.baseURL,
- config: {},
- params: {
- realname: "",
- tel: "",
- email: "",
- content: "",
- },
- },
- mounted() {
- this.getData();
- this.getConfig();
- },
- methods: {
- text(val) {
- return language[val][localStorage.getItem("language")];
- },
- lan_key(val) {
- return `${val}${localStorage.getItem("language") == "en" ? "_en" : ""}`;
- },
-
- initSwiper() {
- this.swiper = new window.Swiper(".swiper", { autoplay: true });
- },
-
- getData() {
- Service.get_index()
- .then((res) => {
- this.carousel_list = res.banner;
- this.product_tab_list = res.product;
- this.product_tab = this.product_tab_list[0];
- this.new_list = res.news;
- this.initSwiper();
- })
- .catch((err) => {
- console.log(err);
- });
- },
- getConfig() {
- Service.get_site()
- .then((res) => {
- this.config = res;
- this.company_list = [
- res.web_about_image1,
- res.web_about_image2,
- res.web_about_image3,
- ];
- this.product_img = res.web_product_info_image;
- })
- .catch((err) => {
- console.log(err);
- });
- },
- submit() {
- if (!this.params.realname) return alert(this.text("请输入您的称呼"));
- if (!this.params.tel) return alert(this.text("请输入您的手机号"));
- if (!this.params.email) return alert(this.text("请输入您的邮箱地址"));
- Service.create_message(this.params)
- .then((res) => {
- Object.keys(this.params).forEach((key) => (this.params[key] = ""));
- alert(this.text("提交成功"));
- })
- .catch((err) => {
- console.log(err);
- });
- },
- },
- });
|