|
|
@ -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) |
|
|
|
}, |
|
|
|
}) |