diff --git a/pages/indexNew/indexNew.js b/pages/indexNew/indexNew.js index fc9d5b8..199f9c7 100644 --- a/pages/indexNew/indexNew.js +++ b/pages/indexNew/indexNew.js @@ -126,16 +126,20 @@ Page({ checkoutVersion() // 获取默认网格 - this.getDefaultGridInfo() + this.getResidentConfig() }, // 获取默认网格 - getDefaultGridInfo(){ + getResidentConfig(){ let that = this - api.getDefaultGridInfo().then(res => { + api.getResidentConfig().then(res => { if (res.code === 0 && res.msg === 'success') { - that.setData({ - defaultGridId:res.data - }) + res.data.forEach(item => { + if (item.residentType === 'default_grid') { + that.setData({ + defaultGridId:item.residentValue + }) + } + }) } }).catch(err => { console.log(err) diff --git a/subpages/home/pages/newsDetail/newsDetail.js b/subpages/home/pages/newsDetail/newsDetail.js index 02f7b6f..159bcc8 100644 --- a/subpages/home/pages/newsDetail/newsDetail.js +++ b/subpages/home/pages/newsDetail/newsDetail.js @@ -1,4 +1,5 @@ const api = require('../../../../utils/home') +var api_getResidentConfig = require('../../../../utils/api.js') import { getTimestamp } from '../../../../utils/common' @@ -11,7 +12,8 @@ Page({ dispportStatus: 'dispport', noticeObj: {}, infoCompleted: 0, - noticeObjContent: '' + noticeObjContent: '', + residentValue:0,//配置时间 }, onLoad(options) { this.setData({ @@ -20,6 +22,8 @@ Page({ }) this.getNewsDetail(options.id) this.browseNews(options.id) + // 获取默认配置 + this.getResidentConfig() }, getNewsDetail(id) { let that = this @@ -160,5 +164,56 @@ Page({ // console.log(err) // }) } - } + }, + // 获取默认配置 阅读时间 + getResidentConfig(){ + let that = this + api_getResidentConfig.getResidentConfig().then(res => { + if (res.code === 0 && res.msg === 'success') { + res.data.forEach(item => { + if (item.residentType === 'poins_config') { + that.setData({ + residentValue:parseInt(item.residentValue) + }) + } + }) + that.countDown() + } + }).catch(err => { + console.log(err) + }) + }, + // 倒计时 + countDown() { + this.data.timer = setInterval(() => { + console.log('加积分倒计时'+this.data.residentValue) + if (this.data.residentValue > 1) { + this.data.residentValue-- + this.setData({ + residentValue: this.data.residentValue + }) + } else { + this.browsePoints() + clearInterval(this.data.timer) + } + }, 1000) + }, + // 加积分 + browsePoints(){ + let that = this + const para = { + newsId: that.data.detailId + } + api.browsePoints(para).then(res => { + console.log('加积分成功',res) + }).catch(err => { + console.log(err) + }) + }, + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { + clearInterval(this.data.timer) + }, }) \ No newline at end of file diff --git a/utils/api.js b/utils/api.js index b7dc22c..1629b90 100644 --- a/utils/api.js +++ b/utils/api.js @@ -50,7 +50,8 @@ module.exports = { completeResidentInfoV2: completeResidentInfoV2, completePartyInfoV2: completePartyInfoV2, userPointsRankinglist:userPointsRankinglist, - getDefaultGridInfo:getDefaultGridInfo + getDefaultGridInfo:getDefaultGridInfo, + getResidentConfig:getResidentConfig } function getToken(wxCode) { @@ -481,4 +482,8 @@ function getWxPhone({ wxCode, encryptedData, iv }) { // 获取默认网格信息 function getDefaultGridInfo() { return fly.get('dic/getDefaultGridInfo') +} +// 获取居民端配置 +function getResidentConfig() { + return fly.get('residentConfig/getResidentConfig') } \ No newline at end of file diff --git a/utils/home.js b/utils/home.js index 86bbf44..48977aa 100644 --- a/utils/home.js +++ b/utils/home.js @@ -9,7 +9,8 @@ module.exports = { getInfoList: getInfoList, infoDetail: infoDetail, newsSupport: newsSupport, - newsOpposition: newsOpposition + newsOpposition: newsOpposition, + browsePoints:browsePoints } function getNoticeList(param) { return fly.get('news/notice/list', param) @@ -47,3 +48,7 @@ function newsOpposition(param) { function infoDetail(param) { return fly.post('news/information/read', param) } +// 新闻浏览加积分 +function browsePoints(param) { + return fly.post('news/news/browsePoints', param) +} \ No newline at end of file