Files
fitness-coach/miniprogram/utils/auth.js
wm b3b58e66fb feat: init fitness-coach (backend + miniprogram)
- backend: NestJS service with exercise/plan data
- miniprogram: WeChat mini program client
- exclude node_modules, dist, runtime data-store, local env
2026-07-22 00:35:40 +08:00

21 lines
583 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 极简登录占位:仅演示 wx.login 拿到 code不请求真实后端服务端。
// 生产环境中,应将 code 发送到后端换取 openid / session。
function getOpenid() {
return new Promise((resolve) => {
wx.login({
success(res) {
if (res.code) {
// 真实实现wx.request({ url: BASE_URL + '/api/auth/login', data: { code } })
console.log('[auth] wx.login code =', res.code);
}
resolve(res.code || '');
},
fail() {
resolve('');
}
});
});
}
module.exports = { getOpenid };