Dining_Hall/pages/post/index.vue

80 lines
2.4 KiB
Vue
Raw Normal View History

<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>
</view>
</template>
<script>
import Cookies from "js-cookie";
let wv // 计划创建的webview
export default {
data() {
return {
webViewHeight: 0,
webviewStyles: {
2025-03-14 15:15:54 +08:00
top: "30px",
},
phoneNumber: Cookies.get('mobile'),
token: Cookies.get('token'),
// webViewSrc:`http://sgwpdm.ah.sgcc.com.cn/canteen/h5yz/#/pages/stage/index?mobile=${Cookies.get('mobile')}&token=${Cookies.get('token')}`
webViewSrc:`../../static/station/index.html?mobile=${Cookies.get('mobile')}&token=${Cookies.get('token')}`
};
},
computed: {
// webViewSrc() {
// console.log(`http://sgwpdm.ah.sgcc.com.cn/canteen/h5yz/#/pages/stage/index?mobile=${this.phoneNumber}&token=${this.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}`;//本地
// }
},
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'
});
}
}
},
onReady() {
// // #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'
});
}
}
},
};
</script>
<style lang="scss" scoped>
page {
background: #fff;
}
</style>