|
|
|
// subpages/understandJs/pages/warning/warning.js
|
|
|
|
const api = require('../../../../utils/understandJs')
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
pageIndex: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
noticelist: [],
|
|
|
|
nodata: false,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
loadMoreVisible: false,
|
|
|
|
noticeCategory: '',//模块编码(政策导航-最热政策:notice_navigation_hot、了解锦水-印象:notice_impression、了解锦水-味道:notice_taste、政策导航-最新通知: notice_navigation_new、了解锦水-警示:notice_warning)
|
|
|
|
noticeContentNew:'',
|
|
|
|
swiperBannerList: [],
|
|
|
|
indicatorDots: false, //指示点
|
|
|
|
autoplay: true, //true,//自动播放
|
|
|
|
circular: true, //衔接滑动
|
|
|
|
interval: 5000, //自动播放间隔时长(ms)
|
|
|
|
duration: 500, //幻灯片切换时长(ms)
|
|
|
|
currentSwiper: 0,
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad: function (options) {
|
|
|
|
this.setData({
|
|
|
|
noticeCategory:options.modulecode
|
|
|
|
})
|
|
|
|
if(options.modulecode == 'notice_impression'){
|
|
|
|
wx.setNavigationBarTitle({
|
|
|
|
title: '锦水印象'
|
|
|
|
})
|
|
|
|
}else if(options.modulecode == 'notice_zcwsc'){
|
|
|
|
this.getBannerList('4')
|
|
|
|
wx.setNavigationBarTitle({
|
|
|
|
title: '众创卫生城'
|
|
|
|
})
|
|
|
|
}else if(options.modulecode == 'notice_aq'){
|
|
|
|
this.getBannerList('5')
|
|
|
|
wx.setNavigationBarTitle({
|
|
|
|
title: '安全365'
|
|
|
|
})
|
|
|
|
}else{
|
|
|
|
this.getBannerList('2')
|
|
|
|
wx.setNavigationBarTitle({
|
|
|
|
title: '锦水警事'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
this.noticelist()
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom: function () {
|
|
|
|
this.setData({
|
|
|
|
loadMoreVisible: true
|
|
|
|
})
|
|
|
|
if (this.data.loadMoreType === 'loading') {
|
|
|
|
this.setData({
|
|
|
|
pageIndex: this.data.pageIndex + 1,
|
|
|
|
pageSize: this.data.pageSize,
|
|
|
|
})
|
|
|
|
this.noticelist();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
noticelist() {
|
|
|
|
let that = this;
|
|
|
|
let params = {
|
|
|
|
pageIndex: that.data.pageIndex,
|
|
|
|
pageSize: that.data.pageSize,
|
|
|
|
noticeCategory: that.data.noticeCategory,
|
|
|
|
}
|
|
|
|
api.noticelist(params).then(function (res) { //了解锦水-模块管理接口
|
|
|
|
let noticelistObj = {}
|
|
|
|
let noticelistItem = []
|
|
|
|
for(var i = 0; i < res.data.length; i++){
|
|
|
|
noticelistObj= res.data[i]
|
|
|
|
noticelistObj.noticeContentNew = res.data[i].noticeContent.replace(/<img/gi, '<img style="display:none" ');
|
|
|
|
noticelistItem.push(noticelistObj)
|
|
|
|
}
|
|
|
|
that.setData({
|
|
|
|
noticelist: that.data.noticelist.concat(noticelistItem),
|
|
|
|
loadMoreType: res.data.length === that.data.pageSize ? 'loading' : 'none',
|
|
|
|
loadMoreVisible: res.data.length === that.data.pageSize ? false : true
|
|
|
|
})
|
|
|
|
if (that.data.noticelist.length == 0) {//没有值
|
|
|
|
that.setData({
|
|
|
|
nodata: true,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
loadMoreVisible: false,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}).catch(err => {
|
|
|
|
that.setData({
|
|
|
|
noticelist: [],
|
|
|
|
nodata: true,
|
|
|
|
loadMoreType: 'none',
|
|
|
|
loadMoreVisible: false,
|
|
|
|
})
|
|
|
|
console.log(err)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
//跳转倒详情页面
|
|
|
|
toDetail(e){
|
|
|
|
wx.navigateTo({
|
|
|
|
url: `../noticeDetail/noticeDetail?id=${e.currentTarget.dataset.id}&modulecode=${this.data.noticeCategory}`
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
getBannerList: function(bannerNum) {
|
|
|
|
let that = this
|
|
|
|
api.bannerList(bannerNum).then(function(res) {
|
|
|
|
// console.log('res==', res.data)
|
|
|
|
that.setData({
|
|
|
|
swiperBannerList: res.data
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
swiperChange: function(e) {
|
|
|
|
wx.createVideoContext('video'+this.data.currentSwiper).pause()
|
|
|
|
this.setData({
|
|
|
|
currentSwiper: e.detail.current,
|
|
|
|
autoplay: true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
bindplay() {
|
|
|
|
this.setData({
|
|
|
|
autoplay: false
|
|
|
|
})
|
|
|
|
wx.getNetworkType({
|
|
|
|
success (res) {
|
|
|
|
const networkType = res.networkType
|
|
|
|
if (res.networkType != 'wifi') {
|
|
|
|
wx.showToast({
|
|
|
|
title: '当前为非WI-FI环境,请注意流量消耗',
|
|
|
|
icon: 'none',
|
|
|
|
duration: 3000
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
bindended() {
|
|
|
|
this.setData({
|
|
|
|
autoplay: true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// swiperChange2: function(e) {
|
|
|
|
// this.setData({
|
|
|
|
// 'options2.currentSwiper': e.detail.current,
|
|
|
|
// currentIndex: e.detail.current
|
|
|
|
// })
|
|
|
|
// },
|
|
|
|
// 跳转到banner详情
|
|
|
|
//navigatetoBannerDetail(e) {
|
|
|
|
// const {
|
|
|
|
// id,
|
|
|
|
// url,
|
|
|
|
// newsflag
|
|
|
|
// } = e.currentTarget.dataset
|
|
|
|
// console.log(id, url, newsflag)
|
|
|
|
// if (newsflag == '0') {
|
|
|
|
// wx.navigateTo({
|
|
|
|
// url: `/subpages/home/pages/webview/webview?url=${url}`
|
|
|
|
// })
|
|
|
|
// } else if (newsflag == '1') {
|
|
|
|
// wx.navigateTo({
|
|
|
|
// url: `/subpages/home/pages/newsDetail/newsDetail?id=${id}`
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
})
|