In the micro-channel pages, you may just need to get openId, then we need to use the silent License.
1. initialization code interpretation whether or not there
async created () { let code = this.getQueryString('token') if (code) { await this.getUser(code) } else { this.getCode() } }
2. Get the code the way
getCode () { the let urlNow = the encodeURIComponent (window.location.origin + window.location.pathname) the let url = $ { `back-end domain name} / url? brand = $ {public No. brand name} & url = $ {urlNow} & scopes snsapi_base` = window.location.replace (URL) }
3. Intercept token [backend interface for requesting, obtaining openId]
// 获取url参数 getQueryString (name) { let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i') let r = window.location.search.substr(1).match(reg) if (r != null) { return unescape(r[2]) } return null }