当前位置: 首页 > news >正文

网站建设项目需求在线网页制作

网站建设项目需求,在线网页制作,梅州做网站,营销型网站的建设软文需求:需要在app启动后进行检查更新,如果有更新就提示更新,可以点击确定更新或者暂时不更新,如果不更新,就将当前的时间进行缓存,并且再次进入时进行对比,只要超过一天时间就继续提醒检查更新 第…

需求:需要在app启动后进行检查更新,如果有更新就提示更新,可以点击确定更新或者暂时不更新,如果不更新,就将当前的时间进行缓存,并且再次进入时进行对比,只要超过一天时间就继续提醒检查更新

第一步获取缓存时间,如果有就获取当前时间进行对比

	const saveDtime = uni.getStorageSync('saveVersionDay')//判断当前的时间大于检查更新时间if (saveDtime) {const currentDay = dateCurrentDayTime()if (Number(currentDay) > Number(saveDtime)) this.updatevVersion()} else {this.updatevVersion()}
  1. 假设当有缓存时间就去检查更新,就执行updatevVersion操作
  2. 确认有更新就可以点击更新或者稍后更新

//检查版本

	async updatevVersion() {const apkName = '*****.apk'//获取当前是否有更新let res = await queryNewVersion({fileName: apkName})const _this = this//如果有更新执行更新操作if (res.data && res.data.code == 0 && res.data.data) {let fileComment = res.data.data.fileComment//获取当前版本号const version = plus.runtime.versionconsole.log(fileComment)if (fileComment != version) {uni.showModal({title: `发现新版本`,// title: `发现${fileComment}`,content: "确认更新",confirmText: '立即更新',cancelText: '稍后进行',success: (res) => {//确认检查更新if (res.confirm == true) {//当用户确定更新,执行更新,下面方法进行下载app_this.startDownload(fileComment, apkName)} else {//暂时不更新保存缓存时间const saveTime = dateCurrentDayTime()uni.setStorageSync('saveVersionDay', saveTime);}},fail: (res) => {}})} else {uni.showToast({title: '已是最新版本',icon: 'none'})}} else {uni.showToast({title: '已是最新版本',icon: 'none'})}},

第二步确认更新就执行startDownload方法

startDownload(versons, name) {this.popupShow = trueconst dowUrl = `${uploadUrl}${this.downloadPath}?fileName=${name}&version=${versons}`//loading加载this.isDownloading = true;//设置进度条初始值this.downloadProgress = 0;this.downloadMessage = '';const url = dowUrl//进行下载操作const task = uni.downloadFile({url: url,success: (res) => {console.log(res)if (res.statusCode === 200) {// 下载成功,保存文件路径到临时路径  const tempFilePath = res.tempFilePath;// 下载完成再把下载进度弹框关闭即可plus.runtime.install( //安装res.tempFilePath, {force: true},function(res) {this.popupShow = falseutils.showToast('更新成功,重启中');plus.runtime.restart();});// 这里你可以将文件保存到本地或者进行其他处理  this.downloadMessage = `下载成功,文件路径:${tempFilePath}`;} else {this.popupShow = falseuni.showToast({title: '下载失败',icon: 'none'})this.downloadMessage = `下载失败,状态码:${res.statusCode}`;}this.isDownloading = false;},fail: (err) => {this.downloadMessage = `下载失败,错误信息:${err.message}`;this.isDownloading = false;},complete: () => {// 无论成功或失败都会执行  }});const _this = this// 监听上传进度变化task.onProgressUpdate((res) => {this.downloadProgress = res.progress;if (res.progress == 100) {//取消弹框// task.abort()}});},

4.执行startDownload后就可以进行安装了
总结:会使用如下方法
使用uni-app的loading加载组件

<u-loading :show="true"></u-loading>

使用uni-app的progress组件

使用<progress :percent="downloadProgress" v-if="isDownloading" show-info></progress>组件

使用html5+检查版本

plus.runtime.version

使用html5+安装

plus.runtime.install()

使用downloadFile下载

uni.downloadFile({url:url})

组件展示

<u-modal :show-title="false" v-model="popupShow" ref="uModal" :show-confirm-button="false"><view class="progressBox"><view class=""><u-loading :show="true"></u-loading>更新中...</view><progress :percent="downloadProgress" v-if="isDownloading" show-info></progress></view>
</u-modal>
http://www.hkea.cn/news/694698/

相关文章:

  • 如何做旅游攻略网站长沙seo优化推荐
  • 长春火车站电话咨询电话快排seo
  • 龙城建设网站公司网站内容优化方法
  • 南通网站建设搭建网站卖链接
  • 驻马店市做网站seo臻系统
  • 找公司做网站怎么图片都要自己找百度推广官网电话
  • 网站小样用什么做seo外链平台热狗
  • 建站点的步骤sem是什么
  • 深圳专业做网站的衡水网站优化推广
  • 徐汇科技网站建设2345中国最好的网址站
  • 邢台论坛吧百度seo收录软件
  • 做国外服务器网站吗怎么让百度搜索靠前
  • 做动态图网站有哪些自建站怎么推广
  • web网站开发课程设计报告seo技术培训沈阳
  • 会宁网站建设公司网站优化助手
  • 网站设计制作体会2023年5月最新疫情
  • 月亮湾设计有限公司网站南宁seo产品优化服务
  • 福田欧曼服务站电话上海高端seo公司
  • 高端网站建设哪家好谷歌seo和百度seo
  • 前端写一个页面多少钱海口网站关键词优化
  • 浦东新区建设局官方网站东莞seo关键词
  • 在百度做橱柜网站进入百度一下官网
  • wordpress调用分类标签站长工具查询seo
  • 网站做全局搜索云南新闻最新消息今天
  • 公司网站推广方案长春seo代理
  • 网站地图怎么样做更利于收录手机百度搜索引擎入口
  • 中国建筑公司网站谷歌浏览器官方app下载
  • 厦门网站建设策划seo网站优化培训找哪些
  • 宝安区住房和建设局官方网站seo搜索引擎优化书籍
  • 省建设厅执业资格注册中心网站2023搜索最多的关键词