<template>
<dsf-datagrid class="news-list" :style='{height:"100%"}' :max-top-number="maxTopNumber" :top-props="'teas_jwgl_bjgl_nowbcsjy.sxrs'" ref='dsfDatagrid' :http-param="datagrid_httpParam" :background-color="'#fff'" :padding="padding" :margin="margin" :top-margin="[0,-15,0,-15]" :col="col" :limit="limit" :hasLoad="hasLoad" :hasRefresh="hasRefresh">
<template v-slot:search v-if="hasFilter">
<div>
<div class="ac-teacher-list-screen">
<div class="ac-tch-lst-screen-item" @click="changeTreeSelectPopupShow">
<dsf-icon name="quanbu" class="ac-tch-lst-screen-icon left"></dsf-icon>
<span class="ac-tch-lst-screen-fun">{{selcetText}}</span>
</div>
<div class="ac-tch-lst-screen-item" @click="onscreen('time')">
<dsf-sort :iconName="'最新'" :custom-sort='time'></dsf-sort>
</div>
<div class="ac-tch-lst-screen-item" @click="onscreen('browse')">
<dsf-sort :iconName="'最热'" :custom-sort='browse'></dsf-sort>
</div>
<div class="ac-tch-lst-screen-item" @click="onscreen('tags')">
<dsf-sort :iconName="'点赞量'" :custom-sort='tags'></dsf-sort>
</div>
</div>
<!-- <template v-if="bannerShow == true">
<div class="nestitle" @click="titletoDetail()">{{bannertitle}}</div>
<van-swipe :autoplay="2000" class="banners" @change="onChange">
<van-swipe-item v-for="(item, index) in bannerDate" :key="index" @click="toDetail(item['nc_news_nbsnews_ptxwsjy.id'])">
<van-image :src="getCover(item)" fit="fill" v-if="getCover(item)">
<template v-slot:loading>
<van-loading type="spinner" size="20" />
</template>
<template v-slot:error><img src="../../../../assets/images/defaultImage/file-read-18688.png" ></template>
</van-image>
<div class="txt">{{item['nc_news_nbsnews_ptxwsjy.cname']}}</div>
</van-swipe-item>
</van-swipe>
</template>
<div class="dsf-searchopts" v-if='choiceText.length>0'>
<span v-for="(obj,index) in choiceText" :key="index">
{{obj.text}}
<dsf-icon name='icon2' @click="deleteSerachV(obj,index)"></dsf-icon>
</span>
</div> -->
</div>
</template>
<template v-slot:top="item" v-if="maxTopNumber>0">
<div class="news-swiper-list" @click="toDetail(item.data['nc_news_nbsnews_ptxwsjy.id'])">
<div class="news-swiper-title">
<p>{{item.data['nc_news_xxlist.cname']}}</p>
</div>
<div class="news-swiper-img">
<img :src="getCover(item.data)" alt />
<p>
<span>{{item.data['nc_news_xxlist.cname']}}</span>
</p>
</div>
</div>
</template>
<template v-slot:default="item">
<div class="news-item" @click="toDetail(item.data['nc_news_nbsnews_ptxwsjy.id'])">
<div v-if="item.data['nc_news_nbsnews_ptxwsjy.lbpt_value'] == 2" class="news-list-img" :class="{'no-image':!getCover(item.data)}">
<van-image :src="getCover(item.data)" fit="fill" v-if="getCover(item.data)">
<template v-slot:loading>
<van-loading type="spinner" size="20" />
</template>
<template v-slot:error><img src="../../../../assets/images/defaultImage/file-read-18688.png" style="width:100%;height:100%"></template>
</van-image>
<div class="news-item-content">
<p>{{item.data['nc_news_nbsnews_ptxwsjy.cname']}}</p>
<p>
<span>{{item.data['nc_news_nbsnews_ptxwsjy.time']}}</span>
<span>
<dsf-icon class="yanjing-icon" name="yanjing"></dsf-icon>{{item.data['nc_news_nbsnews_ptxwsjy.browse']}}
</span>
</p>
</div>
</div>
</div>
</template>
</dsf-datagrid>
</template>
<script>
import { Image } from 'vant';
import { Lazyload } from 'vant';
import { dsfRouteView } from '@/dsf/components/dsfBase';
export default {
name: "newsList",
mixins: [dsfRouteView],
data() {
return {
Detailid:'',
bannerShow:true,
selcetText:'全部',
datagrid_search: '',
datagrid_httpParam: {
query: JSON.stringify({
"searchValue": ""
}),
order: JSON.stringify([]),
namespace: 'nc.news.nbsnews',
pageName: 'ptxwlist',
lmId:this.$route.query.articlelmId || ''
},
choiceText: [],
bannertitle:'',
bannerDate: [
{'cover':'https://img.yzcdn.cn/vant/apple-1.jpg'},
{'cover':'https://img.yzcdn.cn/vant/apple-.jpg'},
{'cover':'https://img.yzcdn.cn/vant/apple-2.jpg'}
],
time: '',
browse : '',
tags:'',
choiceData: [],
choiceText: [],
labelText: [],
choiceAllData: [],
typeText: [],
typeIds: [],
}
},
props: {
active: {
type: String,
default: '1',
},
maxTopNumber: {
type: Number,
default: 5,
},
col: {
type: [String, Number],
default: 1,
desc: '一列显示几个,暂支持1和2'
},
hasLoad: {
type: Boolean,
default: true,
desc: '是否有上拉加载'
},
hasRefresh: {
type: Boolean,
default: true,
desc: '是否有下拉刷新'
},
dataSource: {
type: String,
default: 'meta/list/data',
desc: '请求接口,可自定义'
},
curr: {
type: [String, Number],
default: 1,
desc: '从哪一页开始'
},
limit: {
type: [String, Number],
default: 12,
desc: '每页显示多少'
},
httpParam: {
type: Object,
default: function() {
return {}
},
desc: '接口参数'
},
hasFilter: {
type: Boolean,
default: true
},
padding: {
type: Array,
default() {
return [0, 15, 0, 15]
}
},
margin: {
type: Array,
default() {
return [0, 0, 0, 0]
}
}
},
computed: {},
created: function() {},
mounted: function() {
this.showbanner();
},
methods: {
getCover: function(item) {
let files = dsf.getUploadFileInfo(item['nc_news_nbsnews_ptxwsjy.cover']);
return dsf.config.webRoot + files[0].relativePath
},
query: function() {
},
toDetail(id) {
this.$router.push({
"path": "/recommend/newsDetail/" + id
})
},
titletoDetail(){
this.$router.push({
"path": "/recommend/newsDetail/" + this.Detailid
})
},
onscreen(who) {
let _this = this;
if(_this[who] == 'desc') {
_this[who] = 'asc'
} else {
_this[who] = 'desc'
}
this.queryOrder();
},
deleteSerachV(obj, index) {
},
changeTreeSelectPopupShow() {
this.$emit('selcetAll');
},
childreset(d) {
// let texts= d.name;
// if(texts.length>4){
// texts = texts.substr(0,3)+'...'
// }
// this.selcetText = texts;
this.datagrid_httpParam.lmId = d.dsfa_cms_cm_id;
this.$refs.dsfDatagrid.query();
this.showbanner();
},
onChange(index){
this.bannertitle = this.bannerDate[index]['nc_news_nbsnews_ptxwsjy.cname']
this.Detailid = this.bannerDate[index]['nc_news_nbsnews_ptxwsjy.id']
},
queryOrder() {
let order = [];
if (this.time!='') {
order.push({
code: 'time',
sort: this.time
})
}
if(this.browse){
order.push({
code: 'browse',
sort: this.browse
})
}
if(this.tags){
order.push({
code: 'tags',
sort: this.tags
})
}
this.datagrid_httpParam.order = JSON.stringify(order);
this.$refs.dsfDatagrid.query();
this.showbanner();
},
$refresh() {
this.query();
},
// 单独的banner
showbanner(){
console.log();
let loader = this.dsf.layer.loading();
let _id = this.$route.params.id;
let _this = this;
this.dsf.http
.get("meta/list/data", _this.datagrid_httpParam)
.done(d => {
this.dsf.layer.closeLoading(loader);
if (d.success && d.state ==20000) {
let sd = d.data;
let arr = [];
if(sd && sd.length>0){
for(var i=0,len=sd.length;i<len;i++){
//1为轮播
if( sd[i]['nc_news_nbsnews_ptxwsjy.lbpt_value'] == 1 ){
arr.push(sd[i])
}
}
}else{
_this.bannerShow = false;
}
if(arr && arr.length>0){
_this.bannerDate = arr;
_this.bannertitle = arr[0]['nc_news_nbsnews_ptxwsjy.cname']
_this.Detailid = arr[0]['nc_news_nbsnews_ptxwsjy.id']
_this.bannerShow = true;
}else{
_this.bannerShow = false;
}
} else {
this.dsf.layer.toast(d.message || "数据异常", false);
}
})
.error(response => {
_this.dsf.layer.toast(res.message, false);
});
},
UrlSearch() {
var name, value;
var str = location.href; //取得整个地址栏
var num = str.indexOf("?")
str = str.substr(num + 1); //取得所有参数 stringvar.substr(start [, length ]
var arr = str.split("&"); //各个参数放到数组里
for(var i = 0; i < arr.length; i++) {
num = arr[i].indexOf("=");
if(num > 0) {
name = arr[i].substring(0, num);
value = arr[i].substr(num + 1);
this[name] = decodeURI(value);
}
}
}
}
};
</script>
_this.dsf.$user.loginInfo.userId -------封装的-获取vuex的登录信息