uniapp login process Detailed uni.login

uni.login (OBJECT)
Login

H5 landing platform Note:

When the micro-channel embedded browser to run H5 version, can be achieved by js sdk micro-letters landed, need to introduce a separate js, see the
realization of micro-letters landed on a normal browser, not an open API, the need to micro-channel application, only individual developers have this permissions
other H5 landing platform, such as QQ landing, landing microblogging, uni-app unpackaged, please write in the usual H5 written in the conditional compilation.

OBJECT Parameter Description

Parameter name Required Type Description platform differences explained
provider String NO Login ISP to get through uni.getProvider, if you do not set the login pop-up list to select the interface
scopes String / Array platform differences see description authorization type, default auth_base. Support auth_base (silent authorized) / auth_user (Unsolicited Grant) / auth_zhima (sesame credit) Alipay applet
timeout Number No timeout in ms micro letter applets, Baidu applet
success Function No interface call success callback
fail Function No Interface call fails the callback function
complete function No interface calls the end of the callback function (call succeeds, the failure will be executed)

success return Parameter Description

Parameter name Description
authResult Log information service provider, and the results returned by different service providers are not identical
errMsg descriptions

uni.login({
  provider: 'weixin',
  success: function (loginRes) {
    console.log(loginRes.authResult);
  }
});

uni.checkSession
check whether the login status expired

Attribute Type Description Required
success function whether the interface call success callback function
fail function whether the interface call failed callback function
complete function No interface calls the end of the callback function (call succeeds, the failure will be executed)

uni.getUserInfo (OBJECT)
to obtain user information.

UNI-APP development micro channel number using the public mode (H5) JSSDK of

Uniapp module can be used in the reference micro-channel js-sdk, micro-channel using the official website Download in question, you may be used jweixin-module.

installation

Download use
Download: https: //unpkg.com/[email protected]/out/index.js

use,

var jweixin = require('jweixin-module')  
jweixin.ready(function(){  
    // TODO  
});

A small program:

1, using the button assembly and the open-type is specified as getUserInfo type, a basic user information.

For more details, refer to the documentation:

https://developers.weixin.qq.com/miniprogram/dev/component/button.html

2, shows the use of open-data basic user information.

For more details, refer to the documentation:

https://developers.weixin.qq.com/miniprogram/dev/component/open-data.html

NO Login ISP provider String, obtained by uni.getProvider
withCredentials Boolean No whether to bring login state information. Micro letter applet, applet headlines
lang Number No to return to the language of the user information, the default is en. More value, please refer to the following instructions. Micro letter applet
timeout Number No timeout in ms. Small micro-channel program
success Function No success callback interface calls
fail Function No interface call failed callback function
complete Function No interface calls the end of the callback function (call succeeds, the failure will be executed)

userInfo Parameter Description

Parameter Type Description platform differences
nickName String Nickname
openId String unique user identifier of the service providers App + 5
avatarUrl String user avatar

uni.login({
  provider: 'weixin',
  success: function (loginRes) {
    console.log(loginRes.authResult);
    // 获取用户信息
    uni.getUserInfo({
      provider: 'weixin',
      success: function (infoRes) {
        console.log('用户昵称为:' + infoRes.userInfo.nickName);
      }
    });
  }
});

Description:
call wx.login () to obtain temporary registration certificate code, and the developers back to the server.
Call auth.code2Session interfaces, in exchange for the user and the session key that uniquely identifies OpenID session_key.
After the developer server may generate a custom login state according to the user identifier for identifying a user when the front end of the subsequent interactive service logic.

note:

Session_key session key is encrypted user data signing. In order to apply their own data security, server developers should not be a session key issued to a small program, it should not be provided outside the key.
Temporary registration certificate code can only be used once

uni.getProvider (OBJECT)
for service providers. Only App platform support.

In App platform, available services, packaged environment is configured service providers, and what app mobile terminal is installed does not matter.

Cloud SDK package configuration modules and related information in the manifest, the offline configuration packaged in a native engineering. A service provider configuration is packaged in, you can get the appropriate service provider is running.

On the current content of the article that is involved in front-end, PHP knowledge, if you are interested to follow, very honored, can you find really identify what the British! Also thank you for your attention in the coming days, hoping been quietly supporting me, I will try to write more good works. We grow together, learn from the zero-based programming, the user-friendly front-end Web presentation areas, data structures and algorithms, network theory, etc. to the junior partner. Share Web front-end related technical articles, tools, resources, course selection, hot information.


If this number of local contents do not get bits (for example: to copyright or other problems), please contact us for rectification can be timely and will be processed in the first time.


Please thumbs up! Because you agree / encouragement is the greatest power of my writing!

Welcome attention to Dada 's CSDN!

This is a quality, attitude blog

7d927f18ebd05ea1d505a572393fbc87.jpg

Guess you like

Origin www.cnblogs.com/dashucoding/p/11907521.html