123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- // pages/publics/interpretation/interpretation.js
- import {
- imgUrl
- } from "../../api/request"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- // 图片前缀
- imgUrl: imgUrl,
- interpretationList: [{
- title: '文字解读',
- channelId: '222894'
- },
- {
- title: '图文解读',
- channelId: '158049'
- },
- {
- title: '视频解读',
- channelId: '239780'
- },
- {
- title: '媒体解读',
- channelId: '298206'
- }
- ],
- currentTab: 0,
- interpretationListInfo: [],
- page: 1
- },
- // 切换
- tabNav(e) {
- let currentTab = e.currentTarget.dataset.index
- this.setData({
- currentTab
- })
- },
- // 切换
- handleSwiper(e) {
- let {
- current,
- source
- } = e.detail
- if (source === 'autoplay' || source === 'touch') {
- const currentTab = current
- this.setData({
- currentTab
- })
- }
- this.setData({
- interpretationListInfo: [],
- page: 1
- })
- // if (current == 2 || current ==3) {
- // return;
- // }
- this.getInterpretationById();
- },
- // 获取政策解读列表
- getInterpretationById() {
- wx.showToast({
- title: '加载中',
- icon: 'loading',
- duration: 1500
- })
- wx.request({
- url: 'https://data.cqna.gov.cn/mini/hlw/send?page=' + this.data.page + '&limit=10&channelId=' + this.data.interpretationList[this.data.currentTab].channelId,
- method: 'GET',
- success: res => {
-
- if (res.data.data.DATA.length > 0) {
- let temp = res.data.data.DATA;
- if (this.data.currentTab == 1||this.data.currentTab == 2) {
- // 图文解读
- for (let i=0;i<temp.length;i++) {
- // 截取logo图片
- let url = temp[i].DOCPUBURL.substring(0, temp[i].DOCPUBURL.lastIndexOf("/") + 1)
- console.log(url);
- let logo = temp[i].LOGOURL.substring(temp[i].LOGOURL.lastIndexOf("FileName=") + "fileName=".length)
- console.log(logo);
- if (logo==''||logo==null) {
- temp[i].logoImg = '../../images/zw.jpg'
- }else{
- temp[i].logoImg = url + logo
- }
- }
- }
- temp = this.data.interpretationListInfo.concat(temp);
- this.setData({
- interpretationListInfo: temp
- })
- wx.hideToast();
- } else {
- wx.showToast({
- title: '已加载全部数据',
- icon: 'success',
- duration: 1000
- })
- }
- }
- })
- },
- gotoDetail(e) {
- wx.navigateTo({
- url: '/pages/publics/governmentArticlesDetail/governmentArticlesDetail?channelId=' + e.currentTarget.dataset.channelid + '&isFile=false'
- })
- },
- gotoWeb(e) {
- console.log(e);
- wx.navigateTo({
- url: '/pages/web/web?url=' + e.currentTarget.dataset.url
- })
- },
- gotoDetailByDocId(e) {
- let url = e.currentTarget.dataset.url
- url = url.substring(0, url.lastIndexOf("/") + 1)
- wx.navigateTo({
- url: '/pages/publics/governmentArticlesDetail/governmentArticlesDetail?channelId=' + e.currentTarget.dataset.channelid + '&docId=' + e.currentTarget.dataset.docid + '&url=' + url + '&isFile=false&isPic=true'
- })
- },
- // 触底
- scrollBottom(e) {
- this.setData({
- page: this.data.page + 1
- })
- this.getInterpretationById()
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- this.getInterpretationById();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- return {
- title: '政策解读'
- }
- }
- })
|