Commit 8e2c2f12 authored by 王炽's avatar 王炽
parents e41d30d1 53739a2f
......@@ -53,7 +53,7 @@ const globalStore = useGlobalStore()
// 登录获取 cuk
const wxAutoLogin = async () => {
await new Promise(resolve => {
userStore.wxAutoLogin(resolve)
userStore.syWxAutoLogin(resolve)
})
}
......
......@@ -259,6 +259,36 @@ export const useUserStore = defineStore("userInfo", {
});
},
/**
*
* @param {sy使用}
* @returns
*/
async syWxAutoLogin(cb=null) {
uni.login({
provider: "weixin",
success: async (res) => {
console.log("wxAutoLogin", res);
if (res.errMsg === "login:ok") {
const { data } = await autoLoginByCode(code);
console.log("autoLoginByCode", data);
// 如果登录成功,获取用户信息和宝宝信息,更新到state中,方便全局使用
if (data && data.cuk) {
globalStore.setCuk(data.cuk,data.openId,data.unionId);
cb && cb();
}
} else {
uni.showToast({
title: res.errMsg,
icon: "error",
});
}
md.sensors.init();
},
});
},
async createBabyInfo(babyInfo) {
console.log("createBabyInfo:", babyInfo);
const res = await updateBabyInfo(babyInfo);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment