cloud-retail-auth
v0.1.13
Published
``` javascript import { RequestWithToken } from 'cloud-retail-auth'; export default function DemoPage(props) { const [requestLib, setRequestLib] = useState({ Request }); const [isLogin, setLogin] = useState(isWeChatMiniProgram ? false : true); if (i
Downloads
9
Readme
用于云上rax小程序鉴权
容器入口需要修改 requestLib
import { RequestWithToken } from 'cloud-retail-auth';
export default function DemoPage(props) {
const [requestLib, setRequestLib] = useState({ Request });
const [isLogin, setLogin] = useState(isWeChatMiniProgram ? false : true);
if (isWeChatMiniProgram) {
useEffect(() => {
RequestWithToken({ tokenUrl: 'url' }).then(res => {
setRequestLib(res);
setLogin(true);
})
}, []);
}
return isLogin ? haloContainer.render({
// 业务页面配置
requestConfig: {
requestLib: requestLib.Request,
},
defaultProps: {...props, request: requestLib.Request}
...
}) : null
模块的异步接口请求
this.props.request({});
模块中调用授权
import { showAuth } from 'cloud-retail-auth';
showAuth({
type: 'phone|userInfo',
phoneUrl: 'http://tny.dev.retailcloud.zacz.cn/user-web/auth/weixin/miniapp/updateUserPhone',
userInfoUrl: 'http://tny.dev.retailcloud.zacz.cn/user-web/auth/weixin/miniapp/updateUserInfo'
}).then(res => {
console.log(res, 'res==================');
}).catch(e => {
console.log(e);
})