diff --git a/.gitignore b/.gitignore index 323aee48..34dc8aba 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,4 @@ unpackage *.sln *.sw? /node_modules -/unpackage/ +/unpackage diff --git a/main.js b/main.js index e0109f94..d27afb0e 100644 --- a/main.js +++ b/main.js @@ -35,13 +35,15 @@ Vue.prototype.COMPANY = "" if (process.env.NODE_ENV === 'development') { // 开发环境 console.log('开发环境') - // Vue.prototype.url_config = 'http://47.93.215.234:9809/' // 鞍钢正式地址 + // // Vue.prototype.url_config = 'http://47.93.215.234:9809/' // 鞍钢正式地址(弃用) + // Vue.prototype.url_config = 'http://42.180.188.17:9809/' // 鞍钢正式地址 // Vue.prototype.url_config = 'http://47.93.215.234:11211/' // 鞍钢测试地址 Vue.prototype.url_config = 'http://182.90.224.237:51234/' //雄哥内网穿透地址 // Vue.prototype.url_config = 'http://jxj.zhgdyun.com:61212/' //杰哥内网穿透地址 // Vue.prototype.url_config = 'http://192.168.34.221:9111/' //郭圣雄本地 // Vue.prototype.url_config = 'http://192.168.34.155:19111/' //彭洁本地 - Vue.prototype.work_url = 'http://47.93.215.234:19997' // 工作流线上地址 + // Vue.prototype.work_url = 'http://47.93.215.234:19997' // 工作流线上地址(弃用) + Vue.prototype.work_url = 'http://42.180.188.17:19997' // 工作流线上地址 // Vue.prototype.work_url = 'http://192.168.34.138:5173' // 工作流地址 // Vue.prototype.url_config = 'http://8.142.139.165:7080/' // 湖里 // Vue.prototype.url_config = 'http://139.9.66.234:8/' @@ -80,11 +82,13 @@ if (process.env.NODE_ENV === 'development') { console.log('生产环境') // Vue.prototype.url_config = 'http://10.168.1.105:11111/' // 线上地址 // Vue.prototype.url_config = 'http://10.168.1.104:11111/' // 线上地址 - Vue.prototype.url_config = 'http://47.93.215.234:9809/' // 鞍钢线上地址 + // Vue.prototype.url_config = 'http://47.93.215.234:9809/' // 鞍钢线上地址(弃用) + Vue.prototype.url_config = 'http://42.180.188.17:9809/' // 鞍钢线上地址 // Vue.prototype.url_config = 'http://47.93.215.234:11211/' // 鞍钢测试地址 // Vue.prototype.url_config = 'http://182.90.224.237:51234/' // 百色三标段 // Vue.prototype.url_config = 'http://192.168.34.221:9111/' // 百色三标段 - Vue.prototype.work_url = 'http://47.93.215.234:19997' // 工作流线上地址 + // Vue.prototype.work_url = 'http://47.93.215.234:19997' // 工作流线上地址(弃用) + Vue.prototype.work_url = 'http://42.180.188.17:19997' // 工作流线上地址 // Vue.prototype.work_url = 'http://47.93.215.234:19097' // 工作流测试地址 // Vue.prototype.work_url = 'http://192.168.34.139:5173' // 工作流地址 // Vue.prototype.url_config = 'http://182.90.224.147:100/' //演示平台 diff --git a/manifest.json b/manifest.json index 95be36e5..994f2b92 100644 --- a/manifest.json +++ b/manifest.json @@ -1,9 +1,9 @@ { - "name" : "智慧工地云平台", //中建四局 + "name" : "智慧安全", //中建四局 "appid" : "__UNI__4AA4101", "description" : "", - "versionName" : "1.4.3", - "versionCode" : 143, + "versionName" : "1.4.4", + "versionCode" : 144, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/pages.json b/pages.json index 70116fc3..6e6f6fb4 100644 --- a/pages.json +++ b/pages.json @@ -1596,6 +1596,14 @@ "enablePullDownRefresh": false } + } ,{ + "path" : "pages/lq-upgrade/upgrade", + "style" : + { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + } ], // "subPackages":[{ diff --git a/pages/lq-upgrade/checkVersion.js b/pages/lq-upgrade/checkVersion.js new file mode 100644 index 00000000..05646ee2 --- /dev/null +++ b/pages/lq-upgrade/checkVersion.js @@ -0,0 +1,73 @@ +/** + * 检查app版本是否需要升级 + */ +const checkVersion = ({ + name, //最新版本名称 + code, //最新版本号 + content, //更新内容 + url, //下载链接 + forceUpdate //是否强制升级 +}) => { + // const selfVersionCode = Number(uni.getSystemInfoSync().appVersionCode); //当前App版本号 + let selfVersionCode = '' + //获取当前应用版本 + plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) { + // console.log('版本号的数据信息', widgetInfo.version);//其实是应用版本名称 + // console.log('应用版本名称', widgetInfo.version); + // that.versionName = widgetInfo.version + // console.log('应用版本号', widgetInfo.versionCode); + selfVersionCode = widgetInfo.versionCode + console.log('selfVersionCode',selfVersionCode,code) + //线上版本号高于当前,进行在线升级 + if (code > selfVersionCode) { + let platform = uni.getSystemInfoSync().platform //手机平台 + console.log('platform',platform,getCurrentPageRoute()) + //安卓手机弹窗升级 + debugger + if (platform === 'android') { + console.log('1111111111111111111') + //当前页面不是升级页面跳转防止多次打开 + if (getCurrentPageRoute() !== 'pages/lq-upgrade/upgrade') { + console.log('22222222222222222222222222') + uni.navigateTo({ + url: '/pages/lq-upgrade/upgrade', + success() { + uni.$emit('upgrade-app', { + name, + content, + url, + forceUpdate + }) + }, + fail(res) { + console.log('---333333333333',res) + } + }) + } + + } + //IOS无法在线升级提示到商店下载 + else { + uni.showModal({ + title: '发现新版本 ' + newVersionName, + content: '请到App store进行升级', + showCancel: false + }) + } + } + }) + +} + +//获取当前页面url +const getCurrentPageRoute = () => { + let currentRoute; + let pages = getCurrentPages() // 获取栈实例 + if (pages&&pages.length) { + currentRoute = pages[pages.length - 1].route; + + } + return currentRoute +} + +export default checkVersion \ No newline at end of file diff --git a/pages/lq-upgrade/upgrade.js b/pages/lq-upgrade/upgrade.js new file mode 100644 index 00000000..a62365b6 --- /dev/null +++ b/pages/lq-upgrade/upgrade.js @@ -0,0 +1,93 @@ +/** + * @description H5+下载App + * @param downloadUrl:App下载链接 + * @param progressCallBack:下载进度回调 + */ +export const downloadApp = (downloadUrl, progressCallBack = () => {}, ) => { + return new Promise((resolve, reject) => { + //创建下载任务 + const downloadTask = plus.downloader.createDownload(downloadUrl, { + method: "GET" + }, (task, status) => { + console.log(status,'status') + if (status == 200) { //下载成功 + resolve(task.filename) + + } else { + reject('fail') + uni.showToast({ + title: '下载失败', + duration: 1500, + icon: "none" + }); + } + }) + //监听下载过程 + downloadTask.addEventListener("statechanged", (task, status) => { + switch (task.state) { + case 1: // 开始 + break; + case 2: //已连接到服务器 + break; + case 3: // 已接收到数据 + console.log(task,'task') + let hasProgress = task.totalSize && task.totalSize > 0 //是否能获取到App大小 + if (hasProgress) { + let current = parseInt(100 * task.downloadedSize / task.totalSize); //获取下载进度百分比 + progressCallBack(current,task.downloadedSize,task.totalSize) + } + break; + case 4: // 下载完成 + break; + } + }); + //开始执行下载 + downloadTask.start(); + }) + + +} +/** + * @description H5+安装APP + * @param fileName:app文件名 + * @param callBack:安装成功回调 + */ +export const installApp = (fileName, callBack = () => {}) => { + //注册广播监听app安装情况 + onInstallListening(callBack); + //开始安装 + plus.runtime.install(plus.io.convertLocalFileSystemURL(fileName), {}, () => { + //成功跳转到安装界面 + }, function(error) { + uni.showToast({ + title: '安装失败', + duration: 1500, + icon: "none" + }); + }) + +} +/** + * @description 注册广播监听APP是否成功 + * @param callBack:安装成功回调函数 + */ +const onInstallListening = (callBack = () => {}) => { + + let mainActivity = plus.android.runtimeMainActivity(); //获取activity + //生成广播接收器 + let receiver = plus.android.implements('io.dcloud.android.content.BroadcastReceiver', { + onReceive: (context, intent) => { //接收广播回调 + plus.android.importClass(intent); + mainActivity.unregisterReceiver(receiver); //取消监听 + callBack() + } + }); + let IntentFilter = plus.android.importClass('android.content.IntentFilter'); + let Intent = plus.android.importClass('android.content.Intent'); + let filter = new IntentFilter(); + filter.addAction(Intent.ACTION_PACKAGE_ADDED); //监听apk安装 + filter.addDataScheme("package"); + mainActivity.registerReceiver(receiver, filter); //注册广播 + + +} \ No newline at end of file diff --git a/pages/lq-upgrade/upgrade.vue b/pages/lq-upgrade/upgrade.vue new file mode 100644 index 00000000..acae0c43 --- /dev/null +++ b/pages/lq-upgrade/upgrade.vue @@ -0,0 +1,277 @@ + + + + + + \ No newline at end of file diff --git a/pages/lq-upgrade/upgrade_bg.png b/pages/lq-upgrade/upgrade_bg.png new file mode 100644 index 00000000..54d815a0 Binary files /dev/null and b/pages/lq-upgrade/upgrade_bg.png differ diff --git a/pages/projectEnd/projectIndex/projectIndex.vue b/pages/projectEnd/projectIndex/projectIndex.vue index f2559255..9ece5e0e 100644 --- a/pages/projectEnd/projectIndex/projectIndex.vue +++ b/pages/projectEnd/projectIndex/projectIndex.vue @@ -142,6 +142,7 @@