2025-01-10 15:49:19 +08:00
|
|
|
<template>
|
|
|
|
|
<view>
|
2025-03-14 15:15:54 +08:00
|
|
|
<web-view :update-title="false" :webview-styles="webviewStyles" @message="getMessage" :src="webViewSrc"
|
|
|
|
|
style="height: 100%;"></web-view>
|
2025-01-10 15:49:19 +08:00
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-04-27 15:58:51 +08:00
|
|
|
|
2025-01-10 15:49:19 +08:00
|
|
|
let wv // 计划创建的webview
|
|
|
|
|
export default {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
webViewHeight: 0,
|
|
|
|
|
webviewStyles: {
|
2025-03-14 15:15:54 +08:00
|
|
|
top: "30px",
|
2025-01-10 15:49:19 +08:00
|
|
|
},
|
2025-04-27 15:58:51 +08:00
|
|
|
phoneNumber: uni.getStorageSync('mobile'),
|
|
|
|
|
token: uni.getStorageSync('token'),
|
|
|
|
|
// webViewSrc:`http://sgwpdm.ah.sgcc.com.cn/canteen/h5yz/#/pages/stage/index?mobile=${uni.getStorageSync('mobile')}&token=${uni.getStorageSync('token')}`
|
|
|
|
|
// webViewSrc:`../../static/station/index.html?mobile=${uni.getStorageSync('mobile')}&token=${uni.getStorageSync('token')}`
|
2025-01-10 15:49:19 +08:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
2025-04-27 15:58:51 +08:00
|
|
|
webViewSrc() {
|
|
|
|
|
console.log(`../../static/station/index.html?mobile=${uni.getStorageSync('mobile')}&token=${uni.getStorageSync('token')}`)
|
|
|
|
|
return `../../static/station/index.html?mobile=${uni.getStorageSync('mobile')}&token=${uni.getStorageSync('token')}`;//生产环境
|
|
|
|
|
// return `http://sgwpdm.ah.sgcc.com.cn/canteen/h5yz/#/pages/stage/index?mobile=${this.phoneNumber}&token=${this.token}`;//生产环境
|
|
|
|
|
// return `http://192.168.0.244:16789/jy-station/#/pages/stage/index?mobile=${this.phoneNumber}&token=${this.token}`;//244
|
|
|
|
|
// return `http://192.168.2.91:8080/#/pages/stage/index?mobile=${this.phoneNumber}&token=${this.token}`;//本地
|
|
|
|
|
}
|
2025-04-22 13:05:32 +08:00
|
|
|
},
|
|
|
|
|
onLoad() {
|
|
|
|
|
window.onmessage = (e) =>{
|
|
|
|
|
console.log(e)
|
|
|
|
|
if (e.data.type == 'stage_navigateBack') {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: '/pages/system'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (e.data.type == 'logOut') {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: '/pages/login'
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-01-10 15:49:19 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
onReady() {
|
2025-04-22 13:05:32 +08:00
|
|
|
// // #ifdef APP-PLUS
|
|
|
|
|
// const currentWebview = this.$scope.$getAppWebview() // 获取当前页面的webview对象
|
|
|
|
|
// setTimeout(function() {
|
|
|
|
|
// wv = currentWebview.children()[0]
|
|
|
|
|
// wv.setStyle({
|
|
|
|
|
// scalable: true
|
|
|
|
|
// })
|
|
|
|
|
// }, 1000); // 如果是页面初始化调用时,需要延时一下
|
|
|
|
|
// // #endif
|
|
|
|
|
// window.addEventListener("message", this.getMessage());
|
2025-03-14 15:15:54 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
getMessage(event) { //在H5端使用通信返回App端
|
|
|
|
|
console.log(event, '0000000000000000000000000')
|
|
|
|
|
if (event.data.data.arg.action == 'stage_navigateBack') {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: '/pages/system'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (event.data.data.arg.action == 'logOut') {
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
url: '/pages/login'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-01-10 15:49:19 +08:00
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
page {
|
|
|
|
|
background: #fff;
|
|
|
|
|
}
|
|
|
|
|
</style>
|