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() checkoutVersion()
// 获取默认网格 // 获取默认网格
this.getDefaultGridInfo() this.getResidentConfig()
}, },
// 获取默认网格 // 获取默认网格
getDefaultGridInfo(){ getResidentConfig(){
let that = this let that = this
api.getDefaultGridInfo().then(res => { api.getResidentConfig().then(res => {
if (res.code === 0 && res.msg === 'success') { if (res.code === 0 && res.msg === 'success') {
res.data.forEach(item => {
if (item.residentType === 'default_grid') {
that.setData({ that.setData({
defaultGridId:res.data defaultGridId:item.residentValue
})
}
}) })
} }
}).catch(err => { }).catch(err => {

57
subpages/home/pages/newsDetail/newsDetail.js

@ -1,4 +1,5 @@
const api = require('../../../../utils/home') const api = require('../../../../utils/home')
var api_getResidentConfig = require('../../../../utils/api.js')
import { import {
getTimestamp getTimestamp
} from '../../../../utils/common' } from '../../../../utils/common'
@ -11,7 +12,8 @@ Page({
dispportStatus: 'dispport', dispportStatus: 'dispport',
noticeObj: {}, noticeObj: {},
infoCompleted: 0, infoCompleted: 0,
noticeObjContent: '' noticeObjContent: '',
residentValue:0,//配置时间
}, },
onLoad(options) { onLoad(options) {
this.setData({ this.setData({
@ -20,6 +22,8 @@ Page({
}) })
this.getNewsDetail(options.id) this.getNewsDetail(options.id)
this.browseNews(options.id) this.browseNews(options.id)
// 获取默认配置
this.getResidentConfig()
}, },
getNewsDetail(id) { getNewsDetail(id) {
let that = this let that = this
@ -160,5 +164,56 @@ Page({
// console.log(err) // 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, completeResidentInfoV2: completeResidentInfoV2,
completePartyInfoV2: completePartyInfoV2, completePartyInfoV2: completePartyInfoV2,
userPointsRankinglist:userPointsRankinglist, userPointsRankinglist:userPointsRankinglist,
getDefaultGridInfo:getDefaultGridInfo getDefaultGridInfo:getDefaultGridInfo,
getResidentConfig:getResidentConfig
} }
function getToken(wxCode) { function getToken(wxCode) {
@ -482,3 +483,7 @@ function getWxPhone({ wxCode, encryptedData, iv }) {
function getDefaultGridInfo() { function getDefaultGridInfo() {
return fly.get('dic/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, getInfoList: getInfoList,
infoDetail: infoDetail, infoDetail: infoDetail,
newsSupport: newsSupport, newsSupport: newsSupport,
newsOpposition: newsOpposition newsOpposition: newsOpposition,
browsePoints:browsePoints
} }
function getNoticeList(param) { function getNoticeList(param) {
return fly.get('news/notice/list', param) return fly.get('news/notice/list', param)
@ -47,3 +48,7 @@ function newsOpposition(param) {
function infoDetail(param) { function infoDetail(param) {
return fly.post('news/information/read', param) return fly.post('news/information/read', param)
} }
// 新闻浏览加积分
function browsePoints(param) {
return fly.post('news/news/browsePoints', param)
}
Loading…
Cancel
Save