2023-02-27
功能完善
This commit is contained in:
@@ -9,10 +9,11 @@ const $iconUrl = "/static/icon/ic_ar.png";
|
||||
// 获取当前应用的版本号
|
||||
export const getCurrentNo = function(callback) {
|
||||
// 获取本地应用资源版本号
|
||||
console.log("》》》》", 11111111111111111);
|
||||
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
|
||||
callback && callback({
|
||||
versionCode: inf.version.replace(/\./g, ""),
|
||||
version: inf.version
|
||||
version: inf.version,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -24,7 +25,7 @@ export const getServerNo = function(version, isPrompt = false, callback) {
|
||||
let userName = userInfos.username;
|
||||
let httpData = {
|
||||
version: version,
|
||||
userName:userName
|
||||
userName: userName
|
||||
};
|
||||
console.log(userName)
|
||||
if (platform == "android") {
|
||||
@@ -32,11 +33,12 @@ export const getServerNo = function(version, isPrompt = false, callback) {
|
||||
} else {
|
||||
httpData.type = 1102;
|
||||
}
|
||||
console.log("》》》》", 222222);
|
||||
/* 接口入参说明
|
||||
* version: 应用当前版本号(已自动获取)
|
||||
* type:平台(1101是安卓,1102是IOS)
|
||||
*/
|
||||
$http.get("api/appVersion/versioninfo", httpData, {
|
||||
$http.get("appVersion/versioninfo", httpData, {
|
||||
isPrompt: isPrompt
|
||||
}).then(res => {
|
||||
/* res的数据说明
|
||||
@@ -48,6 +50,7 @@ export const getServerNo = function(version, isPrompt = false, callback) {
|
||||
* | forceUpdate | y | boolean | 是否强制更新 |
|
||||
* | downloadUrl | y | String | 版本下载链接(IOS安装包更新请放跳转store应用商店链接,安卓apk和wgt文件放文件下载链接) |
|
||||
*/
|
||||
console.log("》》》》", 333333333);
|
||||
console.log(res)
|
||||
console.log(JSON.parse(res));
|
||||
console.log(JSON.stringify(JSON.parse(res)))
|
||||
@@ -76,6 +79,7 @@ export const getDownload = function(res) {
|
||||
let file = data.fileName
|
||||
let dtask;
|
||||
let lastProgressValue = 0;
|
||||
console.log("》》》》", 44444444);
|
||||
downloadPopup(popupData, function(res) {
|
||||
dtask = plus.downloader.createDownload(data.downloadUrl, {
|
||||
// filename: '_doc/update/' + file + '/' + new Date().getTime() + '/'
|
||||
@@ -670,7 +674,8 @@ function downloadPopup(data, callback, cancelCallback, rebootCallback) {
|
||||
} else if (buttonNum == 2) {
|
||||
// 双按钮
|
||||
let buttonWidth = (popupViewData.viewContentWidth - popupViewData.viewContentPadding) / 2;
|
||||
if (e.clientX > popupViewData.viewContentPadding && e.clientX < maxLeft - buttonWidth - popupViewData.viewContentPadding) {
|
||||
if (e.clientX > popupViewData.viewContentPadding && e.clientX < maxLeft - buttonWidth -
|
||||
popupViewData.viewContentPadding) {
|
||||
maskLayer.hide();
|
||||
popupView.hide();
|
||||
cancelCallback && cancelCallback();
|
||||
@@ -781,8 +786,10 @@ function downloadPopup(data, callback, cancelCallback, rebootCallback) {
|
||||
}
|
||||
export default function(isPrompt = false) {
|
||||
getCurrentNo(version => {
|
||||
console.log("》》》》", version);
|
||||
getServerNo(version.versionCode, isPrompt, data => {
|
||||
let res = JSON.parse(data);
|
||||
console.log("》》》》", 6666666);
|
||||
if (res.forceUpdate) {
|
||||
if (/\.wgt$/i.test(res.downloadUrl)) {
|
||||
getDownload(res);
|
||||
|
||||
Reference in New Issue
Block a user