uniondrug
TypeScript icon, indicating that this package has built-in type declarations

1.4.48 • Public • Published

Usage

1.安装

npm install uniondrug

2.提示

登录方法unionLogin()会自动把token保留在Cookie的union_token中, 也会返回完整的response可以手动再处理。

如果登录渠道是wechat,还会保留在wechat_token(含openid信息)中, 所以获取token最好也要使用通用方法getToken()来获取。

3.使用(示例)

import uniondrug from 'uniondrug';

//获取token
//会根据浏览器环境取wechat_token(含openid信息)或者union_token
uniondrug.getToken()

//手动跳转统一登录界面 非公共登录页一般不需要用到
uniondrug.navigatorToUnionLogin();

//无感登陆 如果不传参数,那么会取当前url中的参数。
uniondrug.unionLogin({loginType:'wanda',
                       needForceLogin:'0',
                        code:this.$route.query.code,})
            .then(response=>{
                console.log('response',response);
            });
/**
 *  1.必传字段 loginType  (mobile,encrypted,lptoken,weixin,wanda,ylapp,ydbapp,fesco,ght,qyWechat)
 *  2.needForceLogin
 *        传'0'代表授权失败不会自动跳转
 *        公共登录页可以传入'0',然后自己处理授权失败
 *        普通工程可以不传,授权失败自动跳转到公共手动登录页
 *  3.loginType对应类型下的参数

 *
 * loginType=mobile
 * @param {string}  mobile  - 手机号
 * @param {string}  code    - 验证码
 * @param {string} 可选  [type]    - wechat——微信;QJB——企建部;GHT——工会通;WANDA——万达;qywechat-企业微信
 * @param {string} 可选 [openid]   - 微信渠道openid
 * @param {string} 可选 [memberSource]   - memberSource
 * https://xxx.uniondrug.cn/index.html?loginType=mobile&mobile=xxx&code=xxx&type=xxx&openid=xxx&memberSource=



 *
 * loginType=encrypted

 * @param encryptedMobile   {string}            手机号加密字符串
 * @param code              {string}            微信code
 * https://xxx.uniondrug.cn/index.html?loginType=encrypted&encryptedMobile=xxx&code=xxx




 * loginType === lptoken
 *
 * @param token     {string}            令牌中心(token.module)的token
 * @param code      {string}            微信code
 * https://xxx.uniondrug.cn/index.html?loginType=lptoken&token=xxx&code=xxx




 * loginType === weixin
 *
 * @param code  {string}                微信code
 * https://xxx.uniondrug.cn/index.html?loginType=weixin&code=xxx



 * loginType === wanda
 *
 * @param code  {string}                万达 auth code
 * https://xxx.uniondrug.cn/index.html?loginType=wanda&code=xxx



 * loginType === ylapp
 *
 * @param token     {string}            药联app传的token
 * https://xxx.uniondrug.cn/index.html?loginType=ylapp&token=xxx



 * loginType === ydbapp
 *
 * @param token     {string}            药店宝app传的token
 * https://xxx.uniondrug.cn/index.html?loginType=ydbapp&token=xxx



 * loginType === fesco
 *
 * @param name      {string}            name
 * @param mobile    {string}            mobile
 * @param card      {string}            card
 * @param token     {string}            Fesco传入的验证token
 * https://xxx.uniondrug.cn/index.html?loginType=fesco&name=xxx&mobile=xxx&card=xxx&token=xxx


 * loginType === yiyao
 *
 * @param openid        {string}            openid
 * https://xxx.uniondrug.cn/index.html?loginType=yiyao&openId=xxx

 * loginType === qyWechat
 *
 * @param code  {string}            企业code
 * https://xxx.uniondrug.cn/index.html?loginType=qyWechat&code=xxx
 */

Readme

Keywords

none

Package Sidebar

Install

npm i uniondrug

Weekly Downloads

2

Version

1.4.48

License

ISC

Unpacked Size

1.22 MB

Total Files

8

Last publish

Collaborators

  • heartlesssoy
  • yangxinxin
  • huangyibo