| | |
| | | export default { |
| | | data() { |
| | | return { |
| | | serverUrl: 'https://api.zj-yonghutong.com', |
| | | serverUrl: uni.getStorageSync('serverUrl')||'http://47.96.97.237/API', |
| | | showTc:false, |
| | | // 版本更新 |
| | | loadPercent:0, |
| | |
| | | if(uni.getSystemInfoSync().platform !=='ios'){ |
| | | this.update(); |
| | | }else if(uni.getSystemInfoSync().platform =='ios'){ |
| | | this.updateIOS(); |
| | | uni.showToast({ |
| | | title:'请使用安卓手机,以免发生兼容性问题', |
| | | icon:'none' |
| | | }) |
| | | } |
| | | //#endif |
| | | }, |
| | | methods: { |
| | | updateIOS() { |
| | | var _this = this; |
| | | uni.request({ |
| | | url: 'https://api.zj-yonghutong.com/v1/config/configKeyObject/APPVersionIOS', |
| | | header: { |
| | | 'Authorization': 'Bearer ' + getToken(), |
| | | 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' |
| | | }, |
| | | method: 'GET', |
| | | success: result => { |
| | | console.log(result) |
| | | if (result.data.code == 200) { |
| | | uni.setStorageSync('remarkURL',result.data.data.remark) |
| | | plus.runtime.getProperty(plus.runtime.appid, function(inf) { |
| | | console.log(inf) |
| | | uni.setStorageSync('vers',inf.version) |
| | | _this.vers = result.data.data.configValue |
| | | if(result.data.data.configValue > inf.versionCode){ //如果线上版本大于当前版本 |
| | | var configType = result.data.data.fieldOne //当前线上最新整包版本 |
| | | _this.fieldTwo = result.data.data.fieldTwo//更新内容 |
| | | if(configType > inf.versionCode ){//如果线上最新整包版本大于当前版本,则整包更新 |
| | | _this.showTc = true |
| | | console.log(555555) |
| | | }else{//热更新 |
| | | uni.showLoading({ |
| | | title:'发现新资源,正在下载中...', |
| | | mask:true, |
| | | }) |
| | | uni.downloadFile({ |
| | | url: 'https://api.zj-yonghutong.com/profile/kangleju.wgt', |
| | | success: (downloadResult) => { |
| | | if (downloadResult.statusCode === 200) { |
| | | uni.hideLoading() |
| | | plus.runtime.install(downloadResult.tempFilePath, { |
| | | force: false |
| | | }, function() { |
| | | console.log('install success...'); |
| | | plus.runtime.restart(); |
| | | }, function(e) { |
| | | console.error('install fail...'); |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | }, |
| | | }) |
| | | }, |
| | | update() { |
| | | var _this = this; |
| | | uni.request({ |
| | | url:'https://api.zj-yonghutong.com/v1/config/configKeyObject/APPVersion', |
| | | header: { |
| | | 'Authorization': 'Bearer ' + getToken(), |
| | | // 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' |
| | | }, |
| | | method: 'GET', |
| | | url:_this.serverUrl + '/LMES/AppUpdate', |
| | | data: { type:'' }, |
| | | success: result => { |
| | | if (result.data.code == 200) { |
| | | // console.log(1111111,result) |
| | | uni.setStorageSync('remarkURL',result.data.data.remark) |
| | | console.log(1111111,result) |
| | | // "DowloadPath": 整包更新下载地址, |
| | | // "HotDowloadPath": 最新热更新下载地址, |
| | | // "VersionNumber": "最新整包版本", |
| | | // "HotVersionNumber": "最新版本", |
| | | // "Content": "" |
| | | if (result.data.count == 1) { |
| | | var datas = result.data.data[0] |
| | | uni.setStorageSync('remarkURL',datas.DowloadPath) |
| | | plus.runtime.getProperty(plus.runtime.appid, function(inf) { |
| | | console.log(inf) |
| | | _this.vers = result.data.data.configValue |
| | | _this.vers = datas.HotVersionNumber |
| | | uni.setStorageSync('vers','V' + inf.version) |
| | | if(result.data.data.configValue > inf.versionCode){ //如果线上版本大于当前版本 |
| | | var configType = result.data.data.fieldOne //当前线上最新整包版本 |
| | | _this.fieldTwo = result.data.data.fieldTwo//更新内容 |
| | | if(configType > inf.versionCode ){//如果线上最新整包版本大于当前版本,则整包更新 |
| | | console.log(datas.HotVersionNumber,inf.versionCode,datas.HotVersionNumber > inf.versionCode) |
| | | if(datas.HotVersionNumber > inf.versionCode){ |
| | | var configType = datas.VersionNumber |
| | | _this.fieldTwo = datas.Content |
| | | if(configType > inf.versionCode ){ |
| | | _this.showTc = true |
| | | console.log(configType,_this.showTc,_this.fieldTwo) |
| | | }else{ |
| | |
| | | mask:true, |
| | | }) |
| | | uni.downloadFile({ |
| | | url: 'https://api.zj-yonghutong.com/profile/kangleju.wgt', |
| | | url: datas.HotDowloadPath, |
| | | success: (downloadResult) => { |
| | | if (downloadResult.statusCode === 200) { |
| | | uni.hideLoading() |
| | |
| | | }) |
| | | }, |
| | | upOn(){ |
| | | if(uni.getSystemInfoSync().platform !=='ios'){ |
| | | this.doUpData(); |
| | | this.loadPercent = 0 |
| | | }else if(uni.getSystemInfoSync().platform =='ios'){ |
| | | plus.runtime.openURL(uni.getStorageSync('remarkURL')); |
| | | } |
| | | this.doUpData(); |
| | | this.loadPercent = 0 |
| | | }, |
| | | doUpData() { |
| | | this.waitLine = true |
| | |
| | | width: 550rpx; |
| | | height: 730rpx; |
| | | position: absolute; |
| | | top: 10vh; |
| | | top: 20vh; |
| | | left: 100rpx; |
| | | background-image: url('../../../static/images/newVer.png'); |
| | | background-image: url('/static/images/newVer.png'); |
| | | background-position: center; |
| | | background-repeat: no-repeat; |
| | | background-size: cover; |