// 公共部分(头部) var header_navigation_template = vue.extend({ name: 'header-navigation', //组件名称(keep-alive缓存需要本参数) template: '#header-navigation-template', data: function (){ return { efonglogopic: '', }; }, created: function (){ // 非空判断 if(isnotnull(this.$store.state.basicpictutrelist)){ // 设置所有子页面的banner图片 this.setbasicpictutrelist(this.$store.state.basicpictutrelist); } }, mounted: function (){ // 导航栏标题加上背景 $(".enteraboutpage").addclass("activenav"); }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, watch: { // 监听数据 '$store.state.basicpictutrelist': function (newname, oldname){ // 设置所有子页面的banner图片 this.setbasicpictutrelist(newname); } }, methods: { // 设置所有子页面的banner图片 setbasicpictutrelist: function (basicpictutrelist){ // 数组查找 let basicpictutre = basicpictutrelist.find(item => item.name == "官网logo"); // 赋值数据 this.efonglogopic = basicpictutre.pic; }, } }); // 公共部分(底部) var footer_navigation_template = vue.extend({ name: 'footer-navigation', //组件名称(keep-alive缓存需要本参数) template: '#footer-navigation-template', data: function (){ return { friendlylinks: [], otherlinks: [], officialaccountqrcodepic: '', websitefiling: '', headofficeaddress: '', currentyear: new date().getfullyear(), }; }, created: function (){ // 非空判断 if(isnotnull(this.$store.state.allcommonbasicinfo)){ // 设置所有共用基础信息 this.setallcommonbasicinfo(this.$store.state.allcommonbasicinfo); } }, mounted: function (){ }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, watch: { // 监听数据 '$store.state.allcommonbasicinfo': function (newname, oldname){ // 设置所有共用基础信息 this.setallcommonbasicinfo(newname); } }, methods: { // 设置所有共用基础信息 setallcommonbasicinfo: function (allcommonbasicinfo){ // 获取数据 let basiclinklist = allcommonbasicinfo.basiclinklist; let basicinfolist = allcommonbasicinfo.basicinfolist; let basicpictutrelist = allcommonbasicinfo.basicpictutrelist; // 数组过滤 this.friendlylinks = basiclinklist.filter(item => item.type == 0); this.otherlinks = basiclinklist.filter(item => item.type == 1); // 数组查找 this.officialaccountqrcodepic = basicpictutrelist.find(item => item.name == "公众号二维码").pic; this.websitefiling = basicinfolist.find(item => item.name == "网站备案").content; this.headofficeaddress = basicinfolist.find(item => item.name == "总部地址").content; }, } }); // 公共部分(中间) var common_template = vue.extend({ name: 'common', //组件名称(keep-alive缓存需要本参数) template: '#common-template', data: function (){ return { aboutefongpic: '', }; }, created: function (){ // 非空判断 if(isnotnull(this.$store.state.basicpictutrelist)){ // 设置所有子页面的banner图片 this.setbasicpictutrelist(this.$store.state.basicpictutrelist); } }, mounted: function (){ }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, watch: { // 监听数据 '$store.state.basicpictutrelist': function (newname, oldname){ // 设置所有子页面的banner图片 this.setbasicpictutrelist(newname); } }, methods: { // 关于一方路由跳转 routerjumpclick: function (event, path){ // 禁止路由重复跳转 if(router.currentroute.path.substring(1) == path){ return; } // 路由跳转 this.$router.push({ path: path, }); }, // 设置所有子页面的banner图片 setbasicpictutrelist: function (basicpictutrelist){ // 数组查找 let basicpictutre = basicpictutrelist.find(item => item.name == "关于一方"); // 赋值数据 this.aboutefongpic = basicpictutre.pic; }, } }); // 公司简介组件 var intro_template = vue.extend({ name: 'intro', //组件名称(keep-alive缓存需要本参数) template: '#intro-template', data: function (){ return { aboutcompanyintroductionlist: [], aboutproductionbaselist: [], showroutercomponent: false, keepscrollhtml: 0, }; }, created: function (){ // 设置滚动条位置 this.keepscrollhtml = this.$store.state.keepscrollhtml; // 查询公司简介 this.selectintro(); }, mounted: function (){ }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, methods: { // 查询公司简介 selectintro: function (){ // 请求服务端 $ajax.get("aboutpage/selectintro").then(response => { // 非空判断 if(isnotnull(response) && isnotnull(response.data)){ // 获取对象 let data = response.data; // 赋值数据 this.aboutcompanyintroductionlist = data.aboutcompanyintroductionlist; this.aboutproductionbaselist = data.aboutproductionbaselist; } // 显示路由组件 this.showroutercomponent = true; // 异步更新 this.$nexttick(() => { // 滚动到指定位置 document.queryselector("html").scrolltop = this.keepscrollhtml; }); }).catch(error => { console.log(error); }); }, } }); // 企业荣誉组件 var honor_template = vue.extend({ name: 'honor', //组件名称(keep-alive缓存需要本参数) template: '#honor-template', data: function (){ return { abouthonorlist: [], showroutercomponent: false, keepscrollhtml: 0, }; }, created: function (){ // 设置滚动条位置 this.keepscrollhtml = this.$store.state.keepscrollhtml; // 查询企业荣誉 this.selecthonor(); }, mounted: function (){ }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, methods: { // 查询企业荣誉 selecthonor: function (){ // 请求服务端 $ajax.get("aboutpage/selecthonor").then(response => { // 非空判断 if(isnotnull(response) && isnotnull(response.data)){ // 赋值数据 this.abouthonorlist = response.data; // 异步更新 this.$nexttick(() => { // 图片动态展示 new viewer(document.getelementbyid('my-photo-layer'),{ interval:3000, title: function(image) { return image.alt + ' (' + (this.index + 1) + '/' + this.length + ')'; } }); }); } // 显示路由组件 this.showroutercomponent = true; // 异步更新 this.$nexttick(() => { // 滚动到指定位置 document.queryselector("html").scrolltop = this.keepscrollhtml; }); }).catch(error => { console.log(error); }); }, } }); // 大事记组件 var history_template = vue.extend({ name: 'history', //组件名称(keep-alive缓存需要本参数) template: '#history-template', data: function (){ return { aboutdashijilist: [], showroutercomponent: false, keepscrollhtml: 0, }; }, created: function (){ // 设置滚动条位置 this.keepscrollhtml = this.$store.state.keepscrollhtml; // 查询大事记 this.selecthistory(); }, mounted: function (){ }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, methods: { // 查询大事记 selecthistory: function (){ // 请求服务端 $ajax.get("aboutpage/selecthistory").then(response => { // 非空判断 if(isnotnull(response) && isnotnull(response.data)){ // 赋值数据 this.aboutdashijilist = response.data; } // 显示路由组件 this.showroutercomponent = true; // 异步更新 this.$nexttick(() => { // 滚动到指定位置 document.queryselector("html").scrolltop = this.keepscrollhtml; }); }).catch(error => { console.log(error); }); }, } }); // 新闻中心组件 var news_template = vue.extend({ name: 'news', //组件名称(keep-alive缓存需要本参数) template: '#news-template', data: function (){ return { currentpage: 1, totalpage: 0, pagesize: 5, aboutcompanynewsmap: [], searchword: '', showroutercomponent: false, keepscrollhtml: 0, }; }, created: function (){ // 设置滚动条位置 this.keepscrollhtml = this.$store.state.keepscrollhtml; // 查询新闻中心 this.selectnews(true); }, mounted: function (){ }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, watch: { // 监听数据 currentpage: function (newname, oldname){ // 异步更新 this.$nexttick(() => { let body = $('html,body'); let scroll = $('.my-main-box').first(); body.animate({scrolltop:scroll.offset().top-95}, 500); }); }, // 监听数据 searchword: function (newname, oldname){ // 非空判断 if(isnull(newname) && isnotnull(oldname)){ // 初始化数据 this.pagesize = 5; this.currentpage = 1; // 查询新闻中心 this.selectnews(false); } } }, methods: { // 查询新闻中心 selectnews: function (isboolflag){ let params = {}; // 查询条件 params["searchword"] = this.searchword; // 当前页码 params["pagenum"] = this.currentpage; // 当前记录数 params["pagesize"] = this.pagesize; // 请求服务端 $ajax.get("aboutpage/selectnews", { params: params }).then(response => { // 非空判断 if(isnotnull(response) && isnotnull(response.data)){ // 遍历集合 for(let key in response.data){ // 赋值数据 this.totalpage = number(key); this.aboutcompanynewsmap = response.data[key]; } } // 显示路由组件 this.showroutercomponent = true; // 条件判断 if(isboolflag){ // 异步更新 this.$nexttick(() => { // 滚动到指定位置 document.queryselector("html").scrolltop = this.keepscrollhtml; }); } }).catch(error => { console.log(error); }); }, // 搜索新闻中心 searchnewshandler: function (){ // 非空判断 if(isnotnull(this.searchword)){ // 查询新闻中心 this.selectnews(false); } }, // 改变每页条数 handlesizechange: function (val){ this.pagesize = val; // 查询新闻中心 this.selectnews(false); }, // 改变当前页数 handlecurrentchange: function (val){ this.currentpage = val; // 查询新闻中心 this.selectnews(false); }, } }); // 企业宣传片组件 var publicity_template = vue.extend({ name: 'publicity', //组件名称(keep-alive缓存需要本参数) template: '#publicity-template', data: function (){ return { aboutvideolist: [], showroutercomponent: false, keepscrollhtml: 0, }; }, created: function (){ // 设置滚动条位置 this.keepscrollhtml = this.$store.state.keepscrollhtml; // 查询企业宣传片 this.selectpublicity(); }, mounted: function (){ // 初始化layui layui.use("layer", function(){ // 定义变量 let layer = layui.layer; // 宣传视频提示 $(".publicity-list li a").click(function(){ // 条件判断 if($(this).data("isplay") == 0){ // 点击提示 layer.msg('更新中,如有需要,请联系我们。', {time: 2000}); } }); }); }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, methods: { // 查询企业宣传片 selectpublicity: function (){ // 请求服务端 $ajax.get("aboutpage/selectpublicity").then(response => { // 非空判断 if(isnotnull(response) && isnotnull(response.data)){ // 赋值数据 this.aboutvideolist = response.data; // 异步更新 this.$nexttick(() => { // 获取节点 let elements = document.getelementsbyclassname("publicity-video-player"); // 遍历数组 for(let i = 0,len = elements.length;i < len;i ++){ // 初始化页面的视频播放器 new dplayer({ volume: 0.5, container: elements[i], video: { url: elements[i].getattribute("data-video-src"), }, }); } }); } // 显示路由组件 this.showroutercomponent = true; // 异步更新 this.$nexttick(() => { // 滚动到指定位置 document.queryselector("html").scrolltop = this.keepscrollhtml; }); }).catch(error => { console.log(error); }); }, // 初始化页面的视频播放器 loadvideoplayer: function (){ // 遍历标签 $(".iframevideo").each(function(index01) { // 定义变量 let currentthis = $(this); // 加载视频播放器 $(".iframevideo").contents().find("section").each(function(index02) { // 条件判断 if(index01 == index02){ // 设置标签属性 $(this).attr("data-title",currentthis.data('title')); $(this).attr("data-video",currentthis.data('video')); } }); }); // 手动触发点击事件 $(".iframevideo").contents().find(".getdata").trigger("click"); } } }); // 企业资质组件 var qualification_template = vue.extend({ name: 'qualification', //组件名称(keep-alive缓存需要本参数) template: '#qualification-template', data: function (){ return { aboutinfolist: [], showroutercomponent: false, keepscrollhtml: 0, }; }, created: function (){ // 设置滚动条位置 this.keepscrollhtml = this.$store.state.keepscrollhtml; // 查询企业资质 this.selectqualification(); }, mounted: function (){ }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, methods: { // 查询企业资质 selectqualification: function (){ // 请求服务端 $ajax.get("aboutpage/selectqualification").then(response => { // 非空判断 if(isnotnull(response) && isnotnull(response.data)){ // 赋值数据 this.aboutinfolist = response.data; } // 显示路由组件 this.showroutercomponent = true; // 异步更新 this.$nexttick(() => { // 滚动到指定位置 document.queryselector("html").scrolltop = this.keepscrollhtml; }); }).catch(error => { console.log(error); }); }, } }); // 社会责任组件 var duty_template = vue.extend({ name: 'duty', //组件名称(keep-alive缓存需要本参数) template: '#duty-template', data: function (){ return { aboutsocialresponsibilitylist: [], showroutercomponent: false, keepscrollhtml: 0, }; }, created: function (){ // 设置滚动条位置 this.keepscrollhtml = this.$store.state.keepscrollhtml; // 查询社会责任 this.selectduty(); }, mounted: function (){ }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, methods: { // 查询社会责任 selectduty: function (){ // 请求服务端 $ajax.get("aboutpage/selectduty").then(response => { // 非空判断 if(isnotnull(response) && isnotnull(response.data)){ // 赋值数据 this.aboutsocialresponsibilitylist = response.data; // 异步更新 this.$nexttick(() => { // 社会责任瀑布流 $(".dutyinfo-list").pinterest_grid({ no_columns: 3, padding_x: 15, padding_y: 15, margin_bottom: 50, single_column_breakpoint: 700 }); // 图片动态展示 new viewer(document.getelementbyid('my-duty-layer'),{ interval:3000, title: function(image) { return image.alt + ' (' + (this.index + 1) + '/' + this.length + ')'; } }); }); } // 显示路由组件 this.showroutercomponent = true; // 异步更新 this.$nexttick(() => { // 滚动到指定位置 document.queryselector("html").scrolltop = this.keepscrollhtml; }); }).catch(error => { console.log(error); }); }, } }); // 招投标公告组件 var tender_template = vue.extend({ name: 'tender', //组件名称(keep-alive缓存需要本参数) template: '#tender-template', data: function (){ return { currentpage: 1, totalpage: 0, pagesize: 5, abouttendernewsmap: [], searchword: '', showroutercomponent: false, keepscrollhtml: 0, }; }, created: function (){ // 设置滚动条位置 this.keepscrollhtml = this.$store.state.keepscrollhtml; // 查询招投标公告 this.selecttender(true); }, mounted: function (){ }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, watch: { // 监听数据 currentpage: function (newname, oldname){ // 异步更新 this.$nexttick(() => { let body = $('html,body'); let scroll = $('.my-main-box').first(); body.animate({scrolltop:scroll.offset().top-95}, 500); }); }, // 监听数据 searchword: function (newname, oldname){ // 非空判断 if(isnull(newname) && isnotnull(oldname)){ // 初始化数据 this.pagesize = 5; this.currentpage = 1; // 查询招投标公告 this.selecttender(false); } } }, methods: { // 查询招投标公告 selecttender: function (isboolflag){ let params = {}; // 查询条件 params["searchword"] = this.searchword; // 当前页码 params["pagenum"] = this.currentpage; // 当前记录数 params["pagesize"] = this.pagesize; // 请求服务端 $ajax.get("aboutpage/selecttender", { params: params }).then(response => { // 非空判断 if(isnotnull(response) && isnotnull(response.data)){ // 遍历集合 for(let key in response.data){ // 赋值数据 this.totalpage = number(key); this.abouttendernewsmap = response.data[key]; } } // 显示路由组件 this.showroutercomponent = true; // 条件判断 if(isboolflag){ // 异步更新 this.$nexttick(() => { // 滚动到指定位置 document.queryselector("html").scrolltop = this.keepscrollhtml; }); } }).catch(error => { console.log(error); }); }, // 搜索招投标公告 searchtenderhandler: function (){ // 非空判断 if(isnotnull(this.searchword)){ // 查询招投标公告 this.selecttender(false); } }, // 改变每页条数 handlesizechange: function (val){ this.pagesize = val; // 查询招投标公告 this.selecttender(false); }, // 改变当前页数 handlecurrentchange: function (val){ this.currentpage = val; // 查询招投标公告 this.selecttender(false); }, } }); // “新冠”战役组件 var battle_template = vue.extend({ name: 'battle', //组件名称(keep-alive缓存需要本参数) template: '#battle-template', data: function (){ return { showroutercomponent: false, keepscrollhtml: 0, }; }, created: function (){ // 设置滚动条位置 this.keepscrollhtml = this.$store.state.keepscrollhtml; }, mounted: function (){ // 显示路由组件 this.showroutercomponent = true; // 异步更新 this.$nexttick(() => { // 滚动到指定位置 document.queryselector("html").scrolltop = this.keepscrollhtml; }); }, beforerouteupdate: function (to, from, next) { // 路由放行 next(true); // 重置数据 object.assign(this.$data, this.$options.data()); }, methods: { } }); // 定义路由 var routes = [ {path: '/', redirect : '/intro'}, //router的重定向方法 {path: '/intro', component: intro_template}, //公司简介 {path: '/honor', component: honor_template}, //企业荣誉 {path: '/history', component: history_template}, //大事记 {path: '/news', component: news_template}, //新闻中心 {path: '/publicity', component: publicity_template}, //企业宣传片 {path: '/qualification', component: qualification_template}, //企业资质 {path: '/duty', component: duty_template}, //社会责任 {path: '/tender', component: tender_template}, //招投标公告 {path: '/battle', component: battle_template}, //“新冠”战役 ]; // 路由对象 var router = new vuerouter({ mode: 'hash', routes: routes }); // 路由守卫 router.beforeeach((to, from, next) => { // 条件判断 if(to.path == "/intro"){ // 动态标题 document.title = "广东一方制药有限公司 - 公司简介"; }else if(to.path == "/honor"){ // 动态标题 document.title = "广东一方制药有限公司 - 企业荣誉"; }else if(to.path == "/history"){ // 动态标题 document.title = "广东一方制药有限公司 - 大事记"; }else if(to.path == "/news"){ // 动态标题 document.title = "广东一方制药有限公司 - 新闻中心"; }else if(to.path == "/publicity"){ // 动态标题 document.title = "广东一方制药有限公司 - 企业宣传片"; }else if(to.path == "/qualification"){ // 动态标题 document.title = "广东一方制药有限公司 - 企业资质"; }else if(to.path == "/duty"){ // 动态标题 document.title = "广东一方制药有限公司 - 社会责任"; }else if(to.path == "/tender"){ // 动态标题 document.title = "广东一方制药有限公司 - 招投标公告"; }else if(to.path == "/battle"){ // 动态标题 document.title = "广东一方制药有限公司 - “新冠”战役"; } // 路由放行 next(); }); // 创建全局状态存储对象 var store = new vuex.store({ state: { keepscrollhtml: 0, basicpictutrelist: [], allcommonbasicinfo: [], }, mutations: { }, }); // 全局注册主键 vue.component('header-navigation', header_navigation_template); vue.component('footer-navigation', footer_navigation_template); vue.component('common', common_template); // 创建实例 var vm = new vue({ el: '#efongapp', store: store, router: router, created: function (){ // 查询所有子页面的banner图片 this.selectbasicpictutrelist(); // 查询所有共用基础信息 this.selectallcommonbasicinfo(); }, mounted: function (){ // 监听window滚动条 $(window).scroll(function() { // 获取当前滑动位置 var scrolltop = $(window).scrolltop(); // 滑动位置条件判断 if(scrolltop > 20){ $("header").addclass("shadow"); }else{ $("header").removeclass("shadow"); } // 滑动位置条件判断 if(scrolltop > 100){ $(".btn-returntop").fadein(500); }else{ $(".btn-returntop").fadeout(500); } }); // 回到顶部 $(".btn-returntop").click(function(){ $("html,body").animate({scrolltop: 0},'300'); }); // 开始监听 window.addeventlistener("scroll", this.handlescroll, true); }, destroyed: function () { // 取消监听 window.removeeventlistener('scroll', this.handlescroll, true); }, methods: { // 查询所有子页面的banner图片 selectbasicpictutrelist: function (){ // 请求服务端 $ajax.get("aboutpage/selectbasicpictutrelist").then(response => { // 非空判断 if(isnotnull(response) && isnotnull(response.data)){ // 设置所有子页面的banner图片 this.$store.state.basicpictutrelist = response.data; } }).catch(error => { console.log(error); }); }, // 查询所有共用基础信息 selectallcommonbasicinfo: function (){ // 请求服务端 $ajax.get("aboutpage/selectallcommonbasicinfo").then(response => { // 非空判断 if(isnotnull(response) && isnotnull(response.data)){ // 设置所有共用基础信息 this.$store.state.allcommonbasicinfo = response.data; } }).catch(error => { console.log(error); }); }, // 监听页面滚动条 handlescroll: function (){ // 异步更新 this.$nexttick(() => { // 记录滚动条位置 this.$store.state.keepscrollhtml = document.queryselector("html").scrolltop; }); }, } });