addnetconfirm

This commit is contained in:
scout 2024-10-28 15:31:46 +08:00
parent a7bc5506de
commit 951aabfe55
3 changed files with 137 additions and 96 deletions

38
App.vue
View File

@ -1,22 +1,58 @@
<script>
export default {
data() {
return {
//
lastNetworkStatus: null
}
},
methods: {
// APP
isFirstOpen(){
let isFirstOpen = uni.getStorageSync('isFirstOpen')
if (!isFirstOpen) {
uni.setStorageSync('isFirstOpen', true)
return true
}
return false
},
networkStatusChange(res) {
if (res.isConnected) {
//
if (this.isFirstOpen()) {
uni.redirectTo({
url: '/pages/index/index'
})
}
//
if (this.lastNetworkStatus === false) {
uni.showModal({
title: "提示",
content: "当前设备网络发生更改,是否刷新页面?",
success: function (res) {
if (res.confirm) {
uni.redirectTo({
url: '/pages/index/index'
})
} else if (res.cancel) {
}
},
});
}
} else {
uni.redirectTo({
url: '/pages/networko/index'
})
}
this.lastNetworkStatus = res.isConnected
}
},
onLaunch: function () {
},
onShow: function () {
uni.onNetworkStatusChange(this.networkStatusChange);
uni.getNetworkType({
success: (res) => {
if (res.networkType === 'none') {
@ -27,7 +63,7 @@
}
}
})
uni.onNetworkStatusChange(this.networkStatusChange);
},
onHide: function () {
uni.offNetworkStatusChange(this.networkStatusChange)

View File

@ -2,7 +2,7 @@ const env = 'prod';
const configs = {
LocalTest: {
apiBaseUrl: 'https://warehouse.szjixun.cn/oa_backend',
h5Url:'http://192.168.88.29:8080/#/'
h5Url:'http://192.168.88.30:8080/#/'
},
dev: {
apiBaseUrl: 'https://warehouse.szjixun.cn/oa_backend',

View File

@ -4,16 +4,23 @@
</template>
<script setup>
import { ref } from 'vue'
import {onExit } from "@dcloudio/uni-app";
import { onExit, onShow, onLoad } from "@dcloudio/uni-app";
import config from "../../config"
const wv = plus.webview.create(config.h5Url,"custom-webview")
onShow(() => {
const { statusBarHeight } = uni.getSystemInfoSync()
const wv1 = plus.webview.getWebviewById("custom-webview");
let wv = null;
if (wv1) {
wv = wv1;
} else {
wv = plus.webview.create(config.h5Url, "custom-webview", {
top: statusBarHeight,
bottom: 0,
});
}
const currentPages = getCurrentPages()
const currentWebview = currentPages[currentPages.length - 1].$getAppWebview()
currentWebview.append(wv)
const {statusBarHeight} = uni.getSystemInfoSync()
wv.setStyle({
top: statusBarHeight,
bottom: 0,
})
import { Communication } from '../../utils/communication.js';
const commun = new Communication()
@ -96,6 +103,4 @@ const webLoad = (e) => {
};
</script>
<style>
</style>
<style></style>