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.
79 lines
1.7 KiB
79 lines
1.7 KiB
5 years ago
|
import {
|
||
|
getCode,
|
||
|
getPointsLogs
|
||
|
} from "../../../../api/integralCentre.js"
|
||
|
Page({
|
||
|
data: {
|
||
|
codeUrl: '',
|
||
|
behaviorCode: 'points_exchange', //积分动作编码
|
||
|
pageIndex: 1,
|
||
|
pageSize: 10,
|
||
|
pointList: [],
|
||
|
loadMoreVisible: false, //false
|
||
|
loadMoreType: "none",
|
||
|
showLoading: true,
|
||
|
nodata: false,
|
||
|
_timer: null,
|
||
|
},
|
||
|
onLoad: function () {
|
||
|
this.getCode()
|
||
|
this.getPointsLogs()
|
||
|
if (this.data._timer) {
|
||
|
clearInterval()
|
||
|
}
|
||
|
let _timer = null
|
||
|
_timer = setInterval(() => {
|
||
|
console.log('刷新')
|
||
|
this.getCode()
|
||
|
}, 1000 * 180)
|
||
|
},
|
||
|
getCode() {
|
||
|
this.setData({
|
||
|
showLoading: true
|
||
|
})
|
||
|
getCode().then(res => {
|
||
|
this.setData({
|
||
|
codeUrl: res.data.codeUrl,
|
||
|
showLoading: false
|
||
|
})
|
||
|
}).catch(err => {})
|
||
|
},
|
||
|
getNewCode() {
|
||
|
this.getCode()
|
||
|
},
|
||
|
// 获取居民兑换记录接口
|
||
|
getPointsLogs() {
|
||
|
let para = {
|
||
|
pageIndex: this.data.pageIndex,
|
||
|
pageSize: this.data.pageSize,
|
||
|
behaviorCode: this.data.behaviorCode,
|
||
|
}
|
||
|
getPointsLogs(para).then((res) => {
|
||
|
this.setData({
|
||
|
loadMoreVisible: true,
|
||
|
loadMoreType: res.data.length === this.data.pageSize ? 'loading' : 'none',
|
||
|
pointList: this.data.pointList.concat(res.data)
|
||
|
})
|
||
|
if (this.data.pointList.length == 0) {
|
||
|
this.setData({
|
||
|
loadMoreVisible: false,
|
||
|
nodata: true
|
||
|
})
|
||
|
}
|
||
|
}).catch(() => {
|
||
|
this.setData({
|
||
|
nodata: true
|
||
|
})
|
||
|
})
|
||
|
},
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom: function () {
|
||
|
console.log('下拉了')
|
||
|
if (this.data.loadMoreType === 'loading') {
|
||
|
this.data.pageIndex += 1,
|
||
|
this.getPointsLogs()
|
||
|
}
|
||
|
},
|
||
|
})
|