Micro-letter web page login

Package interface page:

const wxLogin = (appid, url) => {
  let redirect_uri = encodeURIComponent(url)
  window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATUS#wechat_redirect`
}
Parameters: 

. 1, the let the redirect_uri the encodeURIComponent = (URL) - post-authorization redirected callback link address and a URI encoded string assembly.

2, windows.location.href = "/ url" - to open the current page URL page
3, appid - Public unique identification number (required)
4, redirect_uri - callback after the authorization redirect link address, please use the links urlEncode processing (required)
5, response_type - return type, please fill in the code (required)
6, scope - the scope of application of the authorization, snsapi_base (silent login, authorization page does not pop up, jump directly, the user can only get openid), snsapi_userinfo (pop authorization page, you can get the nickname, gender, location and by openid, even in the absence of attention, as long as the user authorization, can obtain its information.) (required)
7, State - after redirection will bring the state parameters, developers can fill out the parameter values a-zA-Z0-9 of up to 128 bytes (optional)
8, # wechat_redirect - whether directly or open the page to do a 302 redirect, you must bring this parameter (required fill)

1, the first argument with? No. apart, separated after the parameters & last & #wechat_redirect do not add,
2、open.weixin.qq.com/connect/oauth2/authorize  微信默认地址


Use the page:
template:
<div = @ the Click "wxlogin"> 
     <P> log using micro channel </ P> 
 </ div>

 

script
import {wxLogin} from "@/api/apis";

// methods
wxlogin(){
        wxLogin('wx546563fe38304393', 'http://whc.mouhua.cn/mobile/v-accredit')
}
 The first parameter is the number of public appid, the second is to jump to the default blank page.

Guess you like

Origin www.cnblogs.com/lzuku/p/11304590.html