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.
135 lines
2.8 KiB
JavaScript
135 lines
2.8 KiB
JavaScript
9 months ago
|
const app = getApp();
|
||
|
Page({
|
||
|
|
||
|
/**
|
||
|
* 页面的初始数据
|
||
|
*/
|
||
|
data: {
|
||
|
selectTime: "本月",
|
||
|
startTime: "",
|
||
|
pageNum: 1,
|
||
|
pageSize: 15,
|
||
|
totalAmount: 0,
|
||
|
list: []
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 生命周期函数--监听页面加载
|
||
|
*/
|
||
|
onLoad: function(options) {
|
||
|
var nowDate = app.utils.getFormatTime(new Date(), 3);
|
||
|
this.data.startTime = app.utils.getFormatTime(new Date(), 4);
|
||
|
this.setData({
|
||
|
nowDate: nowDate,
|
||
|
});
|
||
|
|
||
|
this.cy_queryMemberRecord();
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 查询消费记录
|
||
|
*/
|
||
|
cy_queryMemberRecord: function() {
|
||
|
var that = this;
|
||
|
var date = new Date(this.data.startTime);
|
||
|
var startTime = app.utils.getFormatTime(date, 3) + " 00:00:00";
|
||
|
date.setMonth(date.getMonth() + 1);
|
||
|
date.setDate(0);
|
||
|
var endTime = app.utils.getFormatTime(date, 3) + " 23:59:59";
|
||
|
|
||
|
var params = {
|
||
|
method: "card.consume.history",
|
||
|
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);
|
||
|
var data = json.data;
|
||
|
if (data.status == 1) {
|
||
|
if (data.list.length == 0 && that.data.pageNum == 1) {
|
||
|
wx.showToast({
|
||
|
title: "暂无消费记录",
|
||
|
icon: "none"
|
||
|
})
|
||
|
}
|
||
|
var list = [];
|
||
|
if (that.data.pageNum != 1) {
|
||
|
list = that.data.list;
|
||
|
}
|
||
|
|
||
|
for (var item of data.list) {
|
||
|
list.push(item);
|
||
|
}
|
||
|
|
||
|
that.setData({
|
||
|
list: list,
|
||
|
totalAmount: parseFloat(data.sumData.totalAmount).toFixed(2)
|
||
|
});
|
||
|
} else {
|
||
|
wx.showToast({
|
||
|
title: data.errMessage,
|
||
|
icon: "none"
|
||
|
})
|
||
|
}
|
||
|
},
|
||
|
function(err) {
|
||
|
wx.showToast({
|
||
|
title: data.errMessage,
|
||
|
icon: "none"
|
||
|
})
|
||
|
});
|
||
|
},
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 选择时间
|
||
|
*/
|
||
|
cy_selectTime: function(e) {
|
||
|
var value = e.detail.value;
|
||
|
var values = value.split("-");
|
||
|
var time = values[0] + "年" + values[1] + "月";
|
||
|
this.setData({
|
||
|
selectTime: time,
|
||
|
startTime: value,
|
||
|
});
|
||
|
|
||
|
this.cy_queryMemberRecord();
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 取消
|
||
|
*/
|
||
|
cy_cancelTime: function(e) {
|
||
|
console.log(e);
|
||
|
},
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
*/
|
||
|
onPullDownRefresh: function() {
|
||
|
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 页面上拉触底事件的处理函数
|
||
|
*/
|
||
|
onReachBottom: function() {
|
||
|
console.log("加载更多");
|
||
|
this.data.pageNum++;
|
||
|
this.cy_queryMemberRecord();
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* 用户点击右上角分享
|
||
|
*/
|
||
|
onShareAppMessage: function() {
|
||
|
|
||
|
}
|
||
|
})
|