This commit is contained in:
2024-07-17 15:39:51 +08:00
parent 78820169ff
commit a3667d1fc1
3 changed files with 209 additions and 119 deletions

View File

@@ -1,11 +1,7 @@
<template>
<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
></web-view>
<button class="button" @click="evalJs">evalJs(改变webview背景颜色)</button>
<web-view v-if="isSetFirstTime"></web-view>
</view>
</template>
<script>
@@ -154,10 +150,9 @@ export default {
});
},
handlePostMessage(res) {
this.$nextTick(()=>{
this.$refs.webview.handleMessage();
})
this.$nextTick(() => {
this.$refs.webview.handleMessage();
});
},
getMessage(e) {
uni.showModal({
@@ -165,27 +160,26 @@ export default {
showCancel: false,
});
},
async init(data, isChange) {
initWebView() {
let wv = plus.webview.create(
'/static/html/aliplayer.html?',//date保证不走缓存
'batch_view',
{
top: '0',
left: '0',
height: '100%',
width: '100%'
"/static/html/aliplayer.html?", //date保证不走缓存
"batch_view",
{
top: "0",
left: "0",
height: "100%",
width: "100%",
},
{
data: {
videoData:this.videoData,
},
{
data: {
token: '2222',
userInfo: '44444',
implantType: 'uniapp'
}
}) //不用data键值对的方式传的话h5接收后会是多个字段而非一个对象
let currentWebview = this.$mp.page.$getAppWebview()
currentWebview.append(wv);//重要,否则会失效
}
); //不用data键值对的方式传的话h5接收后会是多个字段而非一个对象
let currentWebview = this.$mp.page.$getAppWebview();
currentWebview.append(wv); //重要,否则会失效
},
async init(data, isChange) {
this.platform = this.$platform;
this.isfresh = true;
console.log("at line 59:", "是否先走init这里", this.platform);
@@ -200,7 +194,7 @@ export default {
// await this.getVideo(isChange);
// this.$emit("child-event", this.timer);
},
async getData(data, isChange) {
var that = this;
if (!this.isSetFirstTime) {
@@ -244,8 +238,10 @@ export default {
// }
console.log(this.firstTime, "这是第一次播放时长");
}
this.isSetFirstTime = true;
await this.initWebView();
},
async playVideo(e) {
this.videoContext = uni.createVideoContext("videoId", this);