Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
d7f847f4
Unverified
提交
d7f847f4
authored
11月 11, 2024
作者:
Sherman Chu
提交者:
GitHub
11月 11, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
migrate to "@tencent/wechat_open_sdk" v1.0.3 and add impl for plugin.launchMiniProgram (#671)
上级
157e9964
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
46 行增加
和
11 行删除
+46
-11
oh-package.json5
ohos/oh-package.json5
+1
-1
FluwxPlugin.ets
ohos/src/main/ets/components/plugin/FluwxPlugin.ets
+33
-2
FluwxAuthHandler.ets
.../main/ets/components/plugin/handlers/FluwxAuthHandler.ets
+5
-5
FluwxShareHandler.ets
...main/ets/components/plugin/handlers/FluwxShareHandler.ets
+6
-2
WXAPiHandler.ets
.../src/main/ets/components/plugin/handlers/WXAPiHandler.ets
+1
-1
没有找到文件。
ohos/oh-package.json5
浏览文件 @
d7f847f4
...
...
@@ -7,6 +7,6 @@
"license": "Apache-2.0",
"dependencies": {
"@ohos/flutter_ohos": "file:./har/flutter.har",
"@tencent/wechat_open_sdk": "
^1.0.0
"
"@tencent/wechat_open_sdk": "
1.0.3
"
}
}
ohos/src/main/ets/components/plugin/FluwxPlugin.ets
浏览文件 @
d7f847f4
...
...
@@ -93,8 +93,7 @@ export default class FluwxPlugin implements FlutterPlugin, MethodCallHandler, Ab
result.notImplemented();
break;
case "launchMiniProgram":
// TODO
result.notImplemented();
this.launchMiniProgram(call, result);
break;
case "subscribeMsg":
// TODO
...
...
@@ -174,6 +173,11 @@ export default class FluwxPlugin implements FlutterPlugin, MethodCallHandler, Ab
this.onPayResp(resp);
return;
}
if (resp instanceof wechatSDK.LaunchMiniProgramResp) {
this.onLaunchMiniProgramResp(resp);
return;
}
}
// 微信回调 end
...
...
@@ -215,6 +219,20 @@ export default class FluwxPlugin implements FlutterPlugin, MethodCallHandler, Ab
this.channel?.invokeMethod("onPayResponse", _result);
}
onLaunchMiniProgramResp(resp: wechatSDK.LaunchMiniProgramResp) {
const _result: Map<string, ESObject> = new Map();
_result.set(KEY_ERR_CODE, resp.errCode);
_result.set(KEY_ERR_STR, resp.errStr);
_result.set(KEY_TYPE, resp.type);
_result.set(KEY_OPEN_ID, resp.openId);
if (resp.extMsg) {
_result.set("extMsg", resp.extMsg);
}
this.channel?.invokeMethod("onLaunchMiniProgramResponse", _result);
}
async handlePay(call: MethodCall, result: MethodResult) {
if (!WXAPiHandler.wxApi) {
result.error("Unassigned WxApi", "please config wxapi first", null);
...
...
@@ -240,4 +258,16 @@ export default class FluwxPlugin implements FlutterPlugin, MethodCallHandler, Ab
attemptToResumeMsgFromWx(result: MethodResult) {
WXAPiHandler.wxApi?.handleWant(this.binding?.getAbility().launchWant, this)
}
async launchMiniProgram(call: MethodCall, result: MethodResult) {
const request = new wechatSDK.LaunchMiniProgramReq();
request.userName = call.argument("userName");
request.path = call.argument("path");
// sdk 内当前没 type 常量, 直接使用传入的参数
request.miniprogramType = call.argument("miniprogramType") ?? 0;
const done = await WXAPiHandler.wxApi?.sendReq(this.uiContext, request);
result.success(done);
}
}
\ No newline at end of file
ohos/src/main/ets/components/plugin/handlers/FluwxAuthHandler.ets
浏览文件 @
d7f847f4
...
...
@@ -47,7 +47,7 @@ export class FluwxAuthHandler implements OAuthCallback {
return this.diffDevOauth;
}
sendAuth(call: MethodCall, result: MethodResult) {
async
sendAuth(call: MethodCall, result: MethodResult) {
const req = new SendAuthReq();
req.isOption1 = false;
req.scope = call.argument("scope");
...
...
@@ -57,10 +57,10 @@ export class FluwxAuthHandler implements OAuthCallback {
req.openId = openid;
}
req.nonAutomatic = call.argument("nonAutomatic") ?? false;
result.success(WXAPiHandler.wxApi?.sendReq(
WXAPiHandler.uiContext,
req
))
const done = await WXAPiHandler.wxApi?.sendReq(WXAPiHandler.uiContext, req);
result.success(done);
}
authByQRCode(call: MethodCall, result: MethodResult) {
...
...
ohos/src/main/ets/components/plugin/handlers/FluwxShareHandler.ets
浏览文件 @
d7f847f4
...
...
@@ -54,7 +54,9 @@ export class FluwxShareHandler {
const req = new wechatSDK.SendMessageToWXReq();
req.message = mediaMsg;
result.success(WXAPiHandler.wxApi?.sendReq(WXAPiHandler.uiContext, req))
const done = await WXAPiHandler.wxApi?.sendReq(WXAPiHandler.uiContext, req);
result.success(done)
}
async shareImage(call: MethodCall, result: MethodResult) {
...
...
@@ -80,6 +82,7 @@ export class FluwxShareHandler {
const req = new wechatSDK.SendMessageToWXReq();
req.message = mediaMsg;
result.success(WXAPiHandler.wxApi?.sendReq(WXAPiHandler.uiContext, req));
const done = await WXAPiHandler.wxApi?.sendReq(WXAPiHandler.uiContext, req);
result.success(done);
}
}
\ No newline at end of file
ohos/src/main/ets/components/plugin/handlers/WXAPiHandler.ets
浏览文件 @
d7f847f4
import * as wechatOpenSDK from "@tencent/wechat_open_sdk"
import { MethodCall, MethodResult } from '@ohos/flutter_ohos'
import { bundle
, bundle
Manager, common } from '@kit.AbilityKit'
import { bundleManager, common } from '@kit.AbilityKit'
export class WXAPiHandler {
static wxApi: wechatOpenSDK.WXApi | null = null
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论