Files
template-10584/src/app.ts
赵忠林 1b24a611a8 docs: 更新优惠券相关文档- 新增优惠券API集成文档
- 新增优惠券卡片对齐修复文档
- 新增优惠券状态显示调试文档
- 新增优惠券组件警告修复文档- 更新用ShopInfo Hook字段迁移文档
- 更新Arguments关键字修复文档
2025-08-15 01:52:36 +08:00

49 lines
1.1 KiB
TypeScript
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.

import {useEffect} from 'react'
import Taro, {useDidShow, useDidHide} from '@tarojs/taro'
// 全局样式
import './app.scss'
import {loginByOpenId} from "@/api/layout";
import {TenantId} from "@/config/app";
import {saveStorageByLoginUser} from "@/utils/server";
function App(props: { children: any; }) {
const reload = () => {
Taro.login({
success: (res) => {
loginByOpenId({
code: res.code,
tenantId: TenantId
}).then(data => {
if (data) {
saveStorageByLoginUser(data.access_token, data.user)
}
})
}
})
};
// 可以使用所有的 React Hooks
useEffect(() => {
// Taro.getSetting获取用户的当前设置。返回值中只会出现小程序已经向用户请求过的权限。
Taro.getSetting({
success: (res) => {
if (res.authSetting['scope.userInfo']) {
reload();
}
}
});
}, []);
// 对应 onShow
useDidShow(() => {
})
// 对应 onHide
useDidHide(() => {
})
return props.children
}
export default App