You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
337 lines
9.2 KiB
337 lines
9.2 KiB
const api = require('../../../../utils/understandJs')
|
|
const app = getApp()
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
pageIndex: 1,
|
|
pageSize: 10,
|
|
modulelist: [], //module 接口
|
|
noticelist: [], //notice 接口
|
|
newsCategoryList: [], //type-8 tab list
|
|
nodata: false,
|
|
loadMoreType: 'none',
|
|
loadMoreVisible: false,
|
|
isLoadMore: false, //是否显示load-more组件
|
|
swiperBannerList: [],
|
|
indicatorDots: false, //指示点
|
|
autoplay: true, //true,//自动播放
|
|
circular: true, //衔接滑动
|
|
interval: 5000, //自动播放间隔时长(ms)
|
|
duration: 500, //幻灯片切换时长(ms)
|
|
currentSwiper: 0,
|
|
showTitle: true, //视频标题
|
|
moduleInfo: {}, //pid, bannerflag, categorycode, modulestyle, categoryname
|
|
preloadVisible: true, //type-8 预加载
|
|
lastPlayVideo: '', //正在播放的视频
|
|
completeInfoDialogVisible: false, //完善信息
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
this.data.moduleInfo = { ...options }
|
|
this.setData({
|
|
moduleInfo: this.data.moduleInfo
|
|
})
|
|
wx.setNavigationBarTitle({
|
|
title: options.categoryname
|
|
})
|
|
if (options.bannerflag == '1') {
|
|
this.getBannerList(options.categorycode)
|
|
}
|
|
if (this.data.moduleInfo.modulestyle == '1' || this.data.moduleInfo.modulestyle == '3' || this.data.moduleInfo.modulestyle == '5' || this.data.moduleInfo.modulestyle == '6') {
|
|
this.setData({
|
|
isLoadMore: true
|
|
})
|
|
this.getNoticelist()
|
|
} else if (options.modulestyle == '2') {
|
|
this.getModuleCategory()
|
|
} else if (options.modulestyle == '4') {
|
|
wx.navigateTo({
|
|
url: `../noticeDetail/noticeDetail?pid=${this.data.moduleInfo.pid}&bannerflag=${this.data.moduleInfo.bannerflag}&categorycode=${this.data.moduleInfo.categorycode}&modulestyle=${this.data.moduleInfo.modulestyle}&categoryname=${this.data.moduleInfo.categoryname}`
|
|
})
|
|
} else if (options.modulestyle == '7') {
|
|
this.setData({
|
|
isLoadMore: true
|
|
})
|
|
this.getNoticelist()
|
|
} else if (options.modulestyle == '8') {
|
|
this.getModuleCategoryList().then(() => {
|
|
this.getNoticelist(this.data.newsCategoryList[0].value)
|
|
})
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
this.setData({
|
|
loadMoreVisible: true
|
|
})
|
|
if (this.data.loadMoreType === 'loading') {
|
|
this.setData({
|
|
pageIndex: this.data.pageIndex + 1,
|
|
pageSize: this.data.pageSize,
|
|
})
|
|
|
|
if (this.data.moduleInfo.modulestyle == '1' || this.data.moduleInfo.modulestyle == '3' || this.data.moduleInfo.modulestyle == '5' || this.data.moduleInfo.modulestyle == '6') {
|
|
this.getNoticelist()
|
|
} else if (this.data.moduleInfo.modulestyle == '2') {
|
|
this.getModuleCategory()
|
|
} else if (this.data.moduleInfo.modulestyle == '7') {
|
|
this.getNoticelist()
|
|
} else if (this.data.moduleInfo.modulestyle == '8') {
|
|
this.getNoticelist(this.data.newsCategoryList[0].value)
|
|
}
|
|
}
|
|
},
|
|
|
|
//获取模块列表
|
|
getModuleCategory() {
|
|
let params = {
|
|
pageIndex: this.data.pageIndex,
|
|
pageSize: this.data.pageSize,
|
|
pid: this.data.moduleInfo.pid
|
|
}
|
|
api.moduleCategory(params).then(res => {
|
|
this.setData({
|
|
modulelist: this.data.modulelist.concat(res.data),
|
|
loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none',
|
|
loadMoreVisible: res.data.length === this.data.pageSize ? false : true
|
|
})
|
|
if (this.data.modulelist.length == 0) {
|
|
this.setData({
|
|
nodata: true,
|
|
loadMoreType: 'none',
|
|
loadMoreVisible: false,
|
|
})
|
|
}
|
|
}).catch(err => {
|
|
this.setData({
|
|
modulelist: [],
|
|
nodata: true,
|
|
loadMoreType: 'none',
|
|
loadMoreVisible: false,
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
//获取通知列表
|
|
getNoticelist(categoryCode='') {
|
|
let that = this
|
|
let params = {
|
|
pageIndex: that.data.pageIndex,
|
|
pageSize: that.data.pageSize,
|
|
noticeCategory: categoryCode == '' ? that.data.moduleInfo.categorycode : categoryCode
|
|
}
|
|
|
|
api.noticelist(params).then(res => {
|
|
let list = [ ...res.data ]
|
|
if (that.data.moduleInfo.modulestyle == '7') {
|
|
list = []
|
|
res.data.forEach(item => {
|
|
if (item.noticeVideoUrl) {
|
|
item.showTitle = false
|
|
list.push(item)
|
|
}
|
|
})
|
|
}
|
|
console.log(list)
|
|
that.setData({
|
|
noticelist: that.data.noticelist.concat(list),
|
|
loadMoreType: res.data.length === that.data.pageSize ? 'loading' : 'none',
|
|
loadMoreVisible: res.data.length === that.data.pageSize ? false : true,
|
|
preloadVisible: false
|
|
})
|
|
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,
|
|
preloadVisible: false
|
|
})
|
|
console.log(err)
|
|
})
|
|
},
|
|
|
|
// 获取type-8 分类列表
|
|
getModuleCategoryList () {
|
|
let params = {
|
|
pageIndex: this.data.pageIndex,
|
|
pageSize: this.data.pageSize,
|
|
pid: this.data.moduleInfo.pid
|
|
}
|
|
return new Promise((resolve, reject) => {
|
|
api.moduleCategory(params).then(res => {
|
|
console.log('获取分类列表', res)
|
|
// const newsCategoryList = [{
|
|
// value: 'all',
|
|
// select: true,
|
|
// label: '全部'
|
|
// }]
|
|
const newsCategoryList = []
|
|
res.data.forEach(item => {
|
|
newsCategoryList.push({
|
|
value: item.categoryCode,
|
|
select: false,
|
|
label: item.categoryName
|
|
})
|
|
})
|
|
newsCategoryList[0].select = true
|
|
this.setData({
|
|
newsCategoryList
|
|
})
|
|
resolve(true)
|
|
}).catch(err => {
|
|
console.log(err)
|
|
reject(false)
|
|
})
|
|
})
|
|
},
|
|
|
|
//获取视频banner列表
|
|
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
|
|
})
|
|
},
|
|
bindcontrolstoggle(e) {
|
|
this.setData({
|
|
showTitle: e.detail.show
|
|
})
|
|
},
|
|
videoitemplay (e) {
|
|
wx.createVideoContext(this.data.lastPlayVideo).pause()
|
|
this.setData({
|
|
lastPlayVideo: e.currentTarget.id
|
|
})
|
|
wx.getNetworkType({
|
|
success (res) {
|
|
const networkType = res.networkType
|
|
if (res.networkType != 'wifi') {
|
|
wx.showToast({
|
|
title: '当前为非WI-FI环境,请注意流量消耗',
|
|
icon: 'none',
|
|
duration: 3000
|
|
})
|
|
}
|
|
}
|
|
})
|
|
},
|
|
videoitemtoggle (e) {
|
|
this.data.noticelist[e.currentTarget.dataset.index].showTitle = e.detail.show
|
|
this.setData({
|
|
noticelist: this.data.noticelist
|
|
})
|
|
},
|
|
/**
|
|
* module 跳转模块页面
|
|
*/
|
|
navigateToType (e) {
|
|
const info = e.currentTarget.dataset.info
|
|
wx.navigateTo({
|
|
url: `./moduleList?pid=${info.id}&bannerflag=${info.bannerFlag}&categorycode=${info.categoryCode}&modulestyle=${info.moduleStyle}&categoryname=${info.categoryName}`
|
|
})
|
|
},
|
|
|
|
//notice 跳转详情页面
|
|
toDetail(e){
|
|
const info = e.currentTarget.dataset
|
|
wx.navigateTo({
|
|
url: `../noticeDetail/noticeDetail?id=${info.id}&title=${this.data.moduleInfo.categoryname}`
|
|
})
|
|
},
|
|
|
|
//type-8 tab切换回调函数
|
|
newsCategoryCallback (e) {
|
|
// if (e.detail.newsCategoryId === 'all') {
|
|
// this.data.newsCategoryId = ''
|
|
// } else {
|
|
// this.data.newsCategoryId = e.detail.newsCategoryId
|
|
// }
|
|
this.setData({
|
|
pageIndex: 1,
|
|
noticelist: [],
|
|
loadMoreType: 'none',
|
|
loadMoreVisible: false,
|
|
preloadVisible: true,
|
|
nodata: false
|
|
})
|
|
this.getNoticelist(e.detail.newsCategoryId)
|
|
},
|
|
|
|
//type-2 锦水清风-我要举报
|
|
toReportIssue (e) {
|
|
if (this.verifyCompleteInfo()) {
|
|
return false
|
|
}
|
|
wx.navigateTo({
|
|
url: "/subpages/oneKeyService/pages/reportIssue/reportIssue"
|
|
})
|
|
},
|
|
|
|
// 检查 是否完善信息
|
|
verifyCompleteInfo () {
|
|
if (app.globalData.infoCompleted == 0) {
|
|
this.setData({
|
|
completeInfoDialogVisible: !this.data.completeInfoDialogVisible
|
|
})
|
|
return true
|
|
} else {
|
|
return false
|
|
}
|
|
},
|
|
})
|