2025-05-13 17:18:07 +08:00
|
|
|
if("undefined"==typeof Promise||Promise.prototype.finally||(Promise.prototype.finally=function(e){const t=this.constructor;return this.then((l=>t.resolve(e()).then((()=>l))),(l=>t.resolve(e()).then((()=>{throw l}))))}),"undefined"!=typeof uni&&uni&&uni.requireGlobal){const e=uni.requireGlobal();ArrayBuffer=e.ArrayBuffer,Int8Array=e.Int8Array,Uint8Array=e.Uint8Array,Uint8ClampedArray=e.Uint8ClampedArray,Int16Array=e.Int16Array,Uint16Array=e.Uint16Array,Int32Array=e.Int32Array,Uint32Array=e.Uint32Array,Float32Array=e.Float32Array,Float64Array=e.Float64Array,BigInt64Array=e.BigInt64Array,BigUint64Array=e.BigUint64Array}uni.restoreGlobal&&uni.restoreGlobal(Vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval),function(e){"use strict";function t(e,t,...l){uni.__log__?uni.__log__(e,t,...l):console[e].apply(console,[...l,t])}function l(e,t){return"string"==typeof e?t:e}const a=t=>(l,a=e.getCurrentInstance())=>{!e.isInSSRComponentSetup&&e.injectHook(t,l,a)},i=a("onShow"),r=a("onHide"),n=a("onLoad"),c=(e,t)=>{const l=e.__vccOpts||e;for(const[a,i]of t)l[a]=i;return l};const o=c({name:"ZyUpgrade",props:{theme:{type:String,default:"green"},updateurl:{type:String,default:""},h5preview:{type:Boolean,default:!1},oldversion:{type:String,default:""},oldcode:{type:Number,default:0},appstoreflag:{type:Boolean,default:!1},noticeflag:{type:Boolean,default:!1},autocheckupdate:{type:Boolean,default:!0}},data(){return{update_flag:!1,dshow:!1,update_process:0,downloadTask:[],updated2version:"",version_url:"",update_tips:"",forceupgrade:!1,currentversion:this.oldversion,versionname:"",vesioncode:this.oldcode,wgt_flag:0,wgt_url:"",size:0,header:{Authorization:uni.getStorageSync("token")||"token"}}},mounted(){let e=!1;e=!0,this.h5preview,this.autocheckupdate&&this.check_update()},computed:{version(){let e="";return e=this.currentversion+(""!=this.currentversion&&""!=this.updated2version?"->":"")+this.updated2version,e}},methods:{check_update(){let e=this;plus.runtime.getProperty(plus.runtime.appid,(function(t){e.currentversion=t.version,e.versionname=t.name,e.versioncode=t.versionCode,e.updatebusiness(e)}))},updatebusiness:function(e){uni.request({url:`http://121.36.88.64/nursing-unit/api/pad/versionUpdate?platform=1&version=${e.currentversion}`,method:"GET",dataType:"json",success:l=>{t("log","at component/zy-upgrade/zy-upgrade.vue:134","?????",l),100==l.data.code?l.data.data.update_url&&(e.dshow=!0,e.update_tips=l.data.data.update_tips,e.forceupgrade=1==l.data.data.forceupdate,e.version_url=l.data.data.update_url,e.updated2version=l.data.data.version,e.wgt_flag=l.data.data.wgt_flag,e.wgt_url=l.data.data.wgt_url,e.size=l.data.data.size,e.getnewbanben()):uni.showToast({title:"请求升级出错:"+data.msg,icon:"none"})},fail(){this.loading=!1}})},getnewbanben:function(){this.$emit("chuandinew",this.updated2version)},upgrade_checked:function(){uni.removeStorageSync("token"),this.update_flag=!0,this.updateversion()},upgrade_cancel:function(){this.dshow=!1},upgrade_break:function(){this.downloadTask.abort(),this.update_flag=!1},updateversion:function(){let e=this;if("ios"==uni.getSystemInfoSync().platform&&this.appstoreflag&&1!=e.wgt_flag)e.dshow=!1,plus.runtime.launchApplication({action:e.version_url},(function(e){uni.showToast({title:"打开appstore失败",icon:"none"})}));else{let e=this,l="http://121.36.88.64/nursing-unit/sys/common/static/"+(1==e.wgt_flag?e.wgt_url:e.version_url);this.update_confirm=!0,this.downloadTask=uni.downloadFile({url:l,header:this.header,success:function(e){200==e.statusCode?plus.runtime.install(e.tempFilePath,{force:!1},(function(){plus.runtime.restart()}),(function(e){t("error","at component/zy-upgrade/zy-upgrade.vue:221","install fail...",JSON.stringify(e)),uni.showToast({title:"升级失败",icon:"none"})})):uni.showToast({title:"下载失败,网络错误",icon:"none"})},fail:function(e){uni.showToast({title:"下载失败:"+e.errMsg,icon:"none"}),this.update_flag=!1},complete:function(){}}),this.downloadTask.onProgressUpdate((function(t){if(e.update_process=t.progress,t.progress==1/0){let l=t.totalByte
|