Forráskód Böngészése

添加微信登录调试按钮

chenritian 2 hete
szülő
commit
7ad4d5e980

+ 1 - 1
entry/src/main/ets/model/WechatModel.ets

@@ -31,7 +31,7 @@ export class WechatObj {
       let req = new SendAuthReq();
       req.isOption1 = false;
       req.nonAutomatic = true;
-      req.scope = 'snsapi_userinfo';
+      req.scope = 'snsapi_userinfo'; //应用授权作用域,获取用户个人信息则填写 snsapi_userinfo (只能填 snsapi_userinfo)
       req.state = 'none';
       req.transaction = 'test123';
       let finished = await WechatUtil.getWechatApi().sendReq(ContextHelper.UIAbilityContext, req);

+ 5 - 1
entry/src/main/ets/pages/Index.ets

@@ -139,8 +139,12 @@ struct Index {
             .width(100)
             .height(50)
             .onClick(() => {
+              jDBViewModel.wechatItem.handleWeChatLogin()
 
-
+            })
+            .position({
+              left: '50%',
+              bottom: 200
             })
 
         }.width('100%').height('100%')

+ 6 - 0
entry/src/main/module.json5

@@ -50,6 +50,12 @@
           }
         ],
       }
+    ],
+    "querySchemes": [
+      "https",
+      "weixin",
+      "wxopensdk",
+      "alipays"
     ]
   }
 }