全国服务热线:4008-888-888

公司新闻

有关nuiapp检验升級app并全自动安裝的编码共享

拷贝编码 upapp: function(isup) { //#ifdef APP-PLUS /* 5+自然环境锁住显示屏方位 */ plus.screen.lockOrientation('portrait-primary'); //锁住 /* 5+自然环境升級提醒 */ var server = ""; //查验升级详细地址 var req = { //升級检验数据信息 "appid": plus.runtime.appid, "version": plus.runtime.version, "imei": plus.device.imei 
 uni.request({ url: server, data: req, success: (res) = { if (res.statusCode == 200 res.data.state == "yes") { let openUrl = plus.os.name === 'iOS' ? res.data.iOS : res.data.Android; var url = res.data.urlapp; var content = res.data.content; 
 uni.showModal({ //提示客户升级 title: '升级提醒', cancelText:'明确', confirmText:'撤销', content: res.data.content ? res.data.content : '有新版本本,是不是明确升级?', success: (res) = { if (!res.confirm) { //自动跳转到升級进展网页页面 uni.navigateTo({ url: "/pages/upapp/index?url=" + url + " content=" + content 
 } else { //撤销 } 
 } else if (res.statusCode == 200) { 
 uni.setStorageSync("upapp", time); 
 uni.showToast({ "title": res.data.content ? res.data.content : "已经是全新版本号", 
 }); 
 } else { // } 
 }) //#endif }
免费下载升級进展网页页面:/pages/upapp/index
拷贝编码 template view view {{title}} {{content}} view view progress :percent="percent"  stroke-width="30" / /view /view /view /view /template script export default { 
 data() { return { title: '已经免费下载中,请稍候!', content: "", percent: 0 } 
 }, onLoad: function (option) { if (option.url) { this.content = option.content; this.up_app(option.url); 
 } else { 
 uni.navigateBack({ delta: 1, 
 }); return; 
 }, onHide: function () { 
 }, onShow: function () { 
 }, methods: { up_app: function (url) { 
 plus.screen.lockOrientation('portrait-primary'); //锁住 this.download(url) 
 }, download: function (url) { console.log(url) var that = this; const downloadTask = uni.downloadFile({ url: url, success: function (res) { if (res.statusCode === 200) { console.log(JSON.stringify(res)) console.log('免费下载取得成功'); var tempFilePaths = res.tempFilePath; 
 that.install(tempFilePaths); return; 
 }); 
 downloadTask.onProgressUpdate(function (res) { 
 that.percent = res.progress; //console.log('免费下载进展' + res.progress); //console.log('早已免费下载的数据信息长短' + res.totalBytesWritten); //console.log('预估必须免费下载的数据信息全长度' + res.totalBytesExpectedToWrite); }); 
 }, install: function (path) {//安裝 console.log(path) 
 plus.runtime.install(path, { force: true }, function () { //uni.hideNavigationBarLoading(); console.log("载入进行!"); 
 uni.navigateBack({ delta: 1, 
 }); 
 }, function (e) { console.log(JSON.stringify(e)); 
 }); 
 /script 
 style 
 progress { 
 width: 100%; 
 .progress-box { 
 display: flex; 
 height: 50px; 
 margin-bottom: 60px; 
 .progress-cancel { 
 margin-left: 40px; 
 /style 
后端开发编码(php): $version="";//是接受到的版本号号
$now_v="1.0.1";//要升級全新版本号号
$data_json=["state"= "not","content"= "已经是全新版本号!",];
if ($version !== $now_v) { //这儿是实例编码,真正业务流程上,全新版本号号及relase no
$data_json =array(
"state"= "yes",
"content"= "提升一些新作用。",
"mark"= $now_v,
"urlapp"= "",//免费下载app详细地址
);



在线客服

关闭

客户服务热线
4008-888-888


点击这里给我发消息 在线客服

点击这里给我发消息 在线客服