0.1.13 • Published 3 years ago

cloud-retail-auth v0.1.13

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

用于云上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);
})
0.1.13

3 years ago

0.1.12

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.2

3 years ago

0.1.3

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago