212 lines
4.5 KiB
JavaScript
212 lines
4.5 KiB
JavaScript
// pages/member/integrallist/integrallist.js
|
|
var app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
selected: 0,
|
|
all: [],
|
|
//收入积分
|
|
income: [],
|
|
//消费积分
|
|
out: [],
|
|
integral: '积分',
|
|
recordsList: [],
|
|
//more
|
|
isLoadMore: true,
|
|
page: 1,
|
|
total_page: 0,
|
|
show:false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
this._getIntegralInfo('');
|
|
try {
|
|
const value = wx.getStorageSync('integral');
|
|
if (value) {
|
|
this.setData({
|
|
integral: value
|
|
});
|
|
// Do something with return value
|
|
if (this.data.integral) {
|
|
wx.setNavigationBarTitle({
|
|
title: this.data.integral + '列表'
|
|
});
|
|
}
|
|
}
|
|
} catch (e) {
|
|
// Do something when catch error
|
|
}
|
|
},
|
|
tapIs(e){
|
|
let ind = e.currentTarget.dataset.ind;
|
|
let item = e.currentTarget.dataset.info;
|
|
let recordsList = this.data.recordsList;
|
|
recordsList[ind].show=!this.data.recordsList[ind].show;
|
|
this.setData({
|
|
recordsList:recordsList
|
|
});
|
|
wx.navigateTo({
|
|
url: '/packageB/member/integralDetail/integralDetail' + '?id=' + item.id,
|
|
});
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function() {
|
|
this._getMoreIntegralInfo(this.data.selected);
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function() {
|
|
|
|
},
|
|
_getIntegralInfo(type) {
|
|
let that = this;
|
|
this.data.page = 1;
|
|
let urlStr = app.getNetAddresss("finance.point-info");
|
|
urlStr += '&status=' + type;
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
var myData = res.data.list.data;
|
|
for(let i = 0;i<myData.length;i++){
|
|
// if(app._isTextEmpty(myData[i].transfer_info)){
|
|
myData[i].show = false;
|
|
// }else{
|
|
// myData[i].show = true
|
|
// }
|
|
}
|
|
console.log(myData);
|
|
that.setData({
|
|
total_page: res.data.list.last_page,
|
|
recordsList: myData
|
|
});
|
|
// if (type == 1) {
|
|
// that.setData({
|
|
// income: res.data.list
|
|
// })
|
|
// } else if (type == -1) {
|
|
// that.setData({
|
|
// out: res.data.list
|
|
// })
|
|
// } else {
|
|
// that.setData({
|
|
// all: res.data.list
|
|
// })
|
|
// }
|
|
|
|
}
|
|
},
|
|
fail: function(res) {
|
|
console.log(res.msg);
|
|
}
|
|
});
|
|
},
|
|
_getMoreIntegralInfo(type) {
|
|
let that = this;
|
|
that.setData({
|
|
isLoadMore: false
|
|
});
|
|
if (this.data.page >= this.data.total_page) {
|
|
return;
|
|
} else {
|
|
this.data.page = this.data.page + 1;
|
|
let urlStr = app.getNetAddresss("finance.point-info");
|
|
urlStr = urlStr + '&status=' + type + '&page=' + this.data.page;
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: function (resdata) {
|
|
var res = resdata.data;
|
|
if (res.result == 1) {
|
|
var myData = res.data.list.data;
|
|
for(let i = 0;i<myData.length;i++){
|
|
if(app._isTextEmpty(myData[i].transfer_info)){
|
|
myData[i].show = false;
|
|
}
|
|
}
|
|
that.setData({
|
|
recordsList: that.data.recordsList.concat(myData)
|
|
});
|
|
} else {
|
|
that.setData({
|
|
page: that.data.page - 1,
|
|
isLoadMore: false
|
|
});
|
|
}
|
|
},
|
|
fail: function (res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
}
|
|
},
|
|
swichTabTItem(e) {
|
|
let idx = e.detail.index;
|
|
if (idx == 0) {
|
|
this.setData({
|
|
selected: '',
|
|
recordsList: []
|
|
});
|
|
this._getIntegralInfo('');
|
|
} else if (idx == 1) {
|
|
this.setData({
|
|
selected: 1,
|
|
recordsList: []
|
|
});
|
|
this._getIntegralInfo(1);
|
|
}
|
|
if (idx == 2) {
|
|
this.setData({
|
|
selected: -1,
|
|
recordsList: []
|
|
});
|
|
this._getIntegralInfo(-1);
|
|
}
|
|
}
|
|
});
|