addnetconfirm
This commit is contained in:
parent
a7bc5506de
commit
951aabfe55
38
App.vue
38
App.vue
@ -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)
|
||||
|
@ -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',
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user