98 lines
2.4 KiB
JavaScript
98 lines
2.4 KiB
JavaScript
// pages/account/account.js
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
type : '', //卡类型
|
|
number : '', //账户余额
|
|
accounts : '', //账户列表
|
|
blockeds : '', //待发放余额
|
|
page : {}, //分页信息
|
|
lodingStats : false, //加载状态
|
|
screenArray: [
|
|
{
|
|
channel: 'all',
|
|
name: '全部'
|
|
},
|
|
{
|
|
channel: 'in',
|
|
name: '入账'
|
|
},
|
|
{
|
|
channel: 'out',
|
|
name: '出账'
|
|
}
|
|
], //账变记录筛选数组
|
|
screenIndex: 0 //账变记录筛选index
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad (options) {
|
|
this.setData({
|
|
type : options.type
|
|
})
|
|
},
|
|
|
|
onShow() {
|
|
// 获取账变记录
|
|
this.accountInfo();
|
|
},
|
|
|
|
/**
|
|
* 账变记录
|
|
*/
|
|
accountInfo(page) {
|
|
wx.$api.user.logs(this.data.type, page).then(res=>{
|
|
//判断金卡、银卡、钻石卡
|
|
let number
|
|
if(this.data.type == "silver") {
|
|
number = res.data.account.silver
|
|
} else if(this.data.type == "gold") {
|
|
number = res.data.account.gold
|
|
} else if(this.data.type == "drill") {
|
|
number = res.data.account.drill
|
|
} else {
|
|
return
|
|
}
|
|
|
|
let listArr = this.data.accounts,
|
|
newData = []
|
|
if(page == 1 || page == undefined) listArr = []
|
|
newData = listArr.concat(res.data.data)
|
|
|
|
this.setData({
|
|
number : number,
|
|
blockeds : res.data.blockeds,
|
|
accounts : newData,
|
|
page : res.data.page
|
|
})
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
// 获取账变记录
|
|
this.accountInfo();
|
|
},
|
|
|
|
/**
|
|
* 上拉加载
|
|
*/
|
|
onReachBottom(){
|
|
this.setData({
|
|
lodingStats: true
|
|
})
|
|
let pageNumber = this.data.page.current
|
|
if(this.data.page.has_more){
|
|
pageNumber++
|
|
// 获取账变记录
|
|
this.accountInfo(pageNumber);
|
|
}
|
|
}
|
|
}) |