store/packageA/member/ClockPunchRecord/ClockPunchRecord.js

202 lines
4.3 KiB
JavaScript

// pages/member/ClockPunchRecord/ClockPunchRecord.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
language: '',
//累计支付
payAmount: "",
//累计收入
rewardAmount: "",
//成功打卡天数
clockNum: 0,
//战绩明细显示控制
recordDetailShow: false,
//战绩详情
recordDetail: [],
total_page: 0,
share_title: '',
share_icon: '',
isLoadMore: true,
page: 1,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this._getMyRecord();
this._getMyRecordDetail();
this._getShareData();
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
let language = wx.getStorageSync('langIndex');
this.setData({ 'language': language.en});
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
wx.showShareMenu({
withShareTicket: false,
menus: ['shareAppMessage', 'shareTimeline']
});
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
if (this.data.isLoadMore) {
this._getMoreDetail();
} else {
console.log('没有更多数据');
}
},
/**
* 用户点击右上角分享
*/
onShareTimeline(){
return{
title:this.data.share_title,
imageUrl:this.data.share_icon
};
},
onShareAppMessage: function() {
return {
title: this.data.share_title,
imageUrl: this.data.share_icon
};
},
//我的战绩统计
_getMyRecord() {
let that = this;
let urlStr = app.getNetAddresss("plugin.clock-in.api.clock-in-member.statistic");
app._getNetWork({
url: urlStr,
success: function(resdata) {
var res = resdata.data;
if (res.result == 1) {
that.setData({
payAmount: res.data.pay_amount,
rewardAmount: res.data.reward_amount,
clockNum: res.data.colck_num
});
}
},
fail: function(res) {
console.log(res);
}
});
},
//我的战绩明细
_getMyRecordDetail() {
let that = this;
let urlStr = app.getNetAddresss("plugin.clock-in.api.clock-in-member.get-clock-list");
app._getNetWork({
url: urlStr,
success: function(resdata) {
var res = resdata.data;
if (res.result == 1) {
if (!app._isTextEmpty(res.data.data)) {
that.setData({
recordDetailShow: true,
recordDetail: res.data.data,
total_page: res.data.total
});
}
}
},
fail: function(res) {
console.log(res);
}
});
},
//获取分享数据
_getShareData() {
let that = this;
let urlStr = app.getNetAddresss("plugin.clock-in.api.clock-in.get-set");
app._getNetWork({
url: urlStr,
success: function(resdata) {
var res = resdata.data;
if (res.result == 1) {
that.setData({
share_title: res.data.share.share_title,
share_icon: res.data.share.share_icon
});
}
},
fail: function(res) {
console.log(res);
}
});
},
_getMoreDetail() {
if (this.data.page == this.data.total_page) {
return;
}
if (this.data.page >= this.data.total_page) {
return;
} else {
that.setData({
page: this.data.page + 1
});
let that = this;
let urlStr = app.getNetAddresss("plugin.clock-in.api.clock-in-member.get-clock-list");
urlStr += '&page=' + that.data.page;
app._getNetWork({
url: urlStr,
success: function(resdata) {
var res = resdata.data;
if (res.result == 1) {
that.setData({
recordDetail: that.data.recordDetail.concat(res.data.data)
});
} else {
that.setData({
page: that.data.page - 1,
isLoadMore: false
});
return;
}
},
fail: function(res) {
console.log(res);
}
});
}
},
});