vela-h5-sdk 0.0.7 → 0.0.8

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.
@@ -6960,7 +6960,7 @@ var $ = class extends Me {
6960
6960
  }
6961
6961
  renderRegisterForm() {
6962
6962
  return me`
6963
- <form @submit="${this.handleRegisterSubmit}">
6963
+ <form @submit="${this.handleAccountRegisterSubmit}">
6964
6964
  <div class="field-group">
6965
6965
  <label class="input-label" for="reg-name">Account:</label>
6966
6966
  <input class="tel input-underline" id="reg-name" type="text" placeholder="กรุณากรอกหมายเลขบัญชี"
@@ -7145,11 +7145,9 @@ var $ = class extends Me {
7145
7145
  }, { scope: "public_profile" });
7146
7146
  });
7147
7147
  }
7148
- handleManualLoginSuccess(e) {
7149
- this.saveUserInfo(e), this.visible = !1, this.quickLoginResolve &&= (this.quickLoginResolve({
7150
- success: !0,
7151
- data: e
7152
- }), null), this.dispatchEvent(new CustomEvent("vela-login-success", { detail: e }));
7148
+ handleLoginResult(e) {
7149
+ let t = JSON.parse(e);
7150
+ t.code === 0 ? (this.dispatchEvent(new CustomEvent("vela-login-success", { detail: t.data })), this.visible = !1) : alert(t.msg);
7153
7151
  }
7154
7152
  async handleAccountLoginSubmit(e) {
7155
7153
  if (e.preventDefault(), !this.accountName || !this.passcode) {
@@ -7167,23 +7165,33 @@ var $ = class extends Me {
7167
7165
  password2: this.passcode,
7168
7166
  type: 3
7169
7167
  });
7170
- alert("สมัครสมาชิกสำเร็จ! (注册成功)"), this.handleManualLoginSuccess(e.data);
7168
+ this.handleLoginResult(e.data);
7171
7169
  } catch (e) {
7172
7170
  console.error(e);
7173
7171
  }
7174
7172
  }
7175
- async handleRegisterSubmit(e) {
7173
+ async handleAccountRegisterSubmit(e) {
7176
7174
  if (e.preventDefault(), this.passcode !== this.confirmPasscode) {
7177
7175
  alert("รหัสผ่านไม่ตรงกัน (两次输入的密码不一致)");
7178
7176
  return;
7179
7177
  }
7178
+ if (!this.accountName || !this.passcode) {
7179
+ alert("账号和密码不能为空!");
7180
+ return;
7181
+ }
7182
+ let t = da.default.MD5(this.accountName).toString(), n = da.default.MD5(this.passcode).toString();
7180
7183
  console.log("执行注册...", this.accountName, this.passcode);
7181
7184
  try {
7182
7185
  let e = await ha.request.post(ha.urls.url_web_account_login, {
7183
- name: this.accountName,
7184
- passcode: this.passcode
7186
+ app_id: this.appId,
7187
+ channel_id: this.channelId,
7188
+ name: t,
7189
+ name2: this.accountName,
7190
+ password: n,
7191
+ password2: this.passcode,
7192
+ type: 1
7185
7193
  });
7186
- alert("สมัครสมาชิกสำเร็จ! (注册成功)"), this.handleManualLoginSuccess(e.data);
7194
+ this.handleLoginResult(e.data);
7187
7195
  } catch (e) {
7188
7196
  console.error(e);
7189
7197
  }
@@ -7199,7 +7207,7 @@ var $ = class extends Me {
7199
7207
  name: this.accountName,
7200
7208
  passcode: this.passcode
7201
7209
  });
7202
- alert("สมัครสมาชิกสำเร็จ! (注册成功)"), this.handleManualLoginSuccess(e.data);
7210
+ alert("สมัครสมาชิกสำเร็จ! (注册成功)"), this.handleLoginResult(e.data);
7203
7211
  } catch (e) {
7204
7212
  console.error(e);
7205
7213
  }
@@ -7223,7 +7231,7 @@ var $ = class extends Me {
7223
7231
  type: e,
7224
7232
  open_id: t
7225
7233
  });
7226
- alert("สมัครสมาชิกสำเร็จ! (注册成功)"), this.handleManualLoginSuccess(n.data);
7234
+ alert("สมัครสมาชิกสำเร็จ! (注册成功)"), this.handleLoginResult(n.data);
7227
7235
  } catch (e) {
7228
7236
  console.error(e);
7229
7237
  }
@@ -464,7 +464,7 @@
464
464
  <p class="company">Hong Kong Happy Play Group</p>
465
465
  <br>
466
466
  `}renderRegisterForm(){return me`
467
- <form @submit="${this.handleRegisterSubmit}">
467
+ <form @submit="${this.handleAccountRegisterSubmit}">
468
468
  <div class="field-group">
469
469
  <label class="input-label" for="reg-name">Account:</label>
470
470
  <input class="tel input-underline" id="reg-name" type="text" placeholder="กรุณากรอกหมายเลขบัญชี"
@@ -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`})})}handleManualLoginSuccess(e){this.saveUserInfo(e),this.visible=!1,this.quickLoginResolve&&=(this.quickLoginResolve({success:!0,data:e}),null),this.dispatchEvent(new CustomEvent(`vela-login-success`,{detail:e}))}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,name:t,name2:this.accountName,password:n,password2:this.passcode,type:3});alert(`สมัครสมาชิกสำเร็จ! (注册成功)`),this.handleManualLoginSuccess(e.data)}catch(e){console.error(e)}}async handleRegisterSubmit(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_account_login,{name:this.accountName,passcode:this.passcode});alert(`สมัครสมาชิกสำเร็จ! (注册成功)`),this.handleManualLoginSuccess(e.data)}catch(e){console.error(e)}}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.handleManualLoginSuccess(e.data)}catch(e){console.error(e)}}handleDeleteAccount(){}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.handleManualLoginSuccess(n.data)}catch(e){console.error(e)}}};Q([Le({type:Boolean,reflect:!0})],$.prototype,`visible`,void 0),Q([Le({type:String})],$.prototype,`appId`,void 0),Q([Le({type:String})],$.prototype,`channelId`,void 0),Q([Le({type:String,attribute:`csrf-token`})],$.prototype,`csrfToken`,void 0),Q([Le({type:String,attribute:`apple-client-id`})],$.prototype,`appleClientId`,void 0),Q([Le({type:String,attribute:`apple-scope`})],$.prototype,`appleScope`,void 0),Q([Le({type:String,attribute:`apple-state`})],$.prototype,`appleState`,void 0),Q([Le({type:String,attribute:`apple-nonce`})],$.prototype,`appleNonce`,void 0),Q([Le({type:Boolean,attribute:`apple-use-popup`})],$.prototype,`appleUsePopup`,void 0),Q([Le({type:String,attribute:`apple-redirect-uri`})],$.prototype,`appleRedirectURI`,void 0),Q([Le({type:String,attribute:`facebook-app-id`})],$.prototype,`facebookAppId`,void 0),Q([Re()],$.prototype,`userInfo`,void 0),Q([Re()],$.prototype,`currentView`,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([Pe(`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){let t=JSON.parse(e);t.code===0?(this.dispatchEvent(new CustomEvent(`vela-login-success`,{detail:t.data})),this.visible=!1):alert(t.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,name:t,name2:this.accountName,password:n,password2:this.passcode,type:3});this.handleLoginResult(e.data)}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.data)}catch(e){console.error(e)}}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.data)}catch(e){console.error(e)}}handleDeleteAccount(){}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.data)}catch(e){console.error(e)}}};Q([Le({type:Boolean,reflect:!0})],$.prototype,`visible`,void 0),Q([Le({type:String})],$.prototype,`appId`,void 0),Q([Le({type:String})],$.prototype,`channelId`,void 0),Q([Le({type:String,attribute:`csrf-token`})],$.prototype,`csrfToken`,void 0),Q([Le({type:String,attribute:`apple-client-id`})],$.prototype,`appleClientId`,void 0),Q([Le({type:String,attribute:`apple-scope`})],$.prototype,`appleScope`,void 0),Q([Le({type:String,attribute:`apple-state`})],$.prototype,`appleState`,void 0),Q([Le({type:String,attribute:`apple-nonce`})],$.prototype,`appleNonce`,void 0),Q([Le({type:Boolean,attribute:`apple-use-popup`})],$.prototype,`appleUsePopup`,void 0),Q([Le({type:String,attribute:`apple-redirect-uri`})],$.prototype,`appleRedirectURI`,void 0),Q([Le({type:String,attribute:`facebook-app-id`})],$.prototype,`facebookAppId`,void 0),Q([Re()],$.prototype,`userInfo`,void 0),Q([Re()],$.prototype,`currentView`,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([Pe(`vela-login`)],$),Object.defineProperty(e,"VelaLogin",{enumerable:!0,get:function(){return $}})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vela-h5-sdk",
3
3
  "private": false,
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "type": "module",
6
6
  "description": "Vela H5 登录弹窗 SDK",
7
7
  "main": "./dist/vela-login-sdk.umd.js",