uniapp版本更新插件

摘要:
正文版本更新提示查找新版本并更新体验~{bbh}˂/vie

body

<view v-if="isgx==1">
<view class="bbgx">
<view class="bbgx1">
版本更新提示
</view>
<view class="bbgx2">
发现新版本,快去更新体验吧~
<view class="">

</view>
{{bbh}}
</view>
<view v-if="isgxjd==1">
<view :style="{ jdt + '%' }">

</view>
</view>
<view v-if="isgxjd==1">
更新进度:{{jdt}}%
</view>
<view class="bbgx3">
<view @tap="quxiao" v-if="isgxjd==0">
下次再说
</view>
<view @tap="queding" v-if="isgxjd==0">
立即更新
</view>
</view>
</view>
</view>

css

.bbgxw{
100%;
height: 100%;
position: fixed;
left: 0;
top: 0;
background: rgba(0,0,0,0.5);
z-index: 9999999999;
}
.bbgx{
80%;
height: auto;

background-color: white;
border-radius: 8px;
margin: 0 auto;
margin-top: 200px;
}
.bbgx1{
color: #474F66;
text-align: center;
font-size: 16px;
height: 50px;
100%;
font-weight: bold;
line-height: 50px;
}
.bbgx2{
color: #7A8299;
text-align: center;
font-size: 14px;
height: auto;
90%;
font-weight: 400;
line-height: 30px;
margin: 10px auto;
margin-top: 0px;
}
.bbgx3{
color: #7A8299;
text-align: center;
font-size: 14px;
height:55px;
100%;
font-weight: 400;
line-height: 20px;
margin: 0px auto;
position: relative;

}
.bbgx31{
position: absolute;
36%;
top: 10px;
left: 7%;
height: 30px;
box-sizing: border-box;
line-height: 28px;
text-align: center;
font-size: 14px;
border-radius: 15px;
color: #2385FB;
border: 1px solid #2385FB;
}
.bbgx32{
position: absolute;
36%;
top: 10px;
right: 7%;
height: 30px;
box-sizing: border-box;
line-height: 28px;
background-color: #2385FB;
text-align: center;
font-size: 14px;
border-radius: 15px;
color: #fff;
border: 1px solid #2385FB;
}
.gxjd{
86%;
height: 6px;
border-radius: 3px;
margin: 0 auto;
background: #EDEDED;
position: relative;
overflow: hidden;
}
.gxjdin{
0%;
height: 6px;
border-radius: 3px;
position: absolute;
left: 0;
top: 0;
background: linear-gradient(to right,#4DA5FE,#2D83F4);
}
.gxjdx{
height: 30px;
line-height: 30px;
color: #7A8299;
text-align: center;
font-size: 14px;
height: auto;
90%;
font-weight: 400;
line-height: 30px;
margin: 10px auto;
margin-top: 0px;
}

data

bbh:"",
xzurl:"",
isgx:0,
isgxjd:0,
jdt:0,

onShow() {

// #ifdef APP-PLUS
this.gxck()
// #endif




},

method

quxiao(){
this.isgx=0
},
queding(){

// 获取应用版本号
let version = plus.runtime.version;
console.log(version)


//plus.runtime.openURL(this.xzurl)
if(1){
//整包

/*

  权限

<uses-permission android:name="android.permission.INSTALL_PACKAGES"/>  
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>

*/
plus.runtime.openURL(this.xzurl)
}else{
let _this = this
_this.isgxjd=1

// 创建下载任务

const downloadTask = uni.downloadFile({
url: _this.xzurl,
success: (res) => {
if (res.statusCode === 200) {
_this.isgx=0
_this.isgxjd=0
var watiting = plus.nativeUI.showWaiting("安装中...")
// watiting.setTitle("安装中...");
// console.log('>>>>>tempFilePath', res.tempFilePath)
plus.runtime.install(res.tempFilePath, {
force: true
}, function (succ) {
// console.log('install success...');
plus.nativeUI.closeWaiting();
plus.nativeUI.alert('更新完成!', function () {
// 热更新完成自动重启
plus.runtime.restart();
});
}, function (e) {
plus.nativeUI.closeWaiting();
plus.nativeUI.alert('更新失败,点击确认手动更新', function () {
plus.runtime.openURL(_this.xzurl);
plus.runtime.quit();
});
console.error('install fail...', e);
});
}
}
});
downloadTask.onProgressUpdate((res) => {
console.log('下载进度' + res.progress);
// console.log('已经下载的数据长度' + res.totalBytesWritten);
// console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
_this.jdt=res.progress
});
}

},
gxck(){
if(0){
this.isgx=0
}else{
this.isgx=1
}

this.bbh='1.0.2'
this.xzurl='https://e1624fbe-0b72-486b-91b2-292a62708202.apk'
uni.request({
url: '',
method: 'GET',
data: {
'token':uni.getStorageSync('token'),
},
success: res => {
//console.log(444)
//console.log(res);

//let version = plus.runtime.version;
},
fail: () => {

},
complete: () => {


}
});
},

免责声明:文章转载自《uniapp版本更新插件》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Java子类重写父类方法注意问题收集(转)powerdesign建立联系下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

libffi

Thisislibffi.info,由libffi.texi生产的bymakeinfo版本5.1。本手册适用于libffi,一个可移植的外国函数接口库。版权所有(C)200820102011redhat,股份有限公司。许可授予复制、分发...

安装qmake与环境变量解析

如果你已经有了qmake,可以跳过这里,请看10分钟学会使用qmake。手动安装qmake在手工连编Qt之前,下面这些环境变量必须被设置:QMAKESPEC这个必须设置为你所使用的系统的平台和编译器的组合。当编译完成时,qmake已经可以使用了。这里对添加环境变量时,是在path里头添加,还是new一个变量有点疑惑。而如果是new的话,当我们在为程序添加路径...

Unreal Engine is exiting due to D3D device being lost

先保证显卡驱动最新,然后打开显卡控制面板,关掉“优化以提高计算性能”:参考的是游戏玩家的经验总结:黄卡驱动“优化以提升计算性能”疑问,附简单测试其他常规解决方案:1.[Solved]UnrealEngineisexitingduetoD3Ddevicebeinglost2.由于D3D设备丢失,如何解决虚幻引擎闪退问题?...

浅谈JEECG多数据源的使用

首先,我们将简要介绍JEECG是什么。JEECG主张简单的功能由代码生成器直接生成,复杂的业务由表单定制,业务流程由工作流实现和扩展,开发人员编写特殊的业务逻辑。让我们重点讨论JEECG3.5GA中多个数据源的使用。JEECG3.5提供多个数据源的功能。JEECG多数据源的设计直接使用Springjdbc连接,独立于Hibernate、Mybatis和其他持...

springboot项目:扫描不到其他模块的包 Parameter 0 of constructor in com.zjxf.repository.UserRepository

报错信息如下:***************************APPLICATIONFAILEDTOSTART***************************Description:Parameter0ofconstructorincom.zjxf.repository.UserRepositoryrequiredabeanoftype'java...

阿里云ECS专有网络产品三个步骤配置教程

阿里云ECS专有网络产品三个步骤配置教程阿里云专有网络节点已开通地域:美国硅谷可用区1B,新加坡可用区A,北京可用区A,深圳可用区A,杭州可用区D,上海可用区B举个栗子:购买美国硅谷可用区1BECS专有网络产品步骤一:创建专有网络VPC并创建交换机(选择创建美国硅谷专有网络)步骤二:ECS页面创建订单购买(ECS页面选择美国硅谷可用区1B)步骤三:EIP配置...