Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
scout | 086a5fd1fa | 1 week ago |
@ -1,40 +1,89 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
import silenceUpdate from '@/uni_modules/rt-uni-update/js_sdk/silence-update.js' //引入静默更新
|
||||||
methods:{
|
import config from './config';
|
||||||
networkStatusChange(res){
|
export default {
|
||||||
if(res.isConnected){
|
methods: {
|
||||||
|
networkStatusChange(res) {
|
||||||
|
if (res.isConnected) {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url:'/pages/index/index'
|
url: "/pages/index/index",
|
||||||
})
|
});
|
||||||
}else{
|
} else {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url:'/pages/networko/index'
|
url: "/pages/networko/index",
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// 获取本地应用资源版本号
|
||||||
|
getLocalVersion() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
plus.runtime.getProperty(plus.runtime.appid, function (widgetInfo) {
|
||||||
|
resolve(widgetInfo);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 获取服务端应用资源版本号
|
||||||
|
getServerVersion(widgetInfo) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.request({
|
||||||
|
url: config.apiBaseUrl + "/version-info",
|
||||||
|
method:'POST',
|
||||||
|
data:{
|
||||||
|
edition_type:widgetInfo.appid,
|
||||||
|
version_type:uni.getSystemInfoSync().platform,
|
||||||
|
edition_number:Number(widgetInfo.versionCode)
|
||||||
|
},
|
||||||
|
success: (res) => {
|
||||||
|
console.log("res4", res.data.data);
|
||||||
|
resolve(res.data.data);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
}
|
// 检测更新
|
||||||
|
checkUpdate() {
|
||||||
|
// 检测更新
|
||||||
|
this.getLocalVersion().then((widgetInfo) => {
|
||||||
|
console.log("本地信息", widgetInfo);
|
||||||
|
console.log("config", config);
|
||||||
|
this.getServerVersion(widgetInfo).then((serverVersionData) => {
|
||||||
|
if (Number(widgetInfo.versionCode) !== serverVersionData.edition_number) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url:
|
||||||
|
"/uni_modules/rt-uni-update/components/rt-uni-update/rt-uni-update?obj=" +
|
||||||
|
JSON.stringify(serverVersionData),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onLaunch: function() {
|
|
||||||
},
|
},
|
||||||
onShow: function() {
|
onLaunch: function () {},
|
||||||
|
onShow: function () {
|
||||||
|
console.log("App 1onShow");
|
||||||
|
this.checkUpdate();
|
||||||
|
// silenceUpdate('555')
|
||||||
|
// uni.navigateTo({
|
||||||
|
// url: "./uni_modules/rt-uni-update/components/rt-uni-update/rt-uni-update",
|
||||||
|
// });
|
||||||
uni.getNetworkType({
|
uni.getNetworkType({
|
||||||
success:(res)=> {
|
success: (res) => {
|
||||||
if(res.networkType==='none') {
|
if (res.networkType === "none") {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: '/pages/networko/index'
|
url: "/pages/networko/index",
|
||||||
})
|
});
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
});
|
||||||
uni.onNetworkStatusChange(this.networkStatusChange);
|
uni.onNetworkStatusChange(this.networkStatusChange);
|
||||||
},
|
},
|
||||||
onHide: function() {
|
onHide: function () {
|
||||||
uni.offNetworkStatusChange(this.networkStatusChange)
|
uni.offNetworkStatusChange(this.networkStatusChange);
|
||||||
}
|
},
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/*每个页面公共css */
|
/*每个页面公共css */
|
||||||
</style>
|
</style>
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{}
|
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
Loading…
Reference in New Issue