123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215 |
- var recommendation = new Vue({
- el: "#Recommendation",
- mixins: [cmSysVitaMixins,searchMixins],
- data: {
- status: {
- 'isDocument': 0, // 文件
- 'isSelected': 1, // 精选
- 'isNotice': 2, // 公告
- },
- state: null,
- params: {
- size: 10,
- num: 1,
- typeId: '',
- labelId: '',
- keyword: '',
- status: 1,
- startDate: '',
- endDate: '',
- productFlag: 1, // 是否统计关键词 1 统计 0 不统计
- linkageFlag: 0, // 关键词来源是否为用户搜索 0 是 1 不是
- selectDataRoutes: 1 // 最新 最早
- },
- listData: [],
- articlerecommendationData: [],
- listRecord: 0,
- productRecord: 0,
- productList: [],
- pageInput: '1',
- keyword: '',
- isRossShow: false,
- stateObj: {},
- noMore: true,
- },
- computed: {
- pageTotal: function () {
- let total = Math.ceil(this.listRecord / this.params.size);
- return total > 0 ? total : 1;
- },
- showPageBtn: function () {
- let total = Math.ceil(this.listRecord / this.params.size);
- total = total > 0 ? total : 1;
- let index = Number(this.params.num), arr = [];
- if (total <= 6) {
- for (let i = 1; i <= total; i++) {
- arr.push(i);
- }
- return arr;
- }
- if (index <= 3) return [1, 2, 3, 4, 5, 0, total];
- if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total];
- return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total];
- },
- },
- watch: {
- 'window.location.pathname': {
- handler() {
- const query = window.location.search.split('?')[1]
- this.state = this.status[query]
- },
- deep: true,
- immediate: true
- }
- },
- filters: {
- filterDate(str) {
- return str.substring(0, 11)
- },
- },
- mounted() {
- this.openFullScreen1()
- this.initData()
- },
- methods: {
- openFullScreen1() {
- const _self = this
- const loading = this.$loading({
- lock: true,
- text: '',
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.2)'
- });
- setTimeout(() => {
- _self.isLoading = true;
- loading.close();
- }, 500);
- },
- initData() {
- if (this.state === 2) {
- this.getNewList()
- } else {
- this.getArticlerecommendation(this.state)
- }
- },
- getArticlerecommendation: function (id, num) {
- var _self = this;
- if (isPC) {
- let paramsArr = window.location.pathname.split(".")[0].split("-");
- this.params.num = paramsArr[2]
- $.getJSON("/info/articlerecommendation/" + id + "/" + this.params.num, {}, function (r) {
- if (r.code === 0 && r.data) {
- _self.stateObj = r.data
- _self.articlerecommendationData = r.data.results;
- _self.listRecord = r.data.totalRecord
- }
- });
- } else {
- this.params.num = num || '1'
- $.getJSON("/info/articlerecommendation/" + id + "/" + this.params.num, {}, function (r) {
- console.log(r.data)
- if (r.code === 0 && r.data) {
- _self.stateObj = r.data
- _self.articlerecommendationData = [..._self.articlerecommendationData, ...r.data.results];
- _self.listRecord = r.data.totalRecord
- }
- });
- }
- },
- 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 (this.state===2) {
- if (this.params.num < this.pageTotal) { // 获取列表数据
- this.params.num = num
- this.getNewList(num);
- } else { //到底了
- this.noMore = false;
- }
- } else {
- this.params.num = num;
- this.getArticlerecommendation(this.state, num)
- if (num === this.stateObj.totalPage) {
- this.noMore = false;
- }
- }
- },
- // 页码链接处理
- 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;
- }
- },
- //页面跳转
- changeLink() {
- console.log(this.pageInput)
- if (this.state === 1) {
- window.location.href = '/info/articlerecommendation-1-' + this.pageInput + '.html?isSelected'
- } else {
- window.location.href = '/info/articlerecommendation-0-' + this.pageInput + '.html?isDocument'
- }
- },
- // 过滤标签
- filterTab(str) {
- return str.replace(/<[^>]+>/g, '')
- },
- // 数组
- filterArr(str) {
- return str.split(',')
- },
- // 链接跳转
- handleTramp(id) {
- if (this.state === 2) {
- window.location.href = '/news/details.html?id=' + id
- } else {
- window.location.href = '/info/detail-' + id + '-1.html'
- }
- },
- // 文件链接跳转
- handleFileUrl(id) {
- window.location.href = `/product-${id}.html?tabsIndex=4`
- // const fileUrl = url.split('?')[0]
- // let index = fileUrl.lastIndexOf('.');
- // let suffix = fileUrl.substring(index);
- // if (suffix === '.doc' || suffix === '.ppt' || suffix === '.pptx' || suffix === '.docx') {
- // window.open('https://view.officeapps.live.com/op/view.aspx?src=' + encodeURIComponent(url), '_black') // 下载
- // } else {
- // window.open(fileUrl, '_blank')
- // }
- }
- }
- })
|