Browse Source

新增配置接口+加积分接口

master
zhaoyongnian 5 years ago
parent
commit
0f6b556785
  1. 12
      pages/indexNew/indexNew.js
  2. 57
      subpages/home/pages/newsDetail/newsDetail.js
  3. 7
      utils/api.js
  4. 7
      utils/home.js

12
pages/indexNew/indexNew.js

@ -126,15 +126,19 @@ 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') {
res.data.forEach(item => {
if (item.residentType === 'default_grid') {
that.setData({
defaultGridId:res.data
defaultGridId:item.residentValue
})
}
})
}
}).catch(err => {

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

7
utils/api.js

@ -50,7 +50,8 @@ module.exports = {
completeResidentInfoV2: completeResidentInfoV2,
completePartyInfoV2: completePartyInfoV2,
userPointsRankinglist:userPointsRankinglist,
getDefaultGridInfo:getDefaultGridInfo
getDefaultGridInfo:getDefaultGridInfo,
getResidentConfig:getResidentConfig
}
function getToken(wxCode) {
@ -482,3 +483,7 @@ function getWxPhone({ wxCode, encryptedData, iv }) {
function getDefaultGridInfo() {
return fly.get('dic/getDefaultGridInfo')
}
// 获取居民端配置
function getResidentConfig() {
return fly.get('residentConfig/getResidentConfig')
}

7
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)
}
Loading…
Cancel
Save