# uni-one-login

> 阿里云三大运营商一键登录

Latest version **1.0.12** (published 2021-11-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install uni-one-login
pnpm add uni-one-login
yarn add uni-one-login
bun add uni-one-login
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2021-11-26 |
| First published | 2021-11-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 38.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | houlikai |

## Links

- npm: https://www.npmjs.com/package/uni-one-login
- npm.io page: https://npm.io/package/uni-one-login

## Recent versions

- 1.0.12 (latest) — 2021-11-26
- 1.0.11 — 2021-11-24
- 1.0.10 — 2021-11-20
- 1.0.9 — 2021-11-15
- 1.0.8 — 2021-11-13
- 1.0.7 — 2021-11-13
- 1.0.6 — 2021-11-05
- 1.0.5 — 2021-11-05
- 1.0.4 — 2021-11-05
- 1.0.3 — 2021-11-05
- 1.0.2 — 2021-11-05
- 1.0.1 — 2021-11-05
- 1.0.0 — 2021-11-04

## README

### Install

项目中提前安装好 阿里云相关sdk   manifest.json相关配置
具体案例参考： https://ext.dcloud.net.cn/plugin?spm=a2c4g.11186623.0.0.67039a7crUNMOr&id=4297  

```sh
$ npm install uni-one-login
```

## API

```js


import { uniOneLogin, setAuthSDKInfo, quitLoginPage, hideLoginLoading } from 'uni-one-login'

// 具体案例详见 https://ext.dcloud.net.cn/plugin?spm=a2c4g.11186623.0.0.67039a7crUNMOr&id=4297 

// 设置秘钥与获取状态code(详见下链接) 
async getResultCode(){
   const secretKey = 'uDC+IlZh7l3ysP6uCqlgpOIJJazBTVXPG746PSNrOA7TQ98GIA0d5/WmbRv1Jg+JwH1mqkqwDDMaMOLcdI5iZsFPPS0tGL3mptZlBH171r9/2KVIIz4/2uuR9qWdCwwtF0nE8KTsnXRIpkngd1E2BekFZwVKqdEy3wn78qT+5CuVA36PsQzdBZmQtEh5KkP3V5anK2gh64h66aFpqmlTfwXU+4o0VbmQBhlLHiQHwdHszVy07RK2R8PdlXhMPCdNJ/4QThg/mAxkAQoL+HAYP0m443eyTMZXbE6rQHGMBh2BNyFpCRrzrw=='

  await setAuthSDKInfo(secretKey)
}

// 获取token  fullscreenStyle-》全屏  alertStyle-》弹屏  sheetStyle-》底部弹  buildFullscreenAndImageBg-》全屏（原生图片背景）   alertAndImageBgStyle-》弹窗（原生图片背景）
// sheetAndGifBgStyle-》 底部弹窗（原生GIF背景）

async goLogin() { 
            const myConfig = {
                presentType: 'alertStyle', // 打开方式
                option: { // 配置参数 文字 样式等 具体配置看上边链接
                    uiConfig: {
                        setAppPrivacyOne: {
                            title: '用户协议',
                            url: 'https://www.taobao.com'
                        },
                        setAppPrivacyTwo: {
                            title: '隐私政策',
                            url: 'https://www.taobao.com'
                        },
                        setBackgroundUi: { // 背景图片
                            backgroundColor: '#081223',
                            imageUrl: 'https://cnnho-static.oss-cn-shanghai.aliyuncs.com/image/lizanPlanet/jxhw/images/default/no_feedback.png'
                        }
                    },
                    // widgets:{  // 授权页自定义元素

                    // }
                }
            }

            const [err, res] = await uniOneLogin(myConfig)
            if (err) { // 错误以及点击其他自定义元素
                const { widgetId } = err
                switch (widgetId) {
                    case 'otherLogin': // 其他登陆方式
                        uni.navigateTo({
                            url: '/pages/index/login/index'
                        })
                        break
                    default:
                        console.log('你猜：：', widgetId)
                        break
                }
                console.log('errerrerr', err)
                return
            }
            console.log('resresresresres:::获取的token ', res)
        }


// 关闭一键登录弹框
quitLoginPage()

// 隐藏loading 解决安卓机未主动
hideLoginLoading()

```

---
_Source: https://npm.io/package/uni-one-login · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
