From 944ddf8d667d66ddb46f886c3d84c86d7d4c2707 Mon Sep 17 00:00:00 2001 From: Swanky <413564165@qq.com> Date: Fri, 5 Apr 2024 13:04:44 +0800 Subject: [PATCH] 1 --- common/upgrade.js | 93 +++++++++++++++++++++++++++++++++++++++ manifest.json | 4 +- pages/index/index.vue | 93 +++++++++++++++++++++++++++++++++++++-- pages/mine/mine.vue | 100 +++++++++++++++++++++++++++++++++++++++--- static/jwd.png | Bin 0 -> 3089 bytes 5 files changed, 280 insertions(+), 10 deletions(-) create mode 100644 common/upgrade.js create mode 100644 static/jwd.png diff --git a/common/upgrade.js b/common/upgrade.js new file mode 100644 index 0000000..3fa526f --- /dev/null +++ b/common/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: // 已接收到数据 + let hasProgress = task.totalSize && task.totalSize > 0 //是否能获取到App大小 + if (hasProgress) { + let current = parseInt(100 * task.downloadedSize / task + .totalSize); //获取下载进度百分比 + progressCallBack(current) + } + 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) { + console.log(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); //监听APP安装 + filter.addDataScheme("package"); + mainActivity.registerReceiver(receiver, filter); //注册广播 + +} \ No newline at end of file diff --git a/manifest.json b/manifest.json index 457166f..15b6058 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "草原管理", "appid" : "__UNI__BBBC950", "description" : "", - "versionName" : "1.0.1", - "versionCode" : 101, + "versionName" : "1.0.2", + "versionCode" : 102, "transformPx" : false, "app-plus" : { /* 5+App特有相关 */ diff --git a/pages/index/index.vue b/pages/index/index.vue index a77e18f..e4c9458 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -10,18 +10,27 @@ + 图层 + 测量 + 绕地 + 定位 + + + + 经纬度 + 清除 + + + + 经纬度定位 + + + + + + + + + + + + + + 图层叠加 @@ -43,7 +69,7 @@ - + 180) { + callback('经度范围应在 0 到 180 之间') + } + return true + } + }] + }, + latitude: { + rules: [{ + required: true, + errorMessage: '纬度不能为空', + }, { + format: "number", + validateFunction: function(rule, value, data, callback) { + if (value < -90 || value > 90) { + callback('纬度范围应在 -90 到 90 之间') + } + return true + } + }] + } + } } }, watch: { @@ -186,6 +243,28 @@ uni.stopCompass(); }, methods: { + navWithJwd() { + this.$refs.jwdForm.validate((err, formData) => { + // 如果校验成功 ,err 返回 null + if (!err) { + console.log('success', formData) + this.mapData = { + center: [formData.longitude, formData.latitude, Math.random()] + } + this.$refs.jwdPopup.close(); + return + } + console.log('error', err, formData) + }).then(res => { + // res 返回 null + }) + }, + showJwdPopup() { + this.$refs.jwdPopup.open('bottom'); + setTimeout(() => { + this.$refs.jwdForm.setRules(this.rules) + }, 500) + }, loadLayerItems() { uni.request({ url: `${helper.mgServerUrl}/app/config/layer`, @@ -735,6 +814,11 @@ } .img-clear, + .img-jwd { + width: 26px; + height: 26px; + } + .img-logout, .img-message, .img-search, @@ -789,10 +873,13 @@ width: 48px; height: 48px; background-color: #fff; + flex-direction: column; display: flex; align-items: center; padding: 0; justify-content: center; + font-size: 12px; + padding: 2px 0; } .btn-location { diff --git a/pages/mine/mine.vue b/pages/mine/mine.vue index bf9ce64..3ab9b84 100644 --- a/pages/mine/mine.vue +++ b/pages/mine/mine.vue @@ -9,23 +9,68 @@ - + + 版本信息 + + + + + + + +