|
|
@@ -11,7 +11,6 @@ Page({
|
|
|
appAssetsUrl2: App.appAssetsUrl2,
|
|
|
appAssetsUrl3: App.appAssetsUrl3,
|
|
|
userInfo: {},
|
|
|
- currentDate: new Date(),
|
|
|
currentYear: new Date().getFullYear(),
|
|
|
currentMonth: new Date().getMonth() + 1,
|
|
|
checkedDates: [], // 已签到日期,从服务器或本地存储加载
|
|
|
@@ -113,7 +112,8 @@ Page({
|
|
|
});
|
|
|
// _this.loadUser()
|
|
|
} else {
|
|
|
- wx.removeStorageSync("USER");
|
|
|
+ // wx.removeStorageSync("USER");
|
|
|
+ wx.clearStorage();
|
|
|
wx.navigateTo({
|
|
|
url: "/pages/login",
|
|
|
});
|
|
|
@@ -160,7 +160,6 @@ Page({
|
|
|
// 页面显示时重新加载签到状态
|
|
|
await this.getCheckinHistoryFromServer();
|
|
|
this.loadData();
|
|
|
- this.initCalendar();
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
@@ -169,7 +168,6 @@ Page({
|
|
|
onPullDownRefresh: async function () {
|
|
|
await this.getCheckinHistoryFromServer();
|
|
|
this.loadData();
|
|
|
- this.initCalendar();
|
|
|
this.getUserInfo();
|
|
|
wx.stopPullDownRefresh();
|
|
|
},
|
|
|
@@ -189,14 +187,14 @@ Page({
|
|
|
{},
|
|
|
(res) => {
|
|
|
wx.hideLoading();
|
|
|
- if (res.code === 0) {
|
|
|
+ if (res.code === 0 && res.data) {
|
|
|
// let data = res.data.map(v => {
|
|
|
// return parseInt(v.substr(6, 2));
|
|
|
// })
|
|
|
this.setData({
|
|
|
- checkedDates: res.data || []
|
|
|
+ checkedDates: res.data.history || []
|
|
|
});
|
|
|
- this.initCalendar();
|
|
|
+ this.initCalendar(res.data.current);
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
@@ -205,9 +203,9 @@ Page({
|
|
|
/**
|
|
|
* 初始化日历
|
|
|
*/
|
|
|
- initCalendar() {
|
|
|
+ initCalendar(dates = null) {
|
|
|
// 使用当前系统时间
|
|
|
- const date = new Date();
|
|
|
+ const date = dates ? new Date(dates) : new Date();
|
|
|
const year = date.getFullYear();
|
|
|
const month = date.getMonth();
|
|
|
const today = date.getDate();
|
|
|
@@ -273,7 +271,6 @@ Page({
|
|
|
*/
|
|
|
performCheckin() {
|
|
|
const userId = util.getUserId();
|
|
|
- const currentDate = new Date();
|
|
|
let _this = this;
|
|
|
// TODO: 调用签到API
|
|
|
App._post_form(
|
|
|
@@ -290,10 +287,7 @@ Page({
|
|
|
icon: 'success'
|
|
|
});
|
|
|
await _this.getCheckinHistoryFromServer();
|
|
|
- this.loadList();
|
|
|
- wx.nextTick(() => {
|
|
|
- _this.initCalendar();
|
|
|
- })
|
|
|
+ _this.loadList();
|
|
|
} else {
|
|
|
wx.hideLoading();
|
|
|
wx.showToast({
|