import{_ as t,r as a,aQ as e,n as s,b as i,d as l,p as n,w as o,i as d,o as r,f as u,k as c,t as h,e as _,y as m,F as f,D as p,C as g}from"./index-2PZN6pGH.js";import{_ as b}from"./uni-load-more.BMea_02e.js";import{d as v}from"./util.BQsFLuvY.js";const D=t({data:()=>({banner:{},listData:[],last_id:"",reload:!1,status:"more",adpid:"",contentText:{contentdown:"上拉加载更多",contentrefresh:"加载中",contentnomore:"没有更多"}}),onLoad(){this.adpid=this.$adpid,this.getBanner(),this.getList()},onPullDownRefresh(){this.reload=!0,this.last_id="",this.getBanner(),this.getList()},onReachBottom(){this.status="more",this.getList()},methods:{getBanner(){a({url:"https://unidemo.dcloud.net.cn/api/banner/36kr",data:{column:"id,post_id,title,author_name,cover,published_at"},success:t=>{e(),200==t.statusCode&&(this.banner=t.data)},fail:(t,a)=>{console.log("fail"+JSON.stringify(t))}})},getList(){var t={column:"id,post_id,title,author_name,cover,published_at"};this.last_id&&(this.status="loading",t.minId=this.last_id,t.time=(new Date).getTime()+"",t.pageSize=10),a({url:"https://unidemo.dcloud.net.cn/api/news",data:t,success:t=>{if(200==t.statusCode){let a=this.setTime(t.data);this.listData=this.reload?a:this.listData.concat(a),this.last_id=a[a.length-1].id,this.reload=!1}},fail:(t,a)=>{console.log("fail"+JSON.stringify(t))}})},goDetail:function(t){let a={author_name:t.author_name,cover:t.cover,id:t.id,post_id:t.post_id,published_at:t.published_at,title:t.title};s({url:"../list2detail-detail/list2detail-detail?detailDate="+encodeURIComponent(JSON.stringify(a))})},setTime:function(t){var a=[];return t.forEach((t=>{a.push({author_name:t.author_name,cover:t.cover,id:t.id,post_id:t.post_id,published_at:v.format(t.published_at),title:t.title})})),a},aderror(t){console.log("aderror: "+JSON.stringify(t.detail))}}},[["render",function(t,a,e,s,v,D){const x=p,y=d,C=g,k=i(l("uni-load-more"),b);return r(),n(y,null,{default:o((()=>[u(y,{class:"banner",onClick:a[0]||(a[0]=t=>D.goDetail(v.banner))},{default:o((()=>[u(x,{class:"banner-img",src:v.banner.cover},null,8,["src"]),u(y,{class:"banner-title"},{default:o((()=>[c(h(v.banner.title),1)])),_:1})])),_:1}),u(y,{class:"uni-list"},{default:o((()=>[(r(!0),_(f,null,m(v.listData,((t,a)=>(r(),n(y,{key:a,class:"uni-list-cell","hover-class":"uni-list-cell-hover",onClick:a=>D.goDetail(t)},{default:o((()=>[u(y,{class:"uni-media-list"},{default:o((()=>[u(x,{class:"uni-media-list-logo",src:t.cover},null,8,["src"]),u(y,{class:"uni-media-list-body"},{default:o((()=>[u(y,{class:"uni-media-list-text-top"},{default:o((()=>[c(h(t.title),1)])),_:2},1024),u(y,{class:"uni-media-list-text-bottom"},{default:o((()=>[u(C,null,{default:o((()=>[c(h(t.author_name),1)])),_:2},1024),u(C,null,{default:o((()=>[c(h(t.published_at),1)])),_:2},1024)])),_:2},1024)])),_:2},1024)])),_:2},1024)])),_:2},1032,["onClick"])))),128))])),_:1}),u(k,{status:v.status,"icon-size":16,"content-text":v.contentText},null,8,["status","content-text"])])),_:1})}],["__scopeId","data-v-6761830d"]]);export{D as default};
