86 lines
1.7 KiB
Plaintext
86 lines
1.7 KiB
Plaintext
<template>
|
|
<view class="content" :style="webviewStyles">
|
|
<web ref="webview" class="webview" :src="webUrl" @message="onMessage"></web>
|
|
</view>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
import PageContainer from '@/components/page-container/page-container.vue'
|
|
|
|
|
|
export default {
|
|
components: {
|
|
PageContainer
|
|
},
|
|
data() {
|
|
const sysinfo = uni.getSystemInfoSync();
|
|
return {
|
|
hideviewStyles: {
|
|
height: "0px",
|
|
width: "0px",
|
|
},
|
|
webviewStyles: {
|
|
height: sysinfo.windowHeight + "px",
|
|
width: sysinfo.windowWidth + "px",
|
|
},
|
|
isWebView: false,
|
|
|
|
status: "init",
|
|
prize: [],
|
|
// webUrl: 'https://zfunbox.cn/m/chou-box-luck.html',
|
|
webUrl: "http://192.168.1.26:5502/%E5%85%AC%E5%8F%B8/%E5%B7%A5%E4%BD%9C/%E5%8F%8B%E8%BE%BE/%E8%90%BD%E5%9C%B0%E9%A1%B5/chou-box-luck.html",
|
|
};
|
|
|
|
},
|
|
onLoad(option) {
|
|
uni.showToast({
|
|
title: "初始化"
|
|
})
|
|
this.load(option);
|
|
// this.$c.msg('aaa')
|
|
uni.showToast({
|
|
title: "初始化"
|
|
})
|
|
},
|
|
methods: {
|
|
async load(option) {
|
|
console.log(option);
|
|
uni.showToast({
|
|
title: "初始化"
|
|
})
|
|
if (option.key != null) {
|
|
this.prize = uni.getStorageSync("prizes-lucky");
|
|
console.log(this.prize);
|
|
this.sendMessageToWeb("prizes-lucky", this.prize)
|
|
}
|
|
},
|
|
onMessage(e) {
|
|
console.log('收到WebView消息:', e)
|
|
// this.sendMessageToWeb();
|
|
},
|
|
sendMessageToWeb(action, data) {
|
|
// 获取 webview 引用
|
|
const webview = this.$refs.webview;
|
|
console.log(webview);
|
|
// 向网页发送消息
|
|
webview.postMessage({
|
|
action: action,
|
|
data: data,
|
|
timestamp: Date.now()
|
|
});
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.content {
|
|
|
|
background-color: #fff;
|
|
}
|
|
|
|
.webview {
|
|
flex: 1;
|
|
}
|
|
</style> |