| | |
| | | } |
| | | |
| | | // WEB_INVOKE_APPSERVICE |
| | | function messageFun(e) { |
| | | if (e.data.type === "WEB_INVOKE_APPSERVICE") { |
| | | const {type,data} = e.data.data.arg |
| | | if (type === "tokenExpired") { |
| | | return uni.reLaunch({url: "/pages/login/index"}); |
| | | }else if(type === "wxOpenLocation"){ |
| | | return wx.openLocation({ |
| | | |
| | | |
| | | // 下载图片一次 |
| | | function oneImageDownload(url) { |
| | | return new Promise((resolve, reject) => { |
| | | wx.downloadFile({ |
| | | url, |
| | | success: (res) => { |
| | | wx.saveImageToPhotosAlbum({ |
| | | filePath: res.tempFilePath, |
| | | success: function (res) { |
| | | resolve() |
| | | }, |
| | | }); |
| | | }, |
| | | }); |
| | | }) |
| | | } |
| | | |
| | | // 多次图片下载 |
| | | function multipleImageDownloads(all){ |
| | | // const downloadUrlList = [ |
| | | // // 'https://wrj.shuixiongit.com/aiskyminioTwo/cloud-bucket//089a4039-9c98-4441-abb7-1f9ac56caa8c/DJI_202604270944_002_089a4039-9c98-4441-abb7-1f9ac56caa8c/%E8%BD%A6AI20260427100047007.jpeg', |
| | | // // 'https://aisky.org.cn/command-center-dashboard/assets/zhddpt-BgsJ8s7S.png', |
| | | // 'https://wrj.shuixiongit.com/aiskyminioTwo/cloud-bucket/8d9ba6b4-d255-4f49-b3f8-bdeaf99773b4/DJI_202602121039_002_8d9ba6b4-d255-4f49-b3f8-bdeaf99773b4-flyto/DJI_20260212104641_0003_V.mp4' |
| | | // ] |
| | | const downloadUrlList = all.map(item => { |
| | | return item.replace('aiskyminio', 'aiskyminioTwo') |
| | | }) |
| | | const async = ['https://aisky.org.cn/command-center-dashboard/assets/zhddpt-BgsJ8s7S.png'].map(item => oneImageDownload(item)) |
| | | return Promise.all(async) |
| | | } |
| | | |
| | | // 公共图片下载 |
| | | function publicImageDownloads(data) { |
| | | wx.getSetting({ |
| | | success(res) { |
| | | if (res?.authSetting?.['scope.writePhotosAlbum']) { |
| | | multipleImageDownloads(data.urlList) |
| | | }else{ |
| | | wx.authorize({ |
| | | scope: 'scope.writePhotosAlbum', |
| | | success() { |
| | | multipleImageDownloads(data.urlList) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | | // 公共定位 |
| | | function publicPosit(data) { |
| | | wx.openLocation({ |
| | | latitude: data.latitude, |
| | | longitude: data.longitude, |
| | | name: data.name, |
| | | address: data.name, |
| | | scale: 18 |
| | | }) |
| | | } |
| | | |
| | | |
| | | function messageFun(e) { |
| | | if (e.data.type === "WEB_INVOKE_APPSERVICE") { |
| | | const {type,data} = e.data.data.arg |
| | | if (type === "tokenExpired") { |
| | | uni.reLaunch({url: "/pages/login/index"}); |
| | | }else if(type === "wxImageDownload"){ |
| | | publicImageDownloads(data) |
| | | }else if(type === "wxOpenLocation"){ |
| | | publicPosit(data) |
| | | }else{ |
| | | emit("webMessage", e.data.data.arg); |
| | | } |