// pages/articlDetail/articlDetail.js import { imgUrl } from "../api/request" import { info } from "../api/index-api2" const IMGPATH = "https://www.cqna.gov.cn/data/mini/hlw/forward?url=" // const imageCdn = 'https://tdesign.gtimg.com/site/swiper'; // const swiperList = []; Page({ /** * 页面的初始数据 */ data: { imgUrl: imgUrl, chnlid: "", docid: "", data: {}, current: 0, autoplay: true, duration: 500, interval: 5000, paginationPosition: 'bottom-right', swiperList:[], navigation: { type: 'fraction' }, imgShow:true }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { wx.showLoading({ title: '页面加载中', }) this.setData({ chnlid: options.CHNLID, docid: options.DOCID }) this.initPage(); }, initPage() { info(this.data.chnlid, this.data.docid).then(res => { console.log(res); let swiperLists = []; if (res.result) { let imgs = res.data.DOCATTACHPICFIELD; if(imgs.length<=0&&res.data.THUMBFILES!=null&&res.data.THUMBFILES!=""){ let imgName = res.data.THUMBFILES.split(','); // /webpic/W0202210/W020221019/W020221019788334970636.jpg for (const imgOne of imgName) { let one = "/webpic" let two = "/"+imgOne.slice(0,8) console.log(two); let three = "/"+imgOne.slice(0,10)+"/" console.log(three); swiperLists.push(IMGPATH+one+two+three+imgOne) } }else{ for (const img of imgs) { if(img.APPFILEURL!=null&&img.APPFILEURL!=''){ swiperLists.push(IMGPATH+img.APPFILEURL); } } } console.log(swiperLists); if(swiperLists.length<=0){ this.setData({ imgShow:false }) } this.setData({ data: res.data, swiperList: swiperLists }) // wx.setNavigationBarTitle({ // title: res.data.DOCTITLE // }) wx.hideLoading(); } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage(res) { return { title: this.data.data.DOCTITLE }; }, })