2023-02-27

功能完善
This commit is contained in:
2023-02-27 18:10:06 +08:00
parent 837e8e6552
commit e40ca500b4
42 changed files with 1901 additions and 1841 deletions

View File

@@ -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);

View File

@@ -18,7 +18,8 @@ export default class request {
// 获取默认信息
getDefault(data, options = {}) {
//判断url是不是链接
let urlType = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~/])+$/.test(data.url);
let urlType = /^([hH][tT]{2}[pP]:\/\/|[hH][tT]{2}[pP][sS]:\/\/)(([A-Za-z0-9-~]+).)+([A-Za-z0-9-~/])+$/.test(
data.url);
let config = Object.assign({}, this.config, options, data);
if (data.method == "FILE") {
config.url = urlType ? data.url : this.fileUrl + data.url;
@@ -88,6 +89,7 @@ export default class request {
return;
}
let requestInfo = this.getDefault(data);
//请求前回调
if (this.requestStart) {
let requestStart = this.requestStart(requestInfo);
@@ -110,9 +112,12 @@ export default class request {
return;
}
}
console.log("url: requestInfo.url》》》》", requestInfo.url)
console.log("url: requestInfo.header》》》》", requestInfo.header)
let requestData = {
url: requestInfo.url,
header: requestInfo.header, //加入请求头
success: (res) => {
//请求完成回调
this.requestEnd && this.requestEnd(requestInfo, res);