You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
2.5 KiB
JavaScript
111 lines
2.5 KiB
JavaScript
const app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
hidden: false,
|
|
pageNum: 1,
|
|
pageSize: 15,
|
|
list: []
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
this.cy_cardAmountChange();
|
|
this.setData({color:app.globalData.color})
|
|
},
|
|
|
|
/**
|
|
* 卡金额变动查询
|
|
*/
|
|
cy_cardAmountChange: function() {
|
|
var that = this;
|
|
that.setData({
|
|
hidden: false
|
|
})
|
|
var nowDate = new Date();
|
|
var endTime = app.utils.getFormatTime(nowDate, 1);
|
|
nowDate.setDate(nowDate.getDate() - 180);
|
|
var startTime = app.utils.getFormatTime(nowDate, 1);
|
|
var params = {
|
|
method: "card.amount.change",
|
|
startTime: startTime,
|
|
endTime: endTime,
|
|
pageNum: that.data.pageNum,
|
|
pageSize: that.data.pageSize,
|
|
cardNo: app.globalData.cardNo,
|
|
};
|
|
console.log(params);
|
|
var ignores = [];
|
|
app.jsapi.memberApi(app.globalData.memberAppKey, app.globalData.memberAppSecret, app.globalData.memberUrl).ajax(params, ignores,
|
|
function(json) {
|
|
console.log(json);
|
|
wx.stopPullDownRefresh();
|
|
var result = json.data;
|
|
if (result.status == 1) {
|
|
if (that.data.pageNum == 1) {
|
|
that.data.list = [];
|
|
}
|
|
|
|
for (var item of result.list) {
|
|
if (item.type == "consume") {
|
|
item.color = "#333";
|
|
item.totalAmount = "-" + item.totalAmount;
|
|
} else {
|
|
item.color = "#FEB609";
|
|
item.totalAmount = "+" + item.totalAmount;
|
|
}
|
|
that.data.list.push(item);
|
|
}
|
|
that.setData({
|
|
hidden: true,
|
|
list: that.data.list
|
|
});
|
|
} else {
|
|
that.setData({
|
|
hidden: true,
|
|
});
|
|
wx.showToast({
|
|
title: result.message,
|
|
icon: "none"
|
|
})
|
|
}
|
|
},
|
|
function(error) {
|
|
that.setData({
|
|
hidden: true,
|
|
});
|
|
wx.showToast({
|
|
title: '网络链接失败',
|
|
icon: none
|
|
})
|
|
})
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function() {
|
|
this.data.pageNum = 1;
|
|
this.cy_cardAmountChange();
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function() {
|
|
this.data.pageNum = this.data.pageNum + 1;
|
|
this.cy_cardAmountChange();
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function() {
|
|
|
|
}
|
|
}) |