1 Star 0 Fork 0

测试仓库/webViewCommunication

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
XingChaoYang 提交于 2024-04-19 13:34 +08:00 . [A]添加websocket桥接属性
import {
HtmWebSocket
} from "./util/htm-websocket";
// app.js
App({
// web-view页面嵌套的地址
webViewUrl: 'https://www.haitaiint.com/htmp/phone/#',
// 文件存储基础地址
fileBasePath: wx.env.USER_DATA_PATH + '/htm-weixin',
// 待执行参数
transferList: [],
// 待回传值列表
resultList: [],
// 顶部导航栏信息
statusBarInfo: {
// 是否在启用
statusBarFlag: 'N',
// 导航栏颜色
statusBarColor: ''
},
// websocket所需参数
options: {
ip: 'fzhaitaiinc.com',
port: '56703'
},
// websocket实例
websocket: null,
/**
* 监听小程序启动或切前台
*/
onShow() {
// 启动连接
HtmWebSocket.setMqConn(this.options);
// 创建设备MQ连接配置(默认上线者为appCode+appVer)
let sysMqConnectConfig = HtmWebSocket.createSystemMqConnectConfig(
'HTMD', // 产品CODE
'v5.0', // 产品VER
// 生命周期设置
{
// 接收消息
received: function (receiveMessage) {
// receiveMessage格式见消息格式
console.log('主题编码:' + receiveMessage.topicCode);
console.log('消息内容:' + receiveMessage.msgBody);
console.log('消息:' + receiveMessage.msgContent);
}
}
);
// 启动连接,上线者为HTMDv5.0(ws协议通过网页地址自动决定)
HtmWebSocket.start(sysMqConnectConfig);
}
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/test-warehouse-y/web-view-communication.git
git@gitee.com:test-warehouse-y/web-view-communication.git
test-warehouse-y
web-view-communication
webViewCommunication
master

搜索帮助