var _defaultImg = './images/default-bg-image169.png'; var app = new Vue({ el: "#app", data: { defaultImg: _defaultImg, columnsData: [],//鏍忕洰鏁版嵁鍒楄〃 id: "", columnName: "", advRows: [],//骞垮憡浣 hotData: [],//褰撳墠鏍忕洰涓嬬殑鐑棬绋夸欢锛圱op10锛 gxlbData: [],//渚涢攢鑱旀挱鏁版嵁 }, created: function () { this.id = this.getUrlQueryPrams('id'); if (this.id) { this.getColumnsData(); this.getHotData(); this.getVideoAdvList();//鑾峰彇骞垮憡浣 this.getGXLBList(); } }, mounted: function () { var status = this.getUrlQueryPrams('status'); if (status) { setTimeout(function () { $('html').scrollTop(220); }, 3000); } }, methods: { //鑾峰彇瀛愭爮鐩拰鏍忕洰绋夸欢 getColumnsData: function () { var url = pageConfig.baseUrl + "/api/getSubColumns?&cid=" + this.id + "&type=2&containSubCols=0";//鑾峰彇鏉℃暟瀹氫箟锛 0锛?鏉★紱1锛 5鏉★紱2锛?0鏉★紱3锛?0鏉★紱4锛?00鏉 axios.get(url).then(function (results) { if (results.data && results.data.list && results.data.list.length > 0) { for (var i in results.data.list) { results.data.list[i].list = app.processArticles(results.data.list[i].list); } app.columnName = results.data.column.columnName; document.title = app.columnName + '_涓浗渚涢攢鍚堜綔缃?; app.columnsData = results.data.list; } else { app.$message.error(results.data.msg); } }).catch(function (error) { console.log(error); }); }, //鑾峰彇骞垮憡浣 getVideoAdvList: function () { var url = pageConfig.baseUrl + "/api/getArticles?cid=" + 4985 + "&rowNumber=0&lastFileID=0&pageSize=4&containSubCols=0"; axios.get(url).then(function (result) { if (result.data.list) { app.advRows = app.processArticles(result.data.list); } }).catch(function (error) { console.log(error); }); }, //鑾峰彇渚涢攢鑱旀挱鏁版嵁 getGXLBList: function () { var url = pageConfig.baseUrl + "/api/getArticles?cid=" + 4873 + "&rowNumber=0&lastFileID=0&pageSize=4&containSubCols=1"; axios.get(url).then(function (result) { if (result.data.list) { result.data.list = app.processArticlesGX(result.data.list); app.gxlbData = result.data; } }).catch(function (error) { console.log(error); }); }, //鑾峰彇褰撳墠鏍忕洰涓嬬殑鐑棬绋夸欢 getHotData: function () { // var url = pageConfig.baseUrl + '/api/getHotList?cid=' + this.id + '&type=5&pageSize=20&containSubCols=1'; var url = pageConfig.baseUrl + '/api/getArticles?cid=' + this.id + '&containSubCols=1&type=4&aType=0&pageSize=20&rowNumber=0&lastFileID=0'; axios.get(url).then(function (results) { if (results.data && results.data.list && results.data.list.length > 0) { app.hotData = app.unique(app.processArticles(results.data.list)); } }).catch(function (error) { console.log(error); }); }, //鏈€鐑浠跺幓閲 unique: function (arr) { for (var i = 0; i < arr.length; i++) { for (var j = i + 1; j < arr.length; j++) { if (arr[i].title == arr[j].title) { //绗竴涓瓑鍚屼簬绗簩涓紝splice鏂规硶鍒犻櫎绗簩涓 arr.splice(j, 1); j--; } } } return arr; }, //鑾峰彇url鍙傛暟 getUrlQueryPrams: function (name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; }, //绋夸欢鏁版嵁澶勭悊 processArticles: function (list) { for (var i in list) { if (list[i].articleType == 3) {//閾炬帴绋夸欢 list[i].articleUrl = list[i].articleUrl; } else if (list[i].articleType == 4) {//涓撻绋夸欢 list[i].articleUrl = './special.html?cid=' + list[i].linkID; } else {//鍏朵粬绋夸欢 list[i].articleUrl = './news.html?aid=' + list[i].fileID; } } return list; }, //渚涢攢鐨勮烦杞湴鍧€ processArticlesGX: function (list) { for (var i in list) { if (list[i].articleType == 3) {//閾炬帴绋夸欢 list[i].articleUrl = list[i].articleUrl; } else if (list[i].articleType == 4) {//涓撻绋夸欢 list[i].articleUrl = 'http://www.zh-hz.com/news.html?aid=?cid=' + list[i].linkID + '&aid=' + list[i].fileID; } else {//鍏朵粬绋夸欢 list[i].articleUrl = 'http://www.zh-hz.com/news.html?aid=' + list[i].fileID; } } return list; } } })