Procházet zdrojové kódy

微信登录获取授权码回调

chenritian před 2 týdny
rodič
revize
264b27170d

+ 16 - 3
entry/src/main/ets/model/JDBModel.ets

@@ -17,6 +17,10 @@ export interface RunH5Param {
 
 
 export class JDBObj {
+  /**
+   * 微信登录
+   * @returns
+   */
   async handleWeChatLogin(): Promise<void> {
     try {
       let req = new SendAuthReq();
@@ -31,6 +35,10 @@ export class JDBObj {
     }
   }
 
+  /**
+   * 微信支付
+   * @returns
+   */
   async handleWeChatPay(param: WeChatPayParams) {
     let req = new PayReq()
     req.appId = param.appid
@@ -44,13 +52,18 @@ export class JDBObj {
   }
 
 
+  /**
+   * 支付宝登录
+   */
   handleAlipayAuthorization() {
     ALiPayUtil.startAuthorization()
   }
 
-
+  /**
+   * 支付宝支付
+   * @param orderInfo
+   */
   handleAliPay(orderInfo: string) {
-    IBestToast.show({ message: '开始支付:请求参数:' + orderInfo })
     new Pay().pay(orderInfo, false).then((result) => {
       let message =
         `resultStatus: ${result.get('resultStatus')} memo: ${result.get('memo')} result: ${result.get('result')}`;
@@ -59,7 +72,7 @@ export class JDBObj {
         type: 'ali_pay',
         data: result.get('resultStatus')
       })
-      IBestToast.show({ message: message })
+      // IBestToast.show({ message: message })
     }).catch((error: BusinessError) => {
       console.log(error.message);
       IBestToast.show({

+ 4 - 0
entry/src/main/ets/utils/wechat/WXApiEventHandlerImpl.ets

@@ -97,6 +97,10 @@ export class WXApiEventHandlerImpl implements WXApiEventHandler {
         return;
       }
       //TODO 写微信调用后端接口逻辑
+      jDBViewModel.runJavaScript({
+        type:'wx_login',
+        data: response
+      })
 
     } catch (error) {
       IBestToast.show({ type: 'fail', message: '获取微信授权码失败' })