The APP project developed by uni-app realizes the function of checking the updated version

Encounter such a requirement in the project, first look at the effect of the page
insert image description here
Click Check Settings to update the version

First, you need to request the background interface to obtain some information about the version, and then call the method. The code is as follows:

fetchgetLatestApp({
    
      //调用后台接口获取版本信息
					params: {
    
    
						//司机1
						type: '1'
					}
				}).then(data => {
    
    
					console.log(data) //调用后台接口获取版本信息

					let update_info = {
    
    
						version: data.result[0].version, //线上版本
						now_url: baseUrl + 'sys/common/static/' + encodeURI(data.result[0]
							.download_url), //更新链接
						silent: 0, //是否是静默更新
						force: 0, //是否是强制更新
						net_check: 1, //非WIfi是否提示
						note: data.result[0].note, //更新内容
					}
					console.log('hhhhh');
					console.log(baseUrl + 'sys/common/static/' + data.result[0].download_url);
					console.log(data.result[0].version);
					checkUpdate(update_info, type).then(res => {
    
    
						if (res.msg) {
    
    
							plus.nativeUI.toast(res.msg);
						}
					}); ///检查更新
				})

Guess you like

Origin blog.csdn.net/Quentin0823/article/details/130315573