1class ScriptThirdLogin extends Script { 2 constructor(params) { 3 super(params) 4 this.$third = document.querySelector(`#${this.attrId}`) 5 this.$google = this.$third.querySelector(`.unit-third-login__item-google`) 6 this.$facebook = this.$third.querySelector(`.unit-third-login__item-facebook`) 7 } 8 9 init() { 10 this.bindEvent() 11 } 12 13 bindEvent() { 14 const origin = window.location.origin 15 const redirect_url = `${origin}/?type=third-login` 16 const url = globalThis.Server.getRinseHref('/third_authorize.html', window.app.info.site) 17 const bind_url = `${origin}${url}` 18 this.$google.addEventListener('click', () => { 19 ThirdLoginService.ins().oauth('google', bind_url,redirect_url).then(res => { 20 // console.log(res) 21 if (res.code ===0 && res.data) { 22 // alert(res.data) 23 window.location.href = res.data 24 } 25 }).catch(err => { 26 console.error(err) 27 }) 28 }) 29 30 this.$facebook.addEventListener('click', () => { 31 ThirdLoginService.ins().oauth('facebook', bind_url,redirect_url).then(res => { 32 // console.log(res) 33 if (res.code ===0 && res.data) { 34 // alert(res.data) 35 window.location.href = res.data 36 } 37 }).catch(err => { 38 console.error(err) 39 }) 40 }) 41 } 42} 43 44class ThirdLoginService { 45 constructor() { 46 } 47 48 /** å便¨¡å¼ */ 49 static ins() { 50 if (!this.instance) { 51 return this.instance = new ThirdLoginService() 52 } 53 return this.instance 54 } 55 56 /**è·åç¬¬ä¸æ¹ææurl */ 57 oauth(pt_oauth, bind_url,redirect_url) { 58 return new Promise((resolve, reject) => { 59 Utilts.ins().request({ 60 url: '/v2/user/passport/oauth-url', 61 prefix: 'base', 62 method: 'GET', 63 params: { 64 pt_oauth, 65 bind_url, 66 redirect_url 67 } 68 }).then(res => { 69 // console.log(res) 70 if (res.code === 0) resolve(res) 71 else reject(res) 72 }).catch(err => reject(err)) 73 }) 74 } 75}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.