import language from "./common/language.js"; import Service from "./common/service.js"; new Vue({ el: "#app", data: { current_index: 0, tab_list: ["企业定位", "企业使命", "企业愿景", "联系我们"], info: {}, params: { realname: "", // 姓名 tel: "", // 电话 email: "", // 邮箱 content: "", // 描述 }, config: {}, baseURL: Service.baseURL, company_list: [], company_img: "", }, computed: { current_tab() { return `calc((100% - ${this.tab_list.length * 15}rem) / 2 + ${ (this.current_index + 0.5) * 15 }rem - 1.75rem)`; }, }, mounted() { this.getList(); }, methods: { text(val) { return language[val][localStorage.getItem("language")]; }, lan_key(val) { return `${val}${localStorage.getItem("language") == "en" ? "_en" : ""}`; }, // 切换tab changeCurrent(item) { window.scrollTo(0, document.getElementById(item).offsetTop - 70); }, // 获取数据 getList() { Service.getCompany() .then((res) => { this.company_list = res; }) .catch((err) => { console.log(err); }); Service.get_site() .then((res) => { this.config = res; this.company_img = res.web_company_address_image; }) .catch((err) => { console.log(err); }); Service.get_about() .then((res) => { this.info = res; }) .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); }); }, }, });