uniapp 开发的app检测版本实现自动下载更新(展示下载进度) ...

打印 上一主题 下一主题

主题 831|帖子 831|积分 2493

目录



前言

组件库环境:uview 1x
检测是安卓还是ios

首先在onload中检测是安卓还是ios,ios的话 要做啥操作另外修改一下,这里主要是针对apk的更新
  1. onLoad() {
  2. <view class="progress" v-if="showdownLine">
  3.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  4. </view>//检测更新
  5. <view class="progress" v-if="showdownLine">
  6.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  7. </view>const type = uni.getSystemInfoSync().platform
  8. <view class="progress" v-if="showdownLine">
  9.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  10. </view>console.log(type, '机型')
  11. <view class="progress" v-if="showdownLine">
  12.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  13. </view>type == 'ios' ? '' : this.checkUpdates()
  14. },
复制代码
版本号对比

然后就是检测版本是否是最新,这里我说一下 plus.runtime.version 这玩意 在h5中不起作用,可以去看看官网的解释,在h5中需要使用下面代码块包裹下,不然报错
  1. // #ifdef APP-PLUS
  2. // #endif
复制代码
然后就是他获取到的版本就是manifest.json
文件中配置的版本信息(13.x.13)中间那一位,下边做了一个截取拿到的就是 打包发布配置的那一个版本号,对比版本号的时候需要一个接口,返回最新的版本号码,跟当前环境获取到的plus.runtime.version版本信息比较,一致的话就不用更新

我这接口返回的值,就用到最新apk下载地址和版本号,版本号要和你manifest.json文件中写的一致

直接调用默认浏览器打开下载地址的方法

  1. plus.runtime.openURL('下载url')
复制代码
downloadNum 这玩意是下载进度条的数量,页面展示进度条的代码(uview 版本 1x)
showdownLine这玩意是控制是否显示下载进度条,只有点了更新之后才会显示进度条
完整检测更新和下载文件代码

  1. <view class="progress" v-if="showdownLine">
  2.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  3. </view>
复制代码
  1. checkUpdates() {<view class="progress" v-if="showdownLine">
  2.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  3. </view>//调用接口检查是否可以更新<view class="progress" v-if="showdownLine">
  4.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  5. </view>// #ifdef APP-PLUS<view class="progress" v-if="showdownLine">
  6.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  7. </view>const localVersion = plus.runtime.version.split('.')[1]<view class="progress" v-if="showdownLine">
  8.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  9. </view>console.log(localVersion)<view class="progress" v-if="showdownLine">
  10.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  11. </view>this.$u.get(`/api-sys/sys/sysVersion/getVersion`, {}).then(res => {<view class="progress" v-if="showdownLine">
  12.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  13. </view><view class="progress" v-if="showdownLine">
  14.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  15. </view>console.log(res);<view class="progress" v-if="showdownLine">
  16.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  17. </view><view class="progress" v-if="showdownLine">
  18.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  19. </view>if (res.code == 200) {<view class="progress" v-if="showdownLine">
  20.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  21. </view><view class="progress" v-if="showdownLine">
  22.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  23. </view><view class="progress" v-if="showdownLine">
  24.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  25. </view>const {<view class="progress" v-if="showdownLine">
  26.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  27. </view><view class="progress" v-if="showdownLine">
  28.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  29. </view><view class="progress" v-if="showdownLine">
  30.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  31. </view><view class="progress" v-if="showdownLine">
  32.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  33. </view>version,<view class="progress" v-if="showdownLine">
  34.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  35. </view><view class="progress" v-if="showdownLine">
  36.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  37. </view><view class="progress" v-if="showdownLine">
  38.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  39. </view><view class="progress" v-if="showdownLine">
  40.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  41. </view>androidUrl,<view class="progress" v-if="showdownLine">
  42.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  43. </view><view class="progress" v-if="showdownLine">
  44.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  45. </view><view class="progress" v-if="showdownLine">
  46.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  47. </view><view class="progress" v-if="showdownLine">
  48.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  49. </view>updateContent<view class="progress" v-if="showdownLine">
  50.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  51. </view><view class="progress" v-if="showdownLine">
  52.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  53. </view><view class="progress" v-if="showdownLine">
  54.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  55. </view>} = res.data<view class="progress" v-if="showdownLine">
  56.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  57. </view><view class="progress" v-if="showdownLine">
  58.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  59. </view><view class="progress" v-if="showdownLine">
  60.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  61. </view>if (localVersion == version) {<view class="progress" v-if="showdownLine">
  62.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  63. </view><view class="progress" v-if="showdownLine">
  64.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  65. </view><view class="progress" v-if="showdownLine">
  66.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  67. </view><view class="progress" v-if="showdownLine">
  68.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  69. </view>console.log('不需要更新')<view class="progress" v-if="showdownLine">
  70.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  71. </view><view class="progress" v-if="showdownLine">
  72.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  73. </view><view class="progress" v-if="showdownLine">
  74.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  75. </view>} else {<view class="progress" v-if="showdownLine">
  76.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  77. </view><view class="progress" v-if="showdownLine">
  78.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  79. </view><view class="progress" v-if="showdownLine">
  80.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  81. </view><view class="progress" v-if="showdownLine">
  82.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  83. </view>uni.showModal({ //提醒用户更新  <view class="progress" v-if="showdownLine">
  84.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  85. </view><view class="progress" v-if="showdownLine">
  86.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  87. </view><view class="progress" v-if="showdownLine">
  88.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  89. </view><view class="progress" v-if="showdownLine">
  90.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  91. </view><view class="progress" v-if="showdownLine">
  92.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  93. </view>title: "更新提示",<view class="progress" v-if="showdownLine">
  94.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  95. </view><view class="progress" v-if="showdownLine">
  96.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  97. </view><view class="progress" v-if="showdownLine">
  98.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  99. </view><view class="progress" v-if="showdownLine">
  100.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  101. </view><view class="progress" v-if="showdownLine">
  102.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  103. </view>content: '是否更新',<view class="progress" v-if="showdownLine">
  104.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  105. </view><view class="progress" v-if="showdownLine">
  106.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  107. </view><view class="progress" v-if="showdownLine">
  108.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  109. </view><view class="progress" v-if="showdownLine">
  110.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  111. </view><view class="progress" v-if="showdownLine">
  112.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  113. </view>success: (res) => {<view class="progress" v-if="showdownLine">
  114.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  115. </view><view class="progress" v-if="showdownLine">
  116.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  117. </view><view class="progress" v-if="showdownLine">
  118.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  119. </view><view class="progress" v-if="showdownLine">
  120.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  121. </view><view class="progress" v-if="showdownLine">
  122.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  123. </view><view class="progress" v-if="showdownLine">
  124.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  125. </view>if (res.confirm) {<view class="progress" v-if="showdownLine">
  126.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  127. </view><view class="progress" v-if="showdownLine">
  128.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  129. </view><view class="progress" v-if="showdownLine">
  130.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  131. </view><view class="progress" v-if="showdownLine">
  132.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  133. </view><view class="progress" v-if="showdownLine">
  134.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  135. </view><view class="progress" v-if="showdownLine">
  136.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  137. </view><view class="progress" v-if="showdownLine">
  138.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  139. </view>this.doUpData(androidUrl)<view class="progress" v-if="showdownLine">
  140.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  141. </view><view class="progress" v-if="showdownLine">
  142.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  143. </view><view class="progress" v-if="showdownLine">
  144.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  145. </view><view class="progress" v-if="showdownLine">
  146.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  147. </view><view class="progress" v-if="showdownLine">
  148.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  149. </view><view class="progress" v-if="showdownLine">
  150.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  151. </view><view class="progress" v-if="showdownLine">
  152.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  153. </view>this.showdownLine = true<view class="progress" v-if="showdownLine">
  154.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  155. </view><view class="progress" v-if="showdownLine">
  156.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  157. </view><view class="progress" v-if="showdownLine">
  158.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  159. </view><view class="progress" v-if="showdownLine">
  160.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  161. </view><view class="progress" v-if="showdownLine">
  162.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  163. </view><view class="progress" v-if="showdownLine">
  164.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  165. </view><view class="progress" v-if="showdownLine">
  166.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  167. </view>// plus.runtime.openURL(androidUrl)<view class="progress" v-if="showdownLine">
  168.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  169. </view><view class="progress" v-if="showdownLine">
  170.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  171. </view><view class="progress" v-if="showdownLine">
  172.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  173. </view><view class="progress" v-if="showdownLine">
  174.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  175. </view><view class="progress" v-if="showdownLine">
  176.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  177. </view><view class="progress" v-if="showdownLine">
  178.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  179. </view>}<view class="progress" v-if="showdownLine">
  180.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  181. </view><view class="progress" v-if="showdownLine">
  182.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  183. </view><view class="progress" v-if="showdownLine">
  184.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  185. </view><view class="progress" v-if="showdownLine">
  186.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  187. </view><view class="progress" v-if="showdownLine">
  188.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  189. </view>}<view class="progress" v-if="showdownLine">
  190.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  191. </view><view class="progress" v-if="showdownLine">
  192.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  193. </view><view class="progress" v-if="showdownLine">
  194.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  195. </view><view class="progress" v-if="showdownLine">
  196.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  197. </view>})<view class="progress" v-if="showdownLine">
  198.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  199. </view><view class="progress" v-if="showdownLine">
  200.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  201. </view><view class="progress" v-if="showdownLine">
  202.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  203. </view>}<view class="progress" v-if="showdownLine">
  204.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  205. </view><view class="progress" v-if="showdownLine">
  206.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  207. </view>} else {<view class="progress" v-if="showdownLine">
  208.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  209. </view><view class="progress" v-if="showdownLine">
  210.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  211. </view><view class="progress" v-if="showdownLine">
  212.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  213. </view>this.$u.toast(res.msg)<view class="progress" v-if="showdownLine">
  214.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  215. </view><view class="progress" v-if="showdownLine">
  216.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  217. </view>}<view class="progress" v-if="showdownLine">
  218.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  219. </view>});<view class="progress" v-if="showdownLine">
  220.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  221. </view>// #endif},doUpData(Url) {<view class="progress" v-if="showdownLine">
  222.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  223. </view>uni.showLoading({<view class="progress" v-if="showdownLine">
  224.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  225. </view><view class="progress" v-if="showdownLine">
  226.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  227. </view>title: '更新中……'<view class="progress" v-if="showdownLine">
  228.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  229. </view>})<view class="progress" v-if="showdownLine">
  230.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  231. </view>const downloadTask = uni.downloadFile({ //执行下载<view class="progress" v-if="showdownLine">
  232.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  233. </view><view class="progress" v-if="showdownLine">
  234.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  235. </view>url: Url, //下载地址<view class="progress" v-if="showdownLine">
  236.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  237. </view><view class="progress" v-if="showdownLine">
  238.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  239. </view>timeout: 1000 * 30, //30秒超时时间<view class="progress" v-if="showdownLine">
  240.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  241. </view><view class="progress" v-if="showdownLine">
  242.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  243. </view>success: downloadResult => { //下载成功<view class="progress" v-if="showdownLine">
  244.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  245. </view><view class="progress" v-if="showdownLine">
  246.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  247. </view><view class="progress" v-if="showdownLine">
  248.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  249. </view>console.log(downloadResult)<view class="progress" v-if="showdownLine">
  250.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  251. </view><view class="progress" v-if="showdownLine">
  252.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  253. </view><view class="progress" v-if="showdownLine">
  254.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  255. </view>this.showdownLine = false<view class="progress" v-if="showdownLine">
  256.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  257. </view><view class="progress" v-if="showdownLine">
  258.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  259. </view><view class="progress" v-if="showdownLine">
  260.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  261. </view>uni.hideLoading();<view class="progress" v-if="showdownLine">
  262.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  263. </view><view class="progress" v-if="showdownLine">
  264.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  265. </view><view class="progress" v-if="showdownLine">
  266.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  267. </view>if (downloadResult.statusCode == 200) {<view class="progress" v-if="showdownLine">
  268.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  269. </view><view class="progress" v-if="showdownLine">
  270.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  271. </view><view class="progress" v-if="showdownLine">
  272.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  273. </view><view class="progress" v-if="showdownLine">
  274.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  275. </view>plus.runtime.install( //安装软件<view class="progress" v-if="showdownLine">
  276.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  277. </view><view class="progress" v-if="showdownLine">
  278.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  279. </view><view class="progress" v-if="showdownLine">
  280.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  281. </view><view class="progress" v-if="showdownLine">
  282.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  283. </view><view class="progress" v-if="showdownLine">
  284.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  285. </view>downloadResult.tempFilePath, {<view class="progress" v-if="showdownLine">
  286.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  287. </view><view class="progress" v-if="showdownLine">
  288.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  289. </view><view class="progress" v-if="showdownLine">
  290.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  291. </view><view class="progress" v-if="showdownLine">
  292.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  293. </view><view class="progress" v-if="showdownLine">
  294.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  295. </view><view class="progress" v-if="showdownLine">
  296.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  297. </view>force: true<view class="progress" v-if="showdownLine">
  298.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  299. </view><view class="progress" v-if="showdownLine">
  300.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  301. </view><view class="progress" v-if="showdownLine">
  302.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  303. </view><view class="progress" v-if="showdownLine">
  304.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  305. </view><view class="progress" v-if="showdownLine">
  306.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  307. </view>},<view class="progress" v-if="showdownLine">
  308.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  309. </view><view class="progress" v-if="showdownLine">
  310.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  311. </view><view class="progress" v-if="showdownLine">
  312.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  313. </view><view class="progress" v-if="showdownLine">
  314.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  315. </view><view class="progress" v-if="showdownLine">
  316.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  317. </view>function(res) {<view class="progress" v-if="showdownLine">
  318.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  319. </view><view class="progress" v-if="showdownLine">
  320.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  321. </view><view class="progress" v-if="showdownLine">
  322.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  323. </view><view class="progress" v-if="showdownLine">
  324.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  325. </view><view class="progress" v-if="showdownLine">
  326.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  327. </view><view class="progress" v-if="showdownLine">
  328.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  329. </view>plus.runtime.restart();<view class="progress" v-if="showdownLine">
  330.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  331. </view><view class="progress" v-if="showdownLine">
  332.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  333. </view><view class="progress" v-if="showdownLine">
  334.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  335. </view><view class="progress" v-if="showdownLine">
  336.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  337. </view><view class="progress" v-if="showdownLine">
  338.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  339. </view>}<view class="progress" v-if="showdownLine">
  340.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  341. </view><view class="progress" v-if="showdownLine">
  342.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  343. </view><view class="progress" v-if="showdownLine">
  344.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  345. </view><view class="progress" v-if="showdownLine">
  346.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  347. </view>);<view class="progress" v-if="showdownLine">
  348.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  349. </view><view class="progress" v-if="showdownLine">
  350.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  351. </view><view class="progress" v-if="showdownLine">
  352.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  353. </view>}<view class="progress" v-if="showdownLine">
  354.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  355. </view><view class="progress" v-if="showdownLine">
  356.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  357. </view>},<view class="progress" v-if="showdownLine">
  358.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  359. </view><view class="progress" v-if="showdownLine">
  360.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  361. </view>fail: err => {<view class="progress" v-if="showdownLine">
  362.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  363. </view><view class="progress" v-if="showdownLine">
  364.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  365. </view><view class="progress" v-if="showdownLine">
  366.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  367. </view>uni.hideLoading();<view class="progress" v-if="showdownLine">
  368.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  369. </view><view class="progress" v-if="showdownLine">
  370.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  371. </view><view class="progress" v-if="showdownLine">
  372.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  373. </view>this.showdownLine = false<view class="progress" v-if="showdownLine">
  374.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  375. </view><view class="progress" v-if="showdownLine">
  376.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  377. </view><view class="progress" v-if="showdownLine">
  378.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  379. </view>this.$u.toast(err.errMsg)<view class="progress" v-if="showdownLine">
  380.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  381. </view><view class="progress" v-if="showdownLine">
  382.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  383. </view><view class="progress" v-if="showdownLine">
  384.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  385. </view>console.log(err)<view class="progress" v-if="showdownLine">
  386.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  387. </view><view class="progress" v-if="showdownLine">
  388.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  389. </view>},<view class="progress" v-if="showdownLine">
  390.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  391. </view><view class="progress" v-if="showdownLine">
  392.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  393. </view>complete: com => {<view class="progress" v-if="showdownLine">
  394.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  395. </view><view class="progress" v-if="showdownLine">
  396.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  397. </view><view class="progress" v-if="showdownLine">
  398.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  399. </view>console.log(com)<view class="progress" v-if="showdownLine">
  400.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  401. </view><view class="progress" v-if="showdownLine">
  402.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  403. </view>}<view class="progress" v-if="showdownLine">
  404.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  405. </view>});<view class="progress" v-if="showdownLine">
  406.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  407. </view>// 下载进度<view class="progress" v-if="showdownLine">
  408.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  409. </view>downloadTask.onProgressUpdate(res => {<view class="progress" v-if="showdownLine">
  410.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  411. </view><view class="progress" v-if="showdownLine">
  412.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  413. </view>// this.$u.toast(res.progress)<view class="progress" v-if="showdownLine">
  414.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  415. </view><view class="progress" v-if="showdownLine">
  416.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  417. </view>this.downloadNum = res.progress<view class="progress" v-if="showdownLine">
  418.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  419. </view><view class="progress" v-if="showdownLine">
  420.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  421. </view>// console.log('下载进度' + res.progress);<view class="progress" v-if="showdownLine">
  422.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  423. </view><view class="progress" v-if="showdownLine">
  424.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  425. </view>// console.log('已经下载的数据长度' + res.totalBytesWritten);<view class="progress" v-if="showdownLine">
  426.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  427. </view><view class="progress" v-if="showdownLine">
  428.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  429. </view>// console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);<view class="progress" v-if="showdownLine">
  430.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  431. </view><view class="progress" v-if="showdownLine">
  432.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  433. </view>// 满足测试条件,取消下载任务。<view class="progress" v-if="showdownLine">
  434.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  435. </view><view class="progress" v-if="showdownLine">
  436.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  437. </view>// if (res.progress > 50) {<view class="progress" v-if="showdownLine">
  438.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  439. </view><view class="progress" v-if="showdownLine">
  440.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  441. </view>// <view class="progress" v-if="showdownLine">
  442.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  443. </view>downloadTask.abort();<view class="progress" v-if="showdownLine">
  444.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  445. </view><view class="progress" v-if="showdownLine">
  446.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  447. </view>// }<view class="progress" v-if="showdownLine">
  448.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  449. </view>});},
复制代码
data部分

  1. data() {<view class="progress" v-if="showdownLine">
  2.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  3. </view>return {<view class="progress" v-if="showdownLine">
  4.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  5. </view><view class="progress" v-if="showdownLine">
  6.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  7. </view>downloadNum: null,<view class="progress" v-if="showdownLine">
  8.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  9. </view><view class="progress" v-if="showdownLine">
  10.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  11. </view>showdownLine: false,<view class="progress" v-if="showdownLine">
  12.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  13. </view><view class="progress" v-if="showdownLine">
  14.         <u-line-progress :striped="true" :percent="downloadNum" :striped-active="true"></u-line-progress>
  15. </view>}},
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

尚未崩坏

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表