|
@@ -1,4 +1,4 @@
|
|
|
-let Recommendation = new Vue({
|
|
|
+var recommendation = new Vue({
|
|
|
el: "#Recommendation",
|
|
|
data: {
|
|
|
status: {
|
|
@@ -8,7 +8,7 @@ let Recommendation = new Vue({
|
|
|
},
|
|
|
state: null,
|
|
|
params: {
|
|
|
- size: 8,
|
|
|
+ size: 20,
|
|
|
num: 1,
|
|
|
typeId: '',
|
|
|
labelId: '',
|
|
@@ -30,15 +30,15 @@ let Recommendation = new Vue({
|
|
|
},
|
|
|
computed: {
|
|
|
pageTotal: function () {
|
|
|
- var total = Math.ceil(this.listRecord / this.params.size);
|
|
|
+ let total = Math.ceil(this.listRecord / this.params.size);
|
|
|
return total > 0 ? total : 1;
|
|
|
},
|
|
|
showPageBtn: function () {
|
|
|
- var total = Math.ceil(this.listRecord / this.params.size);
|
|
|
+ let total = Math.ceil(this.listRecord / this.params.size);
|
|
|
total = total > 0 ? total : 1;
|
|
|
- var index = this.params.num, arr = [];
|
|
|
+ let index = this.params.num, arr = [];
|
|
|
if (total <= 6) {
|
|
|
- for (var i = 1; i <= total; i++) {
|
|
|
+ for (let i = 1; i <= total; i++) {
|
|
|
arr.push(i);
|
|
|
}
|
|
|
return arr;
|
|
@@ -53,14 +53,71 @@ let Recommendation = new Vue({
|
|
|
handler() {
|
|
|
const query = window.location.search.split('?')[1]
|
|
|
this.state = this.status[query]
|
|
|
- console.log(this.state)
|
|
|
},
|
|
|
deep: true,
|
|
|
immediate: true
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- console.log("这个是更多")
|
|
|
+ this.initData()
|
|
|
},
|
|
|
- methods: {}
|
|
|
+ methods: {
|
|
|
+ initData() {
|
|
|
+ if (this.state===2) {
|
|
|
+ this.getNewList()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getNewList(num) {
|
|
|
+ if (isPC) {
|
|
|
+ let paramsArr = window.location.pathname.split(".")[0].split("-");
|
|
|
+ this.params.num = paramsArr[2]
|
|
|
+ const params = {
|
|
|
+ pageSize: this.params.size,
|
|
|
+ pageNum: this.params.num
|
|
|
+ }
|
|
|
+ PublicApi.GetNewsList(params, ({data}) => {
|
|
|
+ this.listRecord = data.totalRecord
|
|
|
+ this.listData = data.results
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.params.num = num || '1'
|
|
|
+ const params = {
|
|
|
+ pageSize: this.params.size,
|
|
|
+ pageNum: this.params.num
|
|
|
+ }
|
|
|
+ PublicApi.GetNewsList(params, ({data}) => {
|
|
|
+ this.listRecord = data.totalRecord
|
|
|
+ this.listData = [...this.listData, ...data.results]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //获取更多数据
|
|
|
+ handleMore (num) {
|
|
|
+ if (state===2) {
|
|
|
+ if (this.params.num < this.pageTotal) { // 获取列表数据
|
|
|
+ this.params.num = this.params.num + 1;
|
|
|
+ this.getNewList(num);
|
|
|
+ } else { //到底了
|
|
|
+ this.noMore = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 页码链接处理
|
|
|
+ paginationUrl (pageNum) {
|
|
|
+ let path = window.location.href;
|
|
|
+ const query = window.location.search
|
|
|
+ let paramsArr = window.location.pathname.split(".")[0].split("-");
|
|
|
+ let pageId = paramsArr.length >= 1 ? paramsArr[1] : '';
|
|
|
+ path = '/info/articlerecommendation-' + pageId + '-' + pageNum + '.html';
|
|
|
+ return path + query;
|
|
|
+ },
|
|
|
+ // 页面修改
|
|
|
+ checkNum: function () {
|
|
|
+ if (this.pageInput > this.pageTotal) {
|
|
|
+ this.pageInput = this.pageTotal;
|
|
|
+ } else if (this.pageInput < 1) {
|
|
|
+ this.pageInput = 1;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
})
|