vela-h5-sdk 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -7157,6 +7157,7 @@ var $ = class extends Ne {
|
|
|
7157
7157
|
alert("账号和密码不能为空!");
|
|
7158
7158
|
return;
|
|
7159
7159
|
}
|
|
7160
|
+
this._isLoading = !0;
|
|
7160
7161
|
let t = da.default.MD5(this.accountName).toString(), n = da.default.MD5(this.passcode).toString();
|
|
7161
7162
|
console.log("执行登录...", this.accountName, this.passcode);
|
|
7162
7163
|
try {
|
|
@@ -7173,6 +7174,7 @@ var $ = class extends Ne {
|
|
|
7173
7174
|
} catch (e) {
|
|
7174
7175
|
console.error(e);
|
|
7175
7176
|
}
|
|
7177
|
+
this._isLoading = !1;
|
|
7176
7178
|
}
|
|
7177
7179
|
async handleAccountRegisterSubmit(e) {
|
|
7178
7180
|
if (e.preventDefault(), this.passcode !== this.confirmPasscode) {
|
|
@@ -7183,6 +7185,7 @@ var $ = class extends Ne {
|
|
|
7183
7185
|
alert("账号和密码不能为空!");
|
|
7184
7186
|
return;
|
|
7185
7187
|
}
|
|
7188
|
+
this._isLoading = !0;
|
|
7186
7189
|
let t = da.default.MD5(this.accountName).toString(), n = da.default.MD5(this.passcode).toString();
|
|
7187
7190
|
console.log("执行注册...", this.accountName, this.passcode);
|
|
7188
7191
|
try {
|
|
@@ -7199,16 +7202,17 @@ var $ = class extends Ne {
|
|
|
7199
7202
|
} catch (e) {
|
|
7200
7203
|
console.error(e);
|
|
7201
7204
|
}
|
|
7205
|
+
this._isLoading = !1;
|
|
7202
7206
|
}
|
|
7203
7207
|
async handleLogoutClick(e) {
|
|
7204
|
-
e.preventDefault(), console.log("执行退出登录...");
|
|
7208
|
+
e.preventDefault(), this._isLoading = !0, console.log("执行退出登录...");
|
|
7205
7209
|
try {
|
|
7206
7210
|
let e = await ha.request.post(ha.urls.url_web_login_out, {});
|
|
7207
7211
|
this.handleLoginOutResult(e);
|
|
7208
7212
|
} catch (e) {
|
|
7209
7213
|
console.error(e);
|
|
7210
7214
|
}
|
|
7211
|
-
console.log("退出登录");
|
|
7215
|
+
this._isLoading = !1, console.log("退出登录");
|
|
7212
7216
|
}
|
|
7213
7217
|
async handleResetPasswordSubmit(e) {
|
|
7214
7218
|
if (e.preventDefault(), this.passcode !== this.confirmPasscode) {
|
|
@@ -587,4 +587,4 @@
|
|
|
587
587
|
</div>
|
|
588
588
|
<div class="input-line"></div>
|
|
589
589
|
</div>
|
|
590
|
-
`}loadAppleSDK(){let e=document.createElement(`script`);e.src=`https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js`,e.onload=()=>{window.AppleID.auth.init({clientId:this.appleClientId,scope:this.appleScope,redirectURI:this.appleRedirectURI,state:this.appleState,nonce:this.appleNonce,usePopup:this.appleUsePopup}),document.addEventListener(`AppleIDSignInOnSuccess`,e=>{let t=e.detail.authorization.id_token;this.handleThirdLogin(`3`,t)}),document.addEventListener(`AppleIDSignInOnFailure`,e=>{console.error(e.detail.error)})},document.head.appendChild(e)}handleAppleClick(){window.AppleID.auth.signIn()}loadGoogleSDK(){let e=document.createElement(`script`);e.src=`https://accounts.google.com/gsi/client`,e.async=!0,e.onload=()=>{window.handleGoogleSignIn=e=>{console.log(`Google JWT: `,e.credential),this.handleThirdLogin(`2`,e.credential)}},document.head.appendChild(e)}loadFacebookSDK(){let e=document.createElement(`script`);e.src=`https://connect.facebook.net/en_US/sdk.js`,e.async=!0,e.defer=!0,e.crossOrigin=`anonymous`,e.onload=()=>{window.FB.init({appId:this.facebookAppId,cookie:!0,xfbml:!0,version:`v20.0`})},document.head.appendChild(e)}handleFacebookClick(){if(!window.FB){console.warn(`Facebook SDK not loaded`);return}window.FB.getLoginStatus(e=>{e.authResponse?this.handleThirdLogin(`1`,e.authResponse.userID):window.FB.login(e=>{e.authResponse?this.handleThirdLogin(`1`,e.authResponse.userID):console.log(`Facebook login cancelled`)},{scope:`public_profile`})})}handleLoginResult(e){console.log(`SDK接收到的数据类型是:`,typeof e,e),e.code===0?(this.dispatchEvent(new CustomEvent(`vela-login-success`,{detail:e.data})),this.uid=e.data.uid,this.visible=!1):alert(e.msg)}handleLoginOutResult(e){console.log(`SDK接收到的数据类型是:`,typeof e,e),e.code===0?(this.dispatchEvent(new CustomEvent(`vela-login-out`,{detail:e.data})),this.uid=``,this.switchToLogin()):alert(e.msg)}async handleAccountLoginSubmit(e){if(e.preventDefault(),!this.accountName||!this.passcode){alert(`账号和密码不能为空!`);return}let t=da.default.MD5(this.accountName).toString(),n=da.default.MD5(this.passcode).toString();console.log(`执行登录...`,this.accountName,this.passcode);try{let e=await ha.request.post(ha.urls.url_web_account_login,{app_id:this.appId,channel_id:this.channelId,name:t,name2:this.accountName,password:n,password2:this.passcode,type:3});this.handleLoginResult(e)}catch(e){console.error(e)}}async handleAccountRegisterSubmit(e){if(e.preventDefault(),this.passcode!==this.confirmPasscode){alert(`รหัสผ่านไม่ตรงกัน (两次输入的密码不一致)`);return}if(!this.accountName||!this.passcode){alert(`账号和密码不能为空!`);return}let t=da.default.MD5(this.accountName).toString(),n=da.default.MD5(this.passcode).toString();console.log(`执行注册...`,this.accountName,this.passcode);try{let e=await ha.request.post(ha.urls.url_web_account_login,{app_id:this.appId,channel_id:this.channelId,name:t,name2:this.accountName,password:n,password2:this.passcode,type:1});this.handleLoginResult(e)}catch(e){console.error(e)}}async handleLogoutClick(e){e.preventDefault(),console.log(`执行退出登录...`);try{let e=await ha.request.post(ha.urls.url_web_login_out,{});this.handleLoginOutResult(e)}catch(e){console.error(e)}console.log(`退出登录`)}async handleResetPasswordSubmit(e){if(e.preventDefault(),this.passcode!==this.confirmPasscode){alert(`รหัสผ่านไม่ตรงกัน (两次输入的密码不一致)`);return}console.log(`执行注册...`,this.accountName,this.passcode);try{let e=await ha.request.post(ha.urls.url_web_reset_password,{name:this.accountName,passcode:this.passcode});alert(`สมัครสมาชิกสำเร็จ! (注册成功)`),this.handleLoginResult(e)}catch(e){console.error(e)}}async handleUnbind(e){if(e===`Account`)this.switchToBindingResetPassword();else if(confirm(`您確定要解綁 ${e} 帳戶嗎?`))try{this._isLoading=!0,console.log(`正在請求解綁: ${e}`),await new Promise(e=>setTimeout(e,2e3)),alert(`${e} 帳戶解綁成功!`)}catch(e){console.error(e),alert(`操作失敗,請稍後再試`)}finally{this._isLoading=!1}}async handleThirdLogin(e,t){console.log(`执行三方登录...`,this.accountName,this.passcode);try{let n=await ha.request.post(ha.urls.url_web_third_login,{app_id:this.appId,type:e,open_id:t});alert(`สมัครสมาชิกสำเร็จ! (注册成功)`),this.handleLoginResult(n)}catch(e){console.error(e)}}};Q([H({type:Boolean,reflect:!0})],$.prototype,`visible`,void 0),Q([H({type:String})],$.prototype,`appId`,void 0),Q([H({type:String})],$.prototype,`channelId`,void 0),Q([H({type:String})],$.prototype,`uid`,void 0),Q([H({type:String,attribute:`csrf-token`})],$.prototype,`csrfToken`,void 0),Q([H({type:String,attribute:`apple-client-id`})],$.prototype,`appleClientId`,void 0),Q([H({type:String,attribute:`apple-scope`})],$.prototype,`appleScope`,void 0),Q([H({type:String,attribute:`apple-state`})],$.prototype,`appleState`,void 0),Q([H({type:String,attribute:`apple-nonce`})],$.prototype,`appleNonce`,void 0),Q([H({type:Boolean,attribute:`apple-use-popup`})],$.prototype,`appleUsePopup`,void 0),Q([H({type:String,attribute:`apple-redirect-uri`})],$.prototype,`appleRedirectURI`,void 0),Q([H({type:String,attribute:`facebook-app-id`})],$.prototype,`facebookAppId`,void 0),Q([H({type:String,attribute:`view-mode`})],$.prototype,`currentView`,void 0),Q([Re()],$.prototype,`userInfo`,void 0),Q([Re()],$.prototype,`_isLoading`,void 0),Q([Re()],$.prototype,`accountName`,void 0),Q([Re()],$.prototype,`passcode`,void 0),Q([Re()],$.prototype,`confirmPasscode`,void 0),Q([Re()],$.prototype,`reset_password`,void 0),Q([Re()],$.prototype,`reset_new_password`,void 0),Q([Re()],$.prototype,`reset_new_confirm_password`,void 0),$=Q([Fe(`vela-login`)],$),Object.defineProperty(e,"VelaLogin",{enumerable:!0,get:function(){return $}})});
|
|
590
|
+
`}loadAppleSDK(){let e=document.createElement(`script`);e.src=`https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js`,e.onload=()=>{window.AppleID.auth.init({clientId:this.appleClientId,scope:this.appleScope,redirectURI:this.appleRedirectURI,state:this.appleState,nonce:this.appleNonce,usePopup:this.appleUsePopup}),document.addEventListener(`AppleIDSignInOnSuccess`,e=>{let t=e.detail.authorization.id_token;this.handleThirdLogin(`3`,t)}),document.addEventListener(`AppleIDSignInOnFailure`,e=>{console.error(e.detail.error)})},document.head.appendChild(e)}handleAppleClick(){window.AppleID.auth.signIn()}loadGoogleSDK(){let e=document.createElement(`script`);e.src=`https://accounts.google.com/gsi/client`,e.async=!0,e.onload=()=>{window.handleGoogleSignIn=e=>{console.log(`Google JWT: `,e.credential),this.handleThirdLogin(`2`,e.credential)}},document.head.appendChild(e)}loadFacebookSDK(){let e=document.createElement(`script`);e.src=`https://connect.facebook.net/en_US/sdk.js`,e.async=!0,e.defer=!0,e.crossOrigin=`anonymous`,e.onload=()=>{window.FB.init({appId:this.facebookAppId,cookie:!0,xfbml:!0,version:`v20.0`})},document.head.appendChild(e)}handleFacebookClick(){if(!window.FB){console.warn(`Facebook SDK not loaded`);return}window.FB.getLoginStatus(e=>{e.authResponse?this.handleThirdLogin(`1`,e.authResponse.userID):window.FB.login(e=>{e.authResponse?this.handleThirdLogin(`1`,e.authResponse.userID):console.log(`Facebook login cancelled`)},{scope:`public_profile`})})}handleLoginResult(e){console.log(`SDK接收到的数据类型是:`,typeof e,e),e.code===0?(this.dispatchEvent(new CustomEvent(`vela-login-success`,{detail:e.data})),this.uid=e.data.uid,this.visible=!1):alert(e.msg)}handleLoginOutResult(e){console.log(`SDK接收到的数据类型是:`,typeof e,e),e.code===0?(this.dispatchEvent(new CustomEvent(`vela-login-out`,{detail:e.data})),this.uid=``,this.switchToLogin()):alert(e.msg)}async handleAccountLoginSubmit(e){if(e.preventDefault(),!this.accountName||!this.passcode){alert(`账号和密码不能为空!`);return}this._isLoading=!0;let t=da.default.MD5(this.accountName).toString(),n=da.default.MD5(this.passcode).toString();console.log(`执行登录...`,this.accountName,this.passcode);try{let e=await ha.request.post(ha.urls.url_web_account_login,{app_id:this.appId,channel_id:this.channelId,name:t,name2:this.accountName,password:n,password2:this.passcode,type:3});this.handleLoginResult(e)}catch(e){console.error(e)}this._isLoading=!1}async handleAccountRegisterSubmit(e){if(e.preventDefault(),this.passcode!==this.confirmPasscode){alert(`รหัสผ่านไม่ตรงกัน (两次输入的密码不一致)`);return}if(!this.accountName||!this.passcode){alert(`账号和密码不能为空!`);return}this._isLoading=!0;let t=da.default.MD5(this.accountName).toString(),n=da.default.MD5(this.passcode).toString();console.log(`执行注册...`,this.accountName,this.passcode);try{let e=await ha.request.post(ha.urls.url_web_account_login,{app_id:this.appId,channel_id:this.channelId,name:t,name2:this.accountName,password:n,password2:this.passcode,type:1});this.handleLoginResult(e)}catch(e){console.error(e)}this._isLoading=!1}async handleLogoutClick(e){e.preventDefault(),this._isLoading=!0,console.log(`执行退出登录...`);try{let e=await ha.request.post(ha.urls.url_web_login_out,{});this.handleLoginOutResult(e)}catch(e){console.error(e)}this._isLoading=!1,console.log(`退出登录`)}async handleResetPasswordSubmit(e){if(e.preventDefault(),this.passcode!==this.confirmPasscode){alert(`รหัสผ่านไม่ตรงกัน (两次输入的密码不一致)`);return}console.log(`执行注册...`,this.accountName,this.passcode);try{let e=await ha.request.post(ha.urls.url_web_reset_password,{name:this.accountName,passcode:this.passcode});alert(`สมัครสมาชิกสำเร็จ! (注册成功)`),this.handleLoginResult(e)}catch(e){console.error(e)}}async handleUnbind(e){if(e===`Account`)this.switchToBindingResetPassword();else if(confirm(`您確定要解綁 ${e} 帳戶嗎?`))try{this._isLoading=!0,console.log(`正在請求解綁: ${e}`),await new Promise(e=>setTimeout(e,2e3)),alert(`${e} 帳戶解綁成功!`)}catch(e){console.error(e),alert(`操作失敗,請稍後再試`)}finally{this._isLoading=!1}}async handleThirdLogin(e,t){console.log(`执行三方登录...`,this.accountName,this.passcode);try{let n=await ha.request.post(ha.urls.url_web_third_login,{app_id:this.appId,type:e,open_id:t});alert(`สมัครสมาชิกสำเร็จ! (注册成功)`),this.handleLoginResult(n)}catch(e){console.error(e)}}};Q([H({type:Boolean,reflect:!0})],$.prototype,`visible`,void 0),Q([H({type:String})],$.prototype,`appId`,void 0),Q([H({type:String})],$.prototype,`channelId`,void 0),Q([H({type:String})],$.prototype,`uid`,void 0),Q([H({type:String,attribute:`csrf-token`})],$.prototype,`csrfToken`,void 0),Q([H({type:String,attribute:`apple-client-id`})],$.prototype,`appleClientId`,void 0),Q([H({type:String,attribute:`apple-scope`})],$.prototype,`appleScope`,void 0),Q([H({type:String,attribute:`apple-state`})],$.prototype,`appleState`,void 0),Q([H({type:String,attribute:`apple-nonce`})],$.prototype,`appleNonce`,void 0),Q([H({type:Boolean,attribute:`apple-use-popup`})],$.prototype,`appleUsePopup`,void 0),Q([H({type:String,attribute:`apple-redirect-uri`})],$.prototype,`appleRedirectURI`,void 0),Q([H({type:String,attribute:`facebook-app-id`})],$.prototype,`facebookAppId`,void 0),Q([H({type:String,attribute:`view-mode`})],$.prototype,`currentView`,void 0),Q([Re()],$.prototype,`userInfo`,void 0),Q([Re()],$.prototype,`_isLoading`,void 0),Q([Re()],$.prototype,`accountName`,void 0),Q([Re()],$.prototype,`passcode`,void 0),Q([Re()],$.prototype,`confirmPasscode`,void 0),Q([Re()],$.prototype,`reset_password`,void 0),Q([Re()],$.prototype,`reset_new_password`,void 0),Q([Re()],$.prototype,`reset_new_confirm_password`,void 0),$=Q([Fe(`vela-login`)],$),Object.defineProperty(e,"VelaLogin",{enumerable:!0,get:function(){return $}})});
|