目录
前言
组件库环境:uview 1x
检测是安卓还是ios
首先在onload中检测是安卓还是ios,ios的话 要做啥操作另外修改一下,这里主要是针对apk的更新
- onLoad() {
- <view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>//检测更新
- <view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>const type = uni.getSystemInfoSync().platform
- <view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>console.log(type, '机型')
- <view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>type == 'ios' ? '' : this.checkUpdates()
- },
复制代码 版本号对比
然后就是检测版本是否是最新,这里我说一下 plus.runtime.version 这玩意 在h5中不起作用,可以去看看官网的解释,在h5中需要使用下面代码块包裹下,不然报错
- // #ifdef APP-PLUS
- // #endif
复制代码 然后就是他获取到的版本就是manifest.json
文件中配置的版本信息(13.x.13)中间那一位,下边做了一个截取拿到的就是 打包发布配置的那一个版本号,对比版本号的时候需要一个接口,返回最新的版本号码,跟当前环境获取到的plus.runtime.version版本信息比较,一致的话就不用更新
我这接口返回的值,就用到最新apk下载地址和版本号,版本号要和你manifest.json文件中写的一致
直接调用默认浏览器打开下载地址的方法
- plus.runtime.openURL('下载url')
复制代码 downloadNum 这玩意是下载进度条的数量,页面展示进度条的代码(uview 版本 1x)
showdownLine这玩意是控制是否显示下载进度条,只有点了更新之后才会显示进度条
完整检测更新和下载文件代码
- <view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>
复制代码- checkUpdates() {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>//调用接口检查是否可以更新<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// #ifdef APP-PLUS<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>const localVersion = plus.runtime.version.split('.')[1]<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>console.log(localVersion)<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>this.$u.get(`/api-sys/sys/sysVersion/getVersion`, {}).then(res => {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>console.log(res);<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>if (res.code == 200) {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>const {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>version,<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>androidUrl,<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>updateContent<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>} = res.data<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>if (localVersion == version) {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>console.log('不需要更新')<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>} else {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>uni.showModal({ //提醒用户更新 <view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>title: "更新提示",<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>content: '是否更新',<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>success: (res) => {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>if (res.confirm) {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>this.doUpData(androidUrl)<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>this.showdownLine = true<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// plus.runtime.openURL(androidUrl)<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>}<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>}<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>})<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>}<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>} else {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>this.$u.toast(res.msg)<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>}<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>});<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// #endif},doUpData(Url) {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>uni.showLoading({<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>title: '更新中……'<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>})<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>const downloadTask = uni.downloadFile({ //执行下载<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>url: Url, //下载地址<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>timeout: 1000 * 30, //30秒超时时间<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>success: downloadResult => { //下载成功<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>console.log(downloadResult)<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>this.showdownLine = false<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>uni.hideLoading();<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>if (downloadResult.statusCode == 200) {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>plus.runtime.install( //安装软件<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>downloadResult.tempFilePath, {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>force: true<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>},<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>function(res) {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>plus.runtime.restart();<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>}<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>);<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>}<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>},<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>fail: err => {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>uni.hideLoading();<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>this.showdownLine = false<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>this.$u.toast(err.errMsg)<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>console.log(err)<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>},<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>complete: com => {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>console.log(com)<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>}<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>});<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// 下载进度<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>downloadTask.onProgressUpdate(res => {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// this.$u.toast(res.progress)<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>this.downloadNum = res.progress<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// console.log('下载进度' + res.progress);<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// console.log('已经下载的数据长度' + res.totalBytesWritten);<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// 满足测试条件,取消下载任务。<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// if (res.progress > 50) {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// <view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>downloadTask.abort();<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>// }<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>});},
复制代码 data部分
- data() {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>return {<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>downloadNum: null,<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>showdownLine: false,<view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view><view class="progress" v-if="showdownLine">
- <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
- </view>}},
复制代码 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |