This commit is contained in:
guilinlan jin
2024-07-17 15:32:20 +08:00
parent 0d2ee2e2ca
commit 78820169ff
67 changed files with 28891 additions and 27825 deletions

View File

@@ -2,10 +2,8 @@
<view class="container" style="background-color: #fff; position: relative">
<!-- <web-view style="height: 200px" src="https://www.tmrjournals.com/aliplayer.html"></web-view> -->
<web-view
ref="webview"
@onPostMessage="getMessage"
:style="{ width: '200px', height: '200px' }"
src="../../../../static/html/aliplayer.html"
></web-view>
<button class="button" @click="evalJs">evalJs(改变webview背景颜色)</button>
</view>
@@ -156,7 +154,10 @@ export default {
});
},
handlePostMessage(res) {
this.$refs.webview.evalJs(`handleMessage()`);
this.$nextTick(()=>{
this.$refs.webview.handleMessage();
})
},
getMessage(e) {
uni.showModal({
@@ -166,9 +167,24 @@ export default {
},
async init(data, isChange) {
setTimeout(() => {
this.handlePostMessage("测试传参");
}, 200);
let wv = plus.webview.create(
'/static/html/aliplayer.html?',//date保证不走缓存
'batch_view',
{
top: '0',
left: '0',
height: '100%',
width: '100%'
},
{
data: {
token: '2222',
userInfo: '44444',
implantType: 'uniapp'
}
}) //不用data键值对的方式传的话h5接收后会是多个字段而非一个对象
let currentWebview = this.$mp.page.$getAppWebview()
currentWebview.append(wv);//重要,否则会失效
this.platform = this.$platform;
this.isfresh = true;
@@ -184,11 +200,7 @@ export default {
// await this.getVideo(isChange);
// this.$emit("child-event", this.timer);
},
// 发送数据方法
sendMsg() {
// appScan 就是上面说的 在H5定义在window中的方法
this.$refs.webview.evalJs("document.body.style.background ='#00FF00'");
},
async getData(data, isChange) {
var that = this;
if (!this.isSetFirstTime) {
@@ -233,6 +245,7 @@ export default {
console.log(this.firstTime, "这是第一次播放时长");
}
this.isSetFirstTime = true;
},
async playVideo(e) {
this.videoContext = uni.createVideoContext("videoId", this);