57 lines
1.2 KiB
TypeScript
57 lines
1.2 KiB
TypeScript
import message from "../../utils/message"
|
|
import { signInfo, sign } from "../../service/user-api"
|
|
|
|
// 获取应用实例
|
|
const app = getApp<IAppOption>();
|
|
// pages/sign/index.ts
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
pointValue: 0,
|
|
signToday: false,
|
|
continuousDays: 0,
|
|
dayTextArray: [
|
|
{ text: '一', value: 5 },
|
|
{ text: '二', value: 10 },
|
|
{ text: '三', value: 15 },
|
|
{ text: '四', value: 20 },
|
|
{ text: '五', value: 25 },
|
|
{ text: '六', value: 30 },
|
|
{ text: '七', value: 35 },
|
|
]
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad() {
|
|
if (app.globalData.userInfo) {
|
|
if(app.globalData.userInfo.pointInfo){
|
|
this.setData({
|
|
pointValue: app.globalData.userInfo.pointInfo.totalPoint
|
|
})
|
|
}
|
|
signInfo().then(res => {
|
|
this.setData(res)
|
|
})
|
|
} else {
|
|
// 需要登录
|
|
message.toast('请先登录')
|
|
wx.navigateBack();
|
|
}
|
|
},
|
|
onSignTag() {
|
|
message.showLoading({})
|
|
sign().then(res => {
|
|
app.updateUserInfo();
|
|
message.hideLoading()
|
|
this.setData(res)
|
|
}).catch(err => {
|
|
message.hideLoading()
|
|
message.toast(err.message)
|
|
})
|
|
}
|
|
}) |