nx-xcx-login-zfh
v0.1.4
Published
兆丰华微信开发商登录组件
Downloads
3
Readme
nx-xcx-login-kfs
农信开发商小程序登录组件:
- 集成手机号登录(微信)
使用
- 在小程序根目录上执行 npm init 或 yarn init
- 使用 npm install nx-xcx-login-kfs --save 安装小程序npm
- 使用 npm install nx-xcx-utils --save 安装配置库
- 勾选 详情-》本地设置 下的使用npm模块
- 点击菜单 工具-》构建npm
- 在使用的页面的 json 文件 usingComponents 节点下添加 "nx-xcx-login-kfs": "nx-xcx-login-kfs"
登录参数配置
- 相关文档 https://www.npmjs.com/package/nx-xcx-utils
- 在app.js里
import { configLogin } from 'nx-xcx-utils';
configLogin({
env: 1, //环境信息,根据此配置将请求信息推送至不同的采集站,1:测试 2:预生产 3:正式
loginPage: '登录页地址',
failPage: '授权失败地址,ex:授权取消',
systemId: 1,
channel: '短信通道',
theme: '主题配置'
});
- 页面中配置登录拦截
import { logout, getLoginUser, logout, loginBehavior } from 'nx-xcx-utils';
behaviors: [loginBehavior] // 放置于data同级处,标识页面需要登录
// 获取登录用户
// 如果已经登录,直接从stoge里获取用户信息
// 如果用户未登录,先使用wx.login获取code,然后接口查询,如果用户已经绑定过,根据用户信息进行会话设置并返回,如果flag为false,则返回null,如果flag为true则reject
getLoginUser(flag: boolean = false): Promise<LoginUser>
getLoginUserSync(): LoginUser | null // 获取登录用户信息(同步方法),仅从stoge里获取
// 退出
// flag为false是仅清理stoge中用户信息,flag为true时除清理stoge中用户信息外还将解绑微信, webview中会话信息请自行清理
logout(flag: boolean = false): Promise<boolean>
- theme 主题(可选),可用值及对应色值 theme_sc #ff0023 theme_zx #ff2c71 theme_egg #f5cf49 theme_black #262a2f theme_gray #47525d theme_blue #2d86fe theme_green #22d7bb theme_orange #ff9600
参数说明
- title 授权页标题,请填写小程序所属产品名称
- icon 授权页图标,请使用小程序所属产品图标
- retUrl 授权取消时回退页面,应该配置为小程序登录前页面(需要非登录状态可访问,不然可能造成重定向问题),由拦截器根据当前地址决定,做为动态参数传入登录页