vela-h5-sdk 0.0.26 → 0.0.28

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.
@@ -7144,8 +7144,8 @@ var $ = class extends Me {
7144
7144
  return;
7145
7145
  }
7146
7146
  window.FB.getLoginStatus((e) => {
7147
- e.authResponse ? this.handleThirdLogin("1", e.authResponse.userID) : window.FB.login((e) => {
7148
- e.authResponse ? this.handleThirdLogin("1", e.authResponse.userID) : console.log("Facebook login cancelled");
7147
+ e.authResponse ? (console.log("fb接收到的数据类型是:", typeof e.authResponse, e.authResponse), this.handleThirdLogin("1", e.authResponse.userID)) : window.FB.login((t) => {
7148
+ t.authResponse ? (console.log("fb接收到的数据类型是:", typeof e.authResponse, e.authResponse), this.handleThirdLogin("1", t.authResponse.userID)) : console.log("Facebook login cancelled");
7149
7149
  }, { scope: "public_profile" });
7150
7150
  });
7151
7151
  }
@@ -7284,6 +7284,7 @@ var $ = class extends Me {
7284
7284
  try {
7285
7285
  let n = await Z.request.post(Z.urls.url_web_third_login, {
7286
7286
  app_id: this.appId,
7287
+ channel_id: this.channelId,
7287
7288
  bind_type: e,
7288
7289
  openid: t
7289
7290
  });
@@ -7297,8 +7298,9 @@ var $ = class extends Me {
7297
7298
  try {
7298
7299
  let n = await Z.request.post(Z.urls.url_web_third_bind, {
7299
7300
  app_id: this.appId,
7300
- type: e,
7301
- open_id: t
7301
+ channel_id: this.channelId,
7302
+ bind_type: e,
7303
+ openid: t
7302
7304
  });
7303
7305
  alert("สมัครสมาชิกสำเร็จ! (注册成功)"), this.handleLoginResult(n);
7304
7306
  } catch (e) {
@@ -632,4 +632,4 @@
632
632
  </div>
633
633
  <div class="input-line"></div>
634
634
  </div>
635
- `}showToast(e,t=2e3){this._tip=e,this._toastTimer&&clearTimeout(this._toastTimer),this._toastTimer=setTimeout(()=>{this._tip=``,this._toastTimer=null},t)}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.showToast(`登录成功`),this.dispatchEvent(new CustomEvent(`vela-login-out`,{detail:[]})),setTimeout(()=>{this.dispatchEvent(new CustomEvent(`vela-login-success`,{detail:e.data})),this.uid=e.data.uid,this.visible=!1},1e3)):this.showToast(e.msg,3500)}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()):this.showToast(e.msg,3500)}handleResetPasswordResult(e){console.log(`SDK接收到的数据类型是:`,typeof e,e),e.code===0?(this.showToast(`密码修改成功`),this.closeBtnTap(),this.reset_password=``,this.reset_new_password=``,this.reset_new_confirm_password=``):this.showToast(e.msg,3500)}handleBindWaysResult(e){console.log(`SDK接收到的数据类型是:`,typeof e,e),e.code===0?this.binding_info=e.data:this.showToast(e.msg,3500)}handleUnBindResult(e){console.log(`SDK接收到的数据类型是:`,typeof e,e),e.code===0?(this.showToast(`解绑成功`),this.closeBtnTap()):this.showToast(e.msg,3500)}async handleAccountLoginSubmit(e){if(e.preventDefault(),!this.accountName||!this.passcode){alert(`账号和密码不能为空!`);return}this._isLoading=!0;let t=fa.default.MD5(this.accountName).toString(),n=fa.default.MD5(this.passcode).toString();console.log(`执行登录...`,this.accountName,this.passcode);try{let e=await Z.request.post(Z.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=fa.default.MD5(this.accountName).toString(),n=fa.default.MD5(this.passcode).toString();console.log(`执行注册...`,this.accountName,this.passcode);try{let e=await Z.request.post(Z.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 Z.request.post(Z.urls.url_web_login_out,{});this.handleLoginOutResult(e)}catch(e){console.error(e)}this._isLoading=!1,console.log(`退出登录`)}async handleResetPasswordSubmit(e){if(e.preventDefault(),console.log(`执行重置密码...`,this.reset_password,this.reset_new_password),this.reset_new_password!==this.reset_new_confirm_password){alert(`รหัสผ่านไม่ตรงกัน (两次输入的密码不一致)`);return}if(!this.reset_password||!this.reset_new_password){alert(`密码不能为空!`);return}this._isLoading=!0;let t=fa.default.MD5(this.reset_password).toString(),n=fa.default.MD5(this.reset_new_password).toString();try{let e=await Z.request.post(Z.urls.url_web_reset_password,{app_id:this.appId,old_password:t,password:n});this.handleResetPasswordResult(e)}catch(e){console.error(e)}this._isLoading=!1}async fetchBindWays(){this._isLoading=!0;try{let e=await Z.request.post(Z.urls.url_web_bind_ways,{app_id:this.appId});this.handleBindWaysResult(e)}catch(e){console.error(e)}this._isLoading=!1}bindAction(e,t){t&&(e===`Account`?this.switchToBindingResetPassword():this.handleUnbind(e))}async handleUnbind(e){if(e===`Account`)this.switchToBindingResetPassword();else if(confirm(`您確定要解綁 ${e} 帳戶嗎?`))try{this._isLoading=!0,console.log(`正在請求解綁: ${e}`);let t=await Z.request.post(Z.urls.url_web_unbind,{app_id:this.appId,type:e});this.handleUnBindResult(t),alert(`${e} 帳戶解綁成功!`),this.switchToUserBinding()}catch(e){console.error(e),alert(`操作失敗,請稍後再試`)}finally{this._isLoading=!1}}async handleThirdLogin(e,t){console.log(`执行三方登录...`,e,t);try{let n=await Z.request.post(Z.urls.url_web_third_login,{app_id:this.appId,bind_type:e,openid:t});this.handleLoginResult(n)}catch(e){console.error(e)}}async handleThirdBind(e,t){console.log(`执行三方登录...`,this.accountName,this.passcode);try{let n=await Z.request.post(Z.urls.url_web_third_bind,{app_id:this.appId,type:e,open_id:t});alert(`สมัครสมาชิกสำเร็จ! (注册成功)`),this.handleLoginResult(n)}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})],$.prototype,`uid`,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([Le({type:String,attribute:`view-mode`})],$.prototype,`currentView`,void 0),Q([Re()],$.prototype,`_isLoading`,void 0),Q([Re()],$.prototype,`_tip`,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([Re()],$.prototype,`binding_info`,void 0),$=Q([Pe(`vela-login`)],$),Object.defineProperty(e,"VelaLogin",{enumerable:!0,get:function(){return $}})});
635
+ `}showToast(e,t=2e3){this._tip=e,this._toastTimer&&clearTimeout(this._toastTimer),this._toastTimer=setTimeout(()=>{this._tip=``,this._toastTimer=null},t)}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?(console.log(`fb接收到的数据类型是:`,typeof e.authResponse,e.authResponse),this.handleThirdLogin(`1`,e.authResponse.userID)):window.FB.login(t=>{t.authResponse?(console.log(`fb接收到的数据类型是:`,typeof e.authResponse,e.authResponse),this.handleThirdLogin(`1`,t.authResponse.userID)):console.log(`Facebook login cancelled`)},{scope:`public_profile`})})}handleLoginResult(e){console.log(`SDK接收到的数据类型是:`,typeof e,e),e.code===0?(this.showToast(`登录成功`),this.dispatchEvent(new CustomEvent(`vela-login-out`,{detail:[]})),setTimeout(()=>{this.dispatchEvent(new CustomEvent(`vela-login-success`,{detail:e.data})),this.uid=e.data.uid,this.visible=!1},1e3)):this.showToast(e.msg,3500)}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()):this.showToast(e.msg,3500)}handleResetPasswordResult(e){console.log(`SDK接收到的数据类型是:`,typeof e,e),e.code===0?(this.showToast(`密码修改成功`),this.closeBtnTap(),this.reset_password=``,this.reset_new_password=``,this.reset_new_confirm_password=``):this.showToast(e.msg,3500)}handleBindWaysResult(e){console.log(`SDK接收到的数据类型是:`,typeof e,e),e.code===0?this.binding_info=e.data:this.showToast(e.msg,3500)}handleUnBindResult(e){console.log(`SDK接收到的数据类型是:`,typeof e,e),e.code===0?(this.showToast(`解绑成功`),this.closeBtnTap()):this.showToast(e.msg,3500)}async handleAccountLoginSubmit(e){if(e.preventDefault(),!this.accountName||!this.passcode){alert(`账号和密码不能为空!`);return}this._isLoading=!0;let t=fa.default.MD5(this.accountName).toString(),n=fa.default.MD5(this.passcode).toString();console.log(`执行登录...`,this.accountName,this.passcode);try{let e=await Z.request.post(Z.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=fa.default.MD5(this.accountName).toString(),n=fa.default.MD5(this.passcode).toString();console.log(`执行注册...`,this.accountName,this.passcode);try{let e=await Z.request.post(Z.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 Z.request.post(Z.urls.url_web_login_out,{});this.handleLoginOutResult(e)}catch(e){console.error(e)}this._isLoading=!1,console.log(`退出登录`)}async handleResetPasswordSubmit(e){if(e.preventDefault(),console.log(`执行重置密码...`,this.reset_password,this.reset_new_password),this.reset_new_password!==this.reset_new_confirm_password){alert(`รหัสผ่านไม่ตรงกัน (两次输入的密码不一致)`);return}if(!this.reset_password||!this.reset_new_password){alert(`密码不能为空!`);return}this._isLoading=!0;let t=fa.default.MD5(this.reset_password).toString(),n=fa.default.MD5(this.reset_new_password).toString();try{let e=await Z.request.post(Z.urls.url_web_reset_password,{app_id:this.appId,old_password:t,password:n});this.handleResetPasswordResult(e)}catch(e){console.error(e)}this._isLoading=!1}async fetchBindWays(){this._isLoading=!0;try{let e=await Z.request.post(Z.urls.url_web_bind_ways,{app_id:this.appId});this.handleBindWaysResult(e)}catch(e){console.error(e)}this._isLoading=!1}bindAction(e,t){t&&(e===`Account`?this.switchToBindingResetPassword():this.handleUnbind(e))}async handleUnbind(e){if(e===`Account`)this.switchToBindingResetPassword();else if(confirm(`您確定要解綁 ${e} 帳戶嗎?`))try{this._isLoading=!0,console.log(`正在請求解綁: ${e}`);let t=await Z.request.post(Z.urls.url_web_unbind,{app_id:this.appId,type:e});this.handleUnBindResult(t),alert(`${e} 帳戶解綁成功!`),this.switchToUserBinding()}catch(e){console.error(e),alert(`操作失敗,請稍後再試`)}finally{this._isLoading=!1}}async handleThirdLogin(e,t){console.log(`执行三方登录...`,e,t);try{let n=await Z.request.post(Z.urls.url_web_third_login,{app_id:this.appId,channel_id:this.channelId,bind_type:e,openid:t});this.handleLoginResult(n)}catch(e){console.error(e)}}async handleThirdBind(e,t){console.log(`执行三方登录...`,this.accountName,this.passcode);try{let n=await Z.request.post(Z.urls.url_web_third_bind,{app_id:this.appId,channel_id:this.channelId,bind_type:e,openid:t});alert(`สมัครสมาชิกสำเร็จ! (注册成功)`),this.handleLoginResult(n)}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})],$.prototype,`uid`,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([Le({type:String,attribute:`view-mode`})],$.prototype,`currentView`,void 0),Q([Re()],$.prototype,`_isLoading`,void 0),Q([Re()],$.prototype,`_tip`,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([Re()],$.prototype,`binding_info`,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.26",
4
+ "version": "0.0.28",
5
5
  "type": "module",
6
6
  "description": "Vela H5 登录弹窗 SDK",
7
7
  "main": "./dist/vela-login-sdk.umd.js",