// 定义一个名为 button-counter 的新组件 Vue.component('button-counter', { props: ['title'], data () { return { count: 0 } }, methods: { addCount() { this.count++ } }, template: '' }) var app = new Vue({ el: '#app', data: { //公共 id: null, columnList:[], bbb:'', //首页 homeList: [], status: false, //解决方案 array: [], //解决方案旧 solutionArray: [], //解决方案详情数据 solutionTypes: [], //解决方案类型 // 新聞 news: [], goPage: 1, one_page_size: 3, currentPageNum: 1, totalPageNum: 1, totalPageSzie: 4, loading: true, //新闻详情 articleInfo: {}, previousInfo: {}, nextInfo: {}, relativeArr: [], ariticle_id: 0 }, computed: { // 新闻详情旧 isNews: function() { return (this.articleInfo.type == 1); }, hasPrevious: function() { return Object.keys(this.previousInfo).length > 0; }, hasNext: function() { return Object.keys(this.nextInfo).length > 0; } }, created: function () { this.ariticle_id = this.getQueryVariable('id') this.title = this.getQueryVariable('title')?this.getQueryVariable('title'):'' alert(this.title) }, mounted: function () { _this = this this.getColumnData() }, methods: { //获取栏目 getColumnData() { $.ajax({ type: 'get', dataType: 'json', url: window.FQDN2 + 'siteCategory/siteCategoryList', }).done(function (res) { _this.columnList=res.data; _this.bbb=window.location.pathname for (let i = 0; i < res.data.length; i++) { // console.log(res.data[i].sname) // console.log(window.location.pathname) if (res.data[i].categoryName == '首页'&& window.location.pathname=='/index.html') { //首页旧 jQuery.ajax({ type: 'POST', dataType: 'json', url: window.FQDN + 'Index/index', }).done(function (res) { _this.homeList = res _this.status = true }).fail(function (err) {}); } if (res.data[i].categoryName == '新闻动态'&& window.location.pathname=='/news/read.html') { console.log(res.data[i].categoryName) //新闻详情旧 jQuery.ajax({ type: 'POST', dataType: 'json', url: window.FQDN + 'agw/journalism_details', data: { id: 154 } }).done(function(res) { if (!res.msg) { return; } _this.loading = false; _this.articleInfo = res; _this.relativeArr = res.related; console.log(_this.relativeArr) if (res.previous != null) { _this.previousInfo = res.previous; } if (res.next != null) { _this.nextInfo = res.next; } }).fail(function(err) {}); } if (res.data[i].children.length > 0) { if (res.data[i].categoryName == '解决方案'&& window.location.pathname.indexOf('solution')>-1) { _this.solutionTypes = res.data[i].children _this.id = _this.getQueryVariable('id') ? _this.getQueryVariable('id') : _this.solutionTypes[0].id; _this.getArticalData(_this.id ? _this.id : _this.solutionTypes[0].id) //解决方案旧 $.ajax({ type: 'POST', dataType: 'json', url: window.FQDN + 'Solution/index', data: { id: '1' } }).done(function (arr) { _this.array = arr; console.log(_this.array) }).fail(function (err) {}); } if (res.data[i].categoryName == '新闻动态'&& window.location.pathname.indexOf('news')>-1) { _this.solutionTypes = res.data[i].children _this.id = _this.getQueryVariable('id') ? _this.getQueryVariable('id') : _this.solutionTypes[0].id; _this.getArticalData(_this.id ? _this.id : _this.solutionTypes[0].id) } } } }) }, //获取内容 getArticalData(param) { $.ajax({ type: 'GET', dataType: 'json', url: window.FQDN2 + 'siteArticle/siteArticleList', data: { categoryid: param, pageNum:_this.currentPageNum, pageSize:_this.one_page_size, title:_this.title } }).done(function (res) { var aa = res.data.records aa.sort(_this.compare("lmtitle")) _this.loading = false; _this.solutionArray = aa; _this.totalPageSzie = res.data.total _this.totalPageNum = Math.ceil(res.data.total / res.data.size); console.log(aa) }).fail(function (err) {}); }, //类型点击 facilityClick(e, item) { this.id = item.id this.getArticalData(item.id) this.currentPageNum=1 // console.log(item.id) }, // 分页 oneInnerBox: function(param) { alert(param.title) window.location = "./read.html?id=" + param.id+'&title='+param.title; // window.location = "./read.html?id=154" }, enterPage: function(res) { if (this.goPage >= 1 && this.goPage <= this.totalPageNum) { this.currentPageNum = this.goPage this.getArticalData(this.id ? this.id : this.solutionTypes[0].id) } else { this.goPage = 1 alert('输入页数有误!') } }, currentChange: function(res) { this.currentPageNum = res this.getArticalData(this.id ? this.id : this.solutionTypes[0].id) }, // 排序 compare(property) { return function (a, b) { var value1 = a[property]; var value2 = b[property]; return value1 - value2; } }, //获取路由参数 getQueryVariable: function (variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return (false); } } });