新增教练端,实现业务闭环:会员登录注册→查询团课→预约团课→扫码签到→教练端开课→记录实际开课时间→教练端结课→记录实际结课时间→后台查询数据

This commit is contained in:
2026-07-20 17:21:28 +08:00
parent df0e68469b
commit 4a4697c816
84 changed files with 6914 additions and 258 deletions
+68
View File
@@ -0,0 +1,68 @@
/**
* 教练端全局状态管理 — 以 uni.Storage 为唯一数据源
*/
const TOKEN_KEY = 'coach_token'
const COACH_KEY = 'coach_info'
const store = {
/** 是否已登录 */
get isLoggedIn() {
try {
return !!uni.getStorageSync(TOKEN_KEY)
} catch (e) {
return false
}
},
/** 获取 token */
getToken() {
try {
return uni.getStorageSync(TOKEN_KEY) || null
} catch (e) {
return null
}
},
/** 获取教练信息 */
getCoachInfo() {
try {
return uni.getStorageSync(COACH_KEY) || null
} catch (e) {
return null
}
},
/** 获取教练 ID */
getCoachId() {
const info = this.getCoachInfo()
return info ? info.coachId : null
},
/** 获取教练用户名 */
getUsername() {
const info = this.getCoachInfo()
return info ? info.username : ''
},
/** 设置登录态 */
setLogin(token, coachInfo) {
try {
uni.setStorageSync(TOKEN_KEY, token)
if (coachInfo) uni.setStorageSync(COACH_KEY, coachInfo)
} catch (e) {
console.error('存储登录态失败:', e)
}
},
/** 清除登录态 */
clearLogin() {
try {
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(COACH_KEY)
} catch (e) {
console.error('清除登录态失败:', e)
}
}
}
module.exports = store