1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import language from "./common/language.js";
- import Service from "./common/service.js";
- new Vue({
- el: "#app",
- data: {
- swiper: {}, // 轮播图对象
- carousel_list: [], // 轮播图数据
- company_tab: 0, // 0 公司使命 1 公司愿景 2 未来设想
- company_list: [], // 公司图片列表
- product_tab: {}, // 当前产品tab
- product_tab_list: [], // 产品tab数据
- 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);
- });
- },
- },
- });
|