Initial commit of akmon project
This commit is contained in:
12
uni_modules/uni-openLocation/changelog.md
Normal file
12
uni_modules/uni-openLocation/changelog.md
Normal file
@@ -0,0 +1,12 @@
|
||||
## 1.1.0(2025-03-21)
|
||||
新增 支持编译到鸿蒙
|
||||
## 1.0.4(2024-12-17)
|
||||
调整target.png文件所在位置
|
||||
## 1.0.3(2024-12-16)
|
||||
升级 uts-openSchema 依赖至1.1.1
|
||||
## 1.0.2(2024-12-10)
|
||||
ios端支持侧滑关闭
|
||||
## 1.0.1(2024-12-10)
|
||||
插件新增文件pages_init.json,方便注册页面
|
||||
## 1.0.0(2024-12-09)
|
||||
发布API uni.openLocation 需 HBuilderX 4.41+
|
||||
98
uni_modules/uni-openLocation/package.json
Normal file
98
uni_modules/uni-openLocation/package.json
Normal file
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"id": "uni-openLocation",
|
||||
"displayName": "uni-openLocation",
|
||||
"version": "1.1.0",
|
||||
"description": "APP端的 uni.openLocation,仅支持uni-app x,不支持uni-app",
|
||||
"keywords": [
|
||||
"uni-openLocation"
|
||||
],
|
||||
"repository": "",
|
||||
"engines": {
|
||||
"HBuilderX": "^4.41"
|
||||
},
|
||||
"dcloudext": {
|
||||
"type": "uts",
|
||||
"sale": {
|
||||
"regular": {
|
||||
"price": "0.00"
|
||||
},
|
||||
"sourcecode": {
|
||||
"price": "0.00"
|
||||
}
|
||||
},
|
||||
"contact": {
|
||||
"qq": ""
|
||||
},
|
||||
"declaration": {
|
||||
"ads": "无",
|
||||
"data": "插件不采集任何数据",
|
||||
"permissions": "无"
|
||||
},
|
||||
"npmurl": ""
|
||||
},
|
||||
"uni_modules": {
|
||||
"dependencies": [
|
||||
"uts-openSchema"
|
||||
],
|
||||
"uni-ext-api": {
|
||||
"uni": {
|
||||
"openLocation": {
|
||||
"name": "openLocation",
|
||||
"app": {
|
||||
"js": false,
|
||||
"kotlin": true,
|
||||
"swift": true,
|
||||
"arkts": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"encrypt": [],
|
||||
"platforms": {
|
||||
"cloud": {
|
||||
"tcb": "y",
|
||||
"aliyun": "y",
|
||||
"alipay": "y"
|
||||
},
|
||||
"client": {
|
||||
"Vue": {
|
||||
"vue2": "n",
|
||||
"vue3": "y"
|
||||
},
|
||||
"App": {
|
||||
"app-android": "y",
|
||||
"app-ios": "y",
|
||||
"app-harmony": "y"
|
||||
},
|
||||
"H5-mobile": {
|
||||
"Safari": "y",
|
||||
"Android Browser": "y",
|
||||
"微信浏览器(Android)": "y",
|
||||
"QQ浏览器(Android)": "y"
|
||||
},
|
||||
"H5-pc": {
|
||||
"Chrome": "y",
|
||||
"IE": "n",
|
||||
"Edge": "y",
|
||||
"Firefox": "y",
|
||||
"Safari": "y"
|
||||
},
|
||||
"小程序": {
|
||||
"微信": "n",
|
||||
"阿里": "n",
|
||||
"百度": "n",
|
||||
"字节跳动": "n",
|
||||
"QQ": "n",
|
||||
"钉钉": "n",
|
||||
"快手": "n",
|
||||
"飞书": "n",
|
||||
"京东": "n"
|
||||
},
|
||||
"快应用": {
|
||||
"华为": "n",
|
||||
"联盟": "n"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,552 @@
|
||||
<template>
|
||||
<view class="uni-open-location" :class="classCom">
|
||||
<view class="uni-open-location-map-box">
|
||||
<map class="uni-open-location-map" :id="mapId" :ref="mapId" :latitude="latitude" :longitude="longitude" :scale="openLocationOptions.scale" :markers="markers"
|
||||
:layer-style="theme == 'dark' ? '2' : '1'" :show-compass="false" :enable-zoom="true" :enable-scroll="true" :enable-rotate="false" :enable-poi="true" :show-location="true">
|
||||
</map>
|
||||
<view class="uni-open-location-map-reset" @click="mapReset">
|
||||
<text class="uni-open-location-icons uni-open-location-map-reset-icon">{{ icon.position }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="uni-open-location-nav" :style="'height:' + (60 + safeArea.top) + 'px;'">
|
||||
<view class="uni-open-location-nav-btn uni-open-location-nav-back-btn" :class="[landscapeClassCom]" :style="safeArea.top > 0 ? 'top: ' + safeArea.top + 'px;' : ''"><text
|
||||
class="uni-open-location-nav-text uni-open-location-nav-back-text uni-open-location-icons" @click="back">{{ icon.back }}</text></view>
|
||||
</view>
|
||||
<view class="uni-open-location-footer">
|
||||
<view class="uni-open-location-address">
|
||||
<text class="uni-open-location-name-text">
|
||||
{{ openLocationOptions.name }}
|
||||
</text>
|
||||
<text class="uni-open-location-address-text">
|
||||
{{ openLocationOptions.address }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="uni-open-location-footer-icon-btns">
|
||||
<view class="uni-open-location-footer-icon-btns-item" @click="navigation">
|
||||
<view class="uni-open-location-footer-icon-box">
|
||||
<text class="uni-open-location-icons">{{ icon.navigation }}</text>
|
||||
</view>
|
||||
<text class="uni-open-location-footer-btn-text">{{ languageCom['navigation'] }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script lang="uts">
|
||||
import { openSchema } from '@/uni_modules/uts-openSchema'
|
||||
// #ifdef APP
|
||||
import { canOpenURL } from '@/uni_modules/uts-openSchema'
|
||||
// #endif
|
||||
|
||||
import targetPath from '@/uni_modules/uni-openLocation/pages/openLocation/target.png'
|
||||
|
||||
//const targetPath = '/uni_modules/uni-openLocation/static/target.png'
|
||||
|
||||
type AafeArea = {
|
||||
top : number,
|
||||
bottom : number,
|
||||
left : number,
|
||||
right : number
|
||||
}
|
||||
|
||||
type IconPath = {
|
||||
target : string,
|
||||
position : string,
|
||||
navigation : string,
|
||||
back : string,
|
||||
}
|
||||
|
||||
const languageData = {
|
||||
"en": {
|
||||
"navigation": "navigation"
|
||||
},
|
||||
"zh-Hans": {
|
||||
"navigation": "导航"
|
||||
},
|
||||
"zh-Hant": {
|
||||
"navigation": "導航"
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
data() {
|
||||
const id1 = `UniMap1_${(Math.random() * 10e5).toString(36)}` as string;
|
||||
return {
|
||||
readyEventName: '',
|
||||
optionsEventName: '',
|
||||
successEventName: '',
|
||||
failEventName: '',
|
||||
openLocationOptions: {
|
||||
latitude: 0,
|
||||
longitude: 0,
|
||||
scale: 18,
|
||||
name: '',
|
||||
address: ''
|
||||
} as OpenLocationOptions,
|
||||
safeArea: {
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0
|
||||
} as AafeArea,
|
||||
icon: {
|
||||
target: '\ue683',
|
||||
position: '\ue653',
|
||||
navigation: '\ue640',
|
||||
back: '\ue651',
|
||||
} as IconPath,
|
||||
language: "zh-Hans",
|
||||
isLandscape: false,
|
||||
theme: "light",
|
||||
mapId: id1,
|
||||
latitude: 0,
|
||||
longitude: 0,
|
||||
markers: [] as Marker[]
|
||||
}
|
||||
},
|
||||
onLoad(options : UTSJSONObject) {
|
||||
this.initPageOptions(options);
|
||||
this.getSystemInfo();
|
||||
},
|
||||
onReady() {
|
||||
|
||||
},
|
||||
onUnload() {
|
||||
uni.$off(this.optionsEventName, null);
|
||||
uni.$off(this.readyEventName, null);
|
||||
uni.$off(this.successEventName, null);
|
||||
uni.$off(this.failEventName, null);
|
||||
// #ifdef APP-IOS
|
||||
__uniappx__nativeEventBus.off(this.optionsEventName, null)
|
||||
__uniappx__nativeEventBus.off(this.readyEventName, null)
|
||||
__uniappx__nativeEventBus.off(this.successEventName, null)
|
||||
__uniappx__nativeEventBus.off(this.failEventName, null)
|
||||
// #endif
|
||||
},
|
||||
onResize() {
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
this.isLandscape = systemInfo.deviceOrientation == 'landscape';
|
||||
},
|
||||
methods: {
|
||||
initPageOptions(options : UTSJSONObject) {
|
||||
this.readyEventName = options['readyEventName']! as string;
|
||||
this.optionsEventName = options['optionsEventName']! as string;
|
||||
this.successEventName = options['successEventName']! as string;
|
||||
this.failEventName = options['failEventName']! as string;
|
||||
uni.$on(this.optionsEventName, (data : UTSJSONObject) => {
|
||||
console.log('data: ', JSON.stringify(data))
|
||||
if (data['latitude'] != null) {
|
||||
this.openLocationOptions.latitude = data['latitude'] as number;
|
||||
this.latitude = this.openLocationOptions.latitude;
|
||||
}
|
||||
if (data['longitude'] != null) {
|
||||
this.openLocationOptions.longitude = data['longitude'] as number;
|
||||
this.longitude = this.openLocationOptions.longitude;
|
||||
}
|
||||
if (data['scale'] != null) {
|
||||
this.openLocationOptions.scale = data['scale'] as number;
|
||||
}
|
||||
if (data['name'] != null) {
|
||||
this.openLocationOptions.name = data['name'] as string;
|
||||
}
|
||||
if (data['address'] != null) {
|
||||
this.openLocationOptions.address = data['address'] as string;
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.markers = [
|
||||
{
|
||||
id: 1,
|
||||
latitude: this.openLocationOptions.latitude,
|
||||
longitude: this.openLocationOptions.longitude,
|
||||
iconPath: targetPath,
|
||||
width: 50,
|
||||
height: 50
|
||||
} as Marker
|
||||
] as Marker[];
|
||||
}, 300);
|
||||
uni.$emit(this.successEventName, {});
|
||||
});
|
||||
uni.$emit(this.readyEventName, {});
|
||||
},
|
||||
getSystemInfo() {
|
||||
const info = uni.getWindowInfo();
|
||||
this.safeArea.top = info.safeAreaInsets.top;
|
||||
this.safeArea.bottom = info.safeAreaInsets.bottom;
|
||||
this.safeArea.left = info.safeAreaInsets.left;
|
||||
this.safeArea.right = info.safeAreaInsets.right;
|
||||
const systemInfo = uni.getSystemInfoSync()
|
||||
// const osLanguage = systemInfo.osLanguage
|
||||
const appLanguage = systemInfo.appLanguage
|
||||
this.language = appLanguage
|
||||
const osTheme = systemInfo.osTheme
|
||||
const appTheme = systemInfo.appTheme
|
||||
if (appTheme != null && appTheme != "auto") {
|
||||
this.theme = appTheme
|
||||
} else if (osTheme != null) {
|
||||
this.theme = osTheme
|
||||
}
|
||||
this.isLandscape = systemInfo.deviceOrientation == 'landscape'
|
||||
// #ifdef WEB
|
||||
const hostTheme = systemInfo.hostTheme
|
||||
if (hostTheme != null) {
|
||||
this.theme = hostTheme
|
||||
}
|
||||
const locale = uni.getLocale()
|
||||
this.language = locale
|
||||
uni.onLocaleChange((res) => {
|
||||
if (res.locale) {
|
||||
this.language = res.locale
|
||||
}
|
||||
})
|
||||
uni.onThemeChange((res) => {
|
||||
this.theme = res.theme
|
||||
});
|
||||
// #endif
|
||||
// #ifdef APP-ANDROID || APP-IOS
|
||||
uni.onAppThemeChange((res : AppThemeChangeResult) => {
|
||||
this.theme = res.appTheme
|
||||
})
|
||||
uni.onOsThemeChange((res : OsThemeChangeResult) => {
|
||||
this.theme = res.osTheme
|
||||
})
|
||||
// #endif
|
||||
},
|
||||
closeDialogPage() {
|
||||
// #ifdef APP-ANDROID
|
||||
uni.closeDialogPage({
|
||||
dialogPage: this.$page
|
||||
} as io.dcloud.uniapp.framework.extapi.CloseDialogPageOptions)
|
||||
// #endif
|
||||
// #ifndef APP-ANDROID
|
||||
uni.closeDialogPage({
|
||||
dialogPage: this.$page
|
||||
})
|
||||
// #endif
|
||||
},
|
||||
back() {
|
||||
this.closeDialogPage();
|
||||
},
|
||||
getMapContext() : MapContext | null {
|
||||
return uni.createMapContext(this.mapId, this);
|
||||
},
|
||||
moveToLocation() {
|
||||
const mapContext = this.getMapContext();
|
||||
if (mapContext != null) {
|
||||
mapContext.moveToLocation({});
|
||||
}
|
||||
},
|
||||
mapReset() {
|
||||
this.moveToLocation();
|
||||
},
|
||||
navigation() {
|
||||
const appBaseInfo = uni.getAppBaseInfo();
|
||||
// #ifdef APP-ANDROID
|
||||
const src = appBaseInfo.packageName;
|
||||
// #endif
|
||||
// #ifdef APP-IOS
|
||||
const src = appBaseInfo.bundleId;
|
||||
// #endif
|
||||
// #ifdef WEB
|
||||
const src = 'webapp.baidu.openAPIdemo';
|
||||
// #endif
|
||||
// #ifdef APP-HARMONY
|
||||
const src = appBaseInfo.packageName;
|
||||
// #endif
|
||||
|
||||
const list = ["腾讯地图", "高德地图", "百度地图"] as Array<string>;
|
||||
// #ifdef APP-IOS
|
||||
list.push("苹果地图");
|
||||
// #endif
|
||||
// #ifdef APP-HARMONY
|
||||
// TODO: 华为地图有问题,暂不支持
|
||||
// list.push("华为地图");
|
||||
// #endif
|
||||
uni.showActionSheet({
|
||||
itemList: list,
|
||||
success: (res) => {
|
||||
let index = res.tapIndex;
|
||||
if (index >= 0) {
|
||||
let item = list[index] as string;
|
||||
try {
|
||||
let url = "";
|
||||
if (item == "腾讯地图") {
|
||||
// #ifdef APP
|
||||
url = `qqmap://map/routeplan?type=drive&from=我的位置&fromcoord=CurrentLocation&to=${this.openLocationOptions.name}&tocoord=${this.openLocationOptions.latitude},${this.openLocationOptions.longitude}&referer=1`;
|
||||
// #endif
|
||||
// #ifdef WEB
|
||||
url = `https://apis.map.qq.com/uri/v1/marker?marker=coord:${this.openLocationOptions.latitude},${this.openLocationOptions.longitude};title:${this.openLocationOptions.name};addr:${this.openLocationOptions.address}&referer=1`;
|
||||
// #endif
|
||||
} else if (item == "高德地图") {
|
||||
// #ifdef APP-ANDROID
|
||||
url = `androidamap://route/plan/?sourceApplication=${src}&slat=&slon=&sname=我的位置&dlat=${this.openLocationOptions.latitude}&dlon=${this.openLocationOptions.longitude}&dname=${this.openLocationOptions.name}&dev=0&t=0`;
|
||||
// #endif
|
||||
// #ifdef APP-IOS
|
||||
url = `iosamap://path?sourceApplication=${src}&slat=&slon=&sname=我的位置&dlat=${this.openLocationOptions.latitude}&dlon=${this.openLocationOptions.longitude}&dname=${this.openLocationOptions.name}&dev=0&t=0`;
|
||||
// #endif
|
||||
// #ifdef WEB
|
||||
url = `https://uri.amap.com/navigation?to=${this.openLocationOptions.longitude},${this.openLocationOptions.latitude},${this.openLocationOptions.name},${this.openLocationOptions.address}&mode=car&policy=0&src=mypage&coordinate=gaode&callnative=1`;
|
||||
// #endif
|
||||
// #ifdef APP-HARMONY
|
||||
url = `amapuri://route/plan?dlat=${this.openLocationOptions.latitude}&dlon=${this.openLocationOptions.longitude}&dname=${this.openLocationOptions.name}&sname=我的位置&t=0&sourceApplication=${src}`;
|
||||
// #endif
|
||||
} else if (item == "百度地图") {
|
||||
// #ifdef APP
|
||||
url = `baidumap://map/direction?origin=我的位置&destination=latlng:${this.openLocationOptions.latitude},${this.openLocationOptions.longitude}|name:${this.openLocationOptions.name}&coord_type=gcj02&mode=driving&src=${src}`;
|
||||
// #endif
|
||||
// #ifdef WEB
|
||||
url = `https://api.map.baidu.com/marker?coord_type=gcj02&location=${this.openLocationOptions.latitude},${this.openLocationOptions.longitude}&title=${this.openLocationOptions.name}&content=${this.openLocationOptions.address}&output=html&src=${src}`;
|
||||
// #endif
|
||||
} else if (item == "苹果地图") {
|
||||
// #ifdef APP-IOS
|
||||
url = `maps://?ll=${this.openLocationOptions.latitude},${this.openLocationOptions.longitude}&q=${this.openLocationOptions.name}`;
|
||||
// #endif
|
||||
} else if (item == "华为地图") {
|
||||
// #ifdef APP-HARMONY
|
||||
url = `petalmaps://route?saddr=我的位置&daddr=${this.openLocationOptions.latitude},${this.openLocationOptions.longitude}&type=drive&utm_source=${src}`;
|
||||
// #endif
|
||||
}
|
||||
if (url != "") {
|
||||
// #ifdef APP-HARMONY
|
||||
try {
|
||||
openSchema(url);
|
||||
} catch(err){
|
||||
uni.showToast({
|
||||
title: `打开失败${err.message}`,
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-ANDROID || APP-IOS
|
||||
let schemaPrefix = "";
|
||||
const schemaIndex = url.indexOf('?');
|
||||
if (schemaIndex != -1) {
|
||||
schemaPrefix = url.substring(0, schemaIndex);
|
||||
}
|
||||
if (canOpenURL(schemaPrefix)) {
|
||||
openSchema(url);
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: `请先安装${item}`,
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifdef WEB
|
||||
window.open(url);
|
||||
// #endif
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
languageCom() : UTSJSONObject {
|
||||
const textInfo = languageData[this.language] != null ? languageData[this.language] as UTSJSONObject : languageData['zh-Hans'] as UTSJSONObject;
|
||||
return textInfo;
|
||||
},
|
||||
classCom() : string {
|
||||
let list = [] as Array<string>;
|
||||
if (this.theme == 'dark') {
|
||||
list.push('uni-open-location-dark');
|
||||
} else {
|
||||
list.push('uni-open-location-light');
|
||||
}
|
||||
return list.join(' ');
|
||||
},
|
||||
landscapeClassCom() : string {
|
||||
return this.isLandscape ? 'uni-open-location-landscape' : '';
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: UniOpenLocationFontFamily;
|
||||
src: url('data:font/ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwR1NVQiCLJXoAAAE4AAAAVE9TLzI8MUlTAAABjAAAAGBjbWFwgOWDPQAAAgQAAAHIZ2x5ZhfxkmkAAAPcAAAD3GhlYWQpzkauAAAA4AAAADZoaGVhB94DhwAAALwAAAAkaG10eBgAAAAAAAHsAAAAGGxvY2EDjAKGAAADzAAAAA5tYXhwARQAfwAAARgAAAAgbmFtZYQALlwAAAe4AAADM3Bvc3Rnid8OAAAK7AAAAGgAAQAAA4D/gABcBAAAAAAABAAAAQAAAAAAAAAAAAAAAAAAAAYAAQAAAAEAAP9wa2RfDzz1AAsEAAAAAADjV4FYAAAAAONXgVgAAP+ABAADgQAAAAgAAgAAAAAAAAABAAAABgBzAAQAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKADAAPgACREZMVAAObGF0bgAaAAQAAAAAAAAAAQAAAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAQEAAGQAAUAAAKJAswAAACPAokCzAAAAesAMgEIAAACAAUDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBmRWQAwOYc5oMDgP+AAAAD3ACAAAAAAQAAAAAAAAA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aW5nAAA=') format('truetype');
|
||||
}
|
||||
|
||||
.uni-open-location-icons {
|
||||
font-family: "UniOpenLocationFontFamily";
|
||||
font-size: 16px;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.uni-open-location {
|
||||
position: relative;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #f8f8f8;
|
||||
z-index: 999;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-map-box {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-map {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-map-reset {
|
||||
position: absolute;
|
||||
left: 20px;
|
||||
bottom: 40px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
box-sizing: border-box;
|
||||
background-color: #fff;
|
||||
border-radius: 20px;
|
||||
pointer-events: auto;
|
||||
box-shadow: 0px 0px 20px 2px rgba(0, 0, 0, .3);
|
||||
z-index: 9;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-map-reset .uni-open-location-map-reset-icon {
|
||||
font-size: 26px;
|
||||
text-align: center;
|
||||
line-height: 40px;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-nav {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 60px;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
background-image: linear-gradient(to bottom, rgba(0, 0, 0, .3), rgba(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-nav .uni-open-location-nav-btn {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
left: 5px;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-nav .uni-open-location-nav-btn.uni-open-location-nav-back-btn .uni-open-location-nav-back-text {
|
||||
color: #fff;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-footer {
|
||||
height: 150px;
|
||||
border-radius: 10px 10px 0px 0px;
|
||||
overflow: hidden;
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0px 20px;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-footer .uni-open-location-address {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-footer .uni-open-location-name-text {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-footer .uni-open-location-address-text {
|
||||
font-size: 16px;
|
||||
margin-top: 10px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-footer-icon-btns {
|
||||
width: 100px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-footer-icon-btns .uni-open-location-footer-icon-btns-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-footer-icon-btns .uni-open-location-footer-icon-btns-item .uni-open-location-footer-icon-box {
|
||||
background-color: #f8f8f8;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-footer-icon-btns .uni-open-location-footer-icon-btns-item .uni-open-location-footer-icon-box .uni-open-location-icons {
|
||||
color: #007aff;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-footer-icon-btns .uni-open-location-footer-icon-btns-item .uni-open-location-footer-btn-text {
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.uni-open-location .uni-open-location-footer-icon-btns .uni-open-location-footer-icon-btns-item:active {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.uni-open-location.uni-open-location-dark .uni-open-location-map-reset {
|
||||
background-color: #111111;
|
||||
}
|
||||
|
||||
.uni-open-location.uni-open-location-dark .uni-open-location-map-reset .uni-open-location-map-reset-icon {
|
||||
color: #d1d1d1;
|
||||
}
|
||||
|
||||
.uni-open-location.uni-open-location-dark .uni-open-location-footer {
|
||||
background-color: #181818;
|
||||
}
|
||||
|
||||
.uni-open-location.uni-open-location-dark .uni-open-location-footer .uni-open-location-name-text {
|
||||
color: #fafafa;
|
||||
}
|
||||
|
||||
.uni-open-location.uni-open-location-dark .uni-open-location-footer .uni-open-location-address-text {
|
||||
color: #fafafa;
|
||||
}
|
||||
|
||||
.uni-open-location.uni-open-location-dark .uni-open-location-footer-icon-btns .uni-open-location-footer-icon-btns-item .uni-open-location-footer-icon-box {
|
||||
background-color: #393939;
|
||||
}
|
||||
|
||||
.uni-open-location.uni-open-location-dark .uni-open-location-footer-icon-btns .uni-open-location-footer-icon-btns-item .uni-open-location-footer-btn-text {
|
||||
color: #909090;
|
||||
}
|
||||
</style>
|
||||
BIN
uni_modules/uni-openLocation/pages/openLocation/target.png
Normal file
BIN
uni_modules/uni-openLocation/pages/openLocation/target.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
12
uni_modules/uni-openLocation/pages_init.json
Normal file
12
uni_modules/uni-openLocation/pages_init.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "uni_modules/uni-openLocation/pages/openLocation/openLocation",
|
||||
"style": {
|
||||
"navigationBarTitleText": " ",
|
||||
"navigationStyle": "custom",
|
||||
"disableSwipeBack": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
9
uni_modules/uni-openLocation/readme.md
Normal file
9
uni_modules/uni-openLocation/readme.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# uni-openLocation
|
||||
|
||||
> Android 和 iOS 需 HBuilderX 4.41+
|
||||
>
|
||||
> Harmony 需 HBuilderX 4.61+
|
||||
|
||||
[使用文档](https://doc.dcloud.net.cn/uni-app-x/api/open-location.html)
|
||||
|
||||
**注意:此插件只支持uni-app x,不支持uni-app**
|
||||
36
uni_modules/uni-openLocation/utssdk/app-android/index.uts
Normal file
36
uni_modules/uni-openLocation/utssdk/app-android/index.uts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { OpenLocation, OpenLocationOptions, OpenLocationSuccessImpl, OpenLocationErrorCode } from "../interface.uts"
|
||||
import { OpenLocationFailImpl } from "../unierror.uts"
|
||||
|
||||
export const openLocation : OpenLocation = function (options : OpenLocationOptions) {
|
||||
const uuid = `${Date.now()}${Math.floor(Math.random() * 1e7)}`
|
||||
const baseEventName = `uni_open_location_${uuid}`
|
||||
const readyEventName = `${baseEventName}_ready`
|
||||
const optionsEventName = `${baseEventName}_options`
|
||||
const successEventName = `${baseEventName}_success`
|
||||
const failEventName = `${baseEventName}_fail`
|
||||
|
||||
const readyEventId = uni.$on(readyEventName, () => {
|
||||
uni.$emit(optionsEventName, JSON.parse(JSON.stringify(options)))
|
||||
})
|
||||
const successEventId = uni.$on(successEventName, () => {
|
||||
const res = new OpenLocationSuccessImpl()
|
||||
options.success?.(res)
|
||||
options.complete?.(res)
|
||||
})
|
||||
const failEventId = uni.$on(failEventName, (errCode : OpenLocationErrorCode) => {
|
||||
const res = new OpenLocationFailImpl(errCode)
|
||||
options.fail?.(res)
|
||||
options.complete?.(res)
|
||||
})
|
||||
uni.openDialogPage({
|
||||
url: `/uni_modules/uni-openLocation/pages/openLocation/openLocation?readyEventName=${readyEventName}&optionsEventName=${optionsEventName}&successEventName=${successEventName}&failEventName=${failEventName}`,
|
||||
fail(err) {
|
||||
const res = new OpenLocationFailImpl(4)
|
||||
options.fail?.(res)
|
||||
options.complete?.(res)
|
||||
uni.$off(readyEventName, readyEventId)
|
||||
uni.$off(successEventName, successEventId)
|
||||
uni.$off(failEventName, failEventId)
|
||||
}
|
||||
})
|
||||
};
|
||||
36
uni_modules/uni-openLocation/utssdk/app-harmony/index.uts
Normal file
36
uni_modules/uni-openLocation/utssdk/app-harmony/index.uts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { OpenLocation, OpenLocationOptions, OpenLocationSuccessImpl, OpenLocationErrorCode } from "../interface.uts"
|
||||
import { OpenLocationFailImpl } from "../unierror.uts"
|
||||
|
||||
export const openLocation : OpenLocation = function (options : OpenLocationOptions) {
|
||||
const uuid = `${Date.now()}${Math.floor(Math.random() * 1e7)}`
|
||||
const baseEventName = `uni_open_location_${uuid}`
|
||||
const readyEventName = `${baseEventName}_ready`
|
||||
const optionsEventName = `${baseEventName}_options`
|
||||
const successEventName = `${baseEventName}_success`
|
||||
const failEventName = `${baseEventName}_fail`
|
||||
|
||||
const readyEventId = uni.$on(readyEventName, () => {
|
||||
uni.$emit(optionsEventName, JSON.parse(JSON.stringify(options)))
|
||||
})
|
||||
const successEventId = uni.$on(successEventName, () => {
|
||||
const res = new OpenLocationSuccessImpl()
|
||||
options.success?.(res)
|
||||
options.complete?.(res)
|
||||
})
|
||||
const failEventId = uni.$on(failEventName, (errCode : OpenLocationErrorCode) => {
|
||||
const res = new OpenLocationFailImpl(errCode)
|
||||
options.fail?.(res)
|
||||
options.complete?.(res)
|
||||
})
|
||||
uni.openDialogPage({
|
||||
url: `/uni_modules/uni-openLocation/pages/openLocation/openLocation?readyEventName=${readyEventName}&optionsEventName=${optionsEventName}&successEventName=${successEventName}&failEventName=${failEventName}`,
|
||||
fail(err) {
|
||||
const res = new OpenLocationFailImpl(4)
|
||||
options.fail?.(res)
|
||||
options.complete?.(res)
|
||||
uni.$off(readyEventName, readyEventId)
|
||||
uni.$off(successEventName, successEventId)
|
||||
uni.$off(failEventName, failEventId)
|
||||
}
|
||||
})
|
||||
};
|
||||
14
uni_modules/uni-openLocation/utssdk/app-ios/Info.plist
Normal file
14
uni_modules/uni-openLocation/utssdk/app-ios/Info.plist
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
<string>qqmap</string>
|
||||
<string>iosamap</string>
|
||||
<string>baidumap</string>
|
||||
</array>
|
||||
|
||||
</dict>
|
||||
</plist>
|
||||
36
uni_modules/uni-openLocation/utssdk/app-ios/index.uts
Normal file
36
uni_modules/uni-openLocation/utssdk/app-ios/index.uts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { OpenLocation, OpenLocationOptions, OpenLocationSuccessImpl } from "../interface.uts"
|
||||
import { OpenLocationFailImpl } from "../unierror.uts"
|
||||
|
||||
export const openLocation : OpenLocation = function (options : OpenLocationOptions) {
|
||||
const uuid = `${Date.now()}${Math.floor(Math.random() * 1e7)}`
|
||||
const baseEventName = `uni_open_location_${uuid}`
|
||||
const readyEventName = `${baseEventName}_ready`
|
||||
const optionsEventName = `${baseEventName}_options`
|
||||
const successEventName = `${baseEventName}_success`
|
||||
const failEventName = `${baseEventName}_fail`
|
||||
|
||||
uni.$on(readyEventName, () => {
|
||||
uni.$emit(optionsEventName, JSON.parse(JSON.stringify(options)!))
|
||||
})
|
||||
uni.$on(successEventName, () => {
|
||||
const res = new OpenLocationSuccessImpl()
|
||||
options.success?.(res)
|
||||
options.complete?.(res)
|
||||
})
|
||||
uni.$on(failEventName, () => {
|
||||
const res = new OpenLocationFailImpl(4)
|
||||
options.fail?.(res)
|
||||
options.complete?.(res)
|
||||
})
|
||||
uni.openDialogPage({
|
||||
url: `/uni_modules/uni-openLocation/pages/openLocation/openLocation?readyEventName=${readyEventName}&optionsEventName=${optionsEventName}&successEventName=${successEventName}&failEventName=${failEventName}`,
|
||||
fail(err) {
|
||||
const res = new OpenLocationFailImpl(4)
|
||||
options.fail?.(res)
|
||||
options.complete?.(res)
|
||||
uni.$off(readyEventName)
|
||||
uni.$off(successEventName)
|
||||
uni.$off(failEventName)
|
||||
}
|
||||
})
|
||||
};
|
||||
418
uni_modules/uni-openLocation/utssdk/interface.uts
Normal file
418
uni_modules/uni-openLocation/utssdk/interface.uts
Normal file
@@ -0,0 +1,418 @@
|
||||
/**
|
||||
* 错误码
|
||||
*/
|
||||
export type OpenLocationErrorCode =
|
||||
/**
|
||||
* 框架内部错误
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "5.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.23",
|
||||
* "unixVer": "4.61"
|
||||
* }
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.0"
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "uniVer": "x",
|
||||
* "unixVer": "x"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
4;
|
||||
|
||||
export interface OpenLocationSuccess {
|
||||
errMsg: string
|
||||
}
|
||||
|
||||
type OpenLocationSuccessCallback = (result : OpenLocationSuccess) => void
|
||||
|
||||
export interface OpenLocationFail extends IUniError {
|
||||
errCode : OpenLocationErrorCode
|
||||
}
|
||||
type OpenLocationFailCallback = (result : OpenLocationFail) => void
|
||||
|
||||
export type OpenLocationComplete = any
|
||||
type OpenLocationCompleteCallback = (result : OpenLocationComplete) => void
|
||||
|
||||
/**
|
||||
* uni.openLocation函数参数定义
|
||||
*/
|
||||
export type OpenLocationOptions = {
|
||||
/**
|
||||
* 纬度,范围为-90~90,负数表示南纬,使用 gcj02 国测局坐标系
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "5.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.23",
|
||||
* "unixVer": "4.61"
|
||||
* }
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.0"
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
latitude : number,
|
||||
/**
|
||||
* 经度,范围为-180~180,负数表示西经,使用 gcj02 国测局坐标系
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "5.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.23",
|
||||
* "unixVer": "4.61"
|
||||
* }
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.0"
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
longitude : number,
|
||||
/**
|
||||
* 缩放比例,范围5~18,默认为18(微信小程序)
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "5.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.23",
|
||||
* "unixVer": "4.61"
|
||||
* }
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.0"
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
scale ?: number | null,
|
||||
/**
|
||||
* 位置名
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "5.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.23",
|
||||
* "unixVer": "4.61"
|
||||
* }
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.0"
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
name ?: string | null,
|
||||
/**
|
||||
* 地址的详细说明
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "5.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.23",
|
||||
* "unixVer": "4.61"
|
||||
* }
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.0"
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
address ?: string | null,
|
||||
/**
|
||||
* 接口调用成功的回调函数
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "5.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.23",
|
||||
* "unixVer": "4.61"
|
||||
* }
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.0"
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
success ?: OpenLocationSuccessCallback | null,
|
||||
/**
|
||||
* 接口调用失败的回调函数
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "5.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.23",
|
||||
* "unixVer": "4.61"
|
||||
* }
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.0"
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
fail ?: OpenLocationFailCallback | null,
|
||||
/**
|
||||
* 接口调用结束的回调函数(调用成功、失败都会执行)
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "5.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.23",
|
||||
* "unixVer": "4.61"
|
||||
* }
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.0"
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
complete ?: OpenLocationCompleteCallback | null
|
||||
};
|
||||
|
||||
/**
|
||||
* 使用应用内置地图查看位置
|
||||
*
|
||||
* @param {OpenLocationOptions} options
|
||||
* @tutorial https://doc.dcloud.net.cn/uni-app-x/api/prompt.html#openLocation
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "5.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.23",
|
||||
* "unixVer": "4.61"
|
||||
* }
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.0"
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
export type OpenLocation = (options : OpenLocationOptions) => void;
|
||||
|
||||
export interface Uni {
|
||||
/**
|
||||
* @description 使用应用内置地图查看位置
|
||||
* @example
|
||||
* ```typescript
|
||||
uni.openLocation({
|
||||
latitude: 39.908823,
|
||||
longitude: 116.39747,
|
||||
success: (res) => {
|
||||
console.log('res: ', res)
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('err: ', err)
|
||||
},
|
||||
complete: (res) => {
|
||||
console.log('complete: ', res)
|
||||
}
|
||||
});
|
||||
* ```
|
||||
* @tutorial https://doc.dcloud.net.cn/uni-app-x/api/prompt.html#openLocation
|
||||
* @uniPlatform {
|
||||
* "app": {
|
||||
* "android": {
|
||||
* "osVer": "5.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "ios": {
|
||||
* "osVer": "12.0",
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* },
|
||||
* "harmony": {
|
||||
* "osVer": "3.0",
|
||||
* "uniVer": "4.23",
|
||||
* "unixVer": "4.61"
|
||||
* }
|
||||
* },
|
||||
* "web": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.0"
|
||||
* },
|
||||
* "mp": {
|
||||
* "weixin": {
|
||||
* "uniVer": "√",
|
||||
* "unixVer": "4.41"
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
openLocation(options : OpenLocationOptions) : void;
|
||||
}
|
||||
|
||||
export class OpenLocationSuccessImpl implements OpenLocationSuccess {
|
||||
errMsg : string
|
||||
constructor(errMsg : string = 'chooseLocation:ok') {
|
||||
this.errMsg = errMsg
|
||||
}
|
||||
}
|
||||
30
uni_modules/uni-openLocation/utssdk/unierror.uts
Normal file
30
uni_modules/uni-openLocation/utssdk/unierror.uts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { OpenLocationErrorCode, OpenLocationFail } from "./interface.uts"
|
||||
|
||||
/**
|
||||
* 错误主题
|
||||
*/
|
||||
|
||||
export const UniErrorSubject = 'uni-openLocation';
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
* @UniError
|
||||
*/
|
||||
export const UniErrors : Map<OpenLocationErrorCode, string> = new Map([
|
||||
/**
|
||||
* 框架内部错误
|
||||
*/
|
||||
[4, 'internal error']
|
||||
]);
|
||||
|
||||
export class OpenLocationFailImpl extends UniError implements OpenLocationFail {
|
||||
// #ifndef APP-IOS
|
||||
override errCode : OpenLocationErrorCode;
|
||||
// #endif
|
||||
constructor(errCode : OpenLocationErrorCode) {
|
||||
super();
|
||||
this.errSubject = UniErrorSubject;
|
||||
this.errCode = errCode;
|
||||
this.errMsg = UniErrors.get(errCode) ?? "";
|
||||
}
|
||||
}
|
||||
36
uni_modules/uni-openLocation/utssdk/web/index.uts
Normal file
36
uni_modules/uni-openLocation/utssdk/web/index.uts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { OpenLocation, OpenLocationOptions, OpenLocationSuccessImpl, OpenLocationErrorCode } from "../interface.uts"
|
||||
import { OpenLocationFailImpl } from "../unierror.uts"
|
||||
|
||||
export const openLocation : OpenLocation = function (options : OpenLocationOptions) {
|
||||
const uuid = `${Date.now()}${Math.floor(Math.random() * 1e7)}`
|
||||
const baseEventName = `uni_open_location_${uuid}`
|
||||
const readyEventName = `${baseEventName}_ready`
|
||||
const optionsEventName = `${baseEventName}_options`
|
||||
const successEventName = `${baseEventName}_success`
|
||||
const failEventName = `${baseEventName}_fail`
|
||||
|
||||
const readyEventId = uni.$on(readyEventName, () => {
|
||||
uni.$emit(optionsEventName, JSON.parse(JSON.stringify(options)))
|
||||
})
|
||||
const successEventId = uni.$on(successEventName, () => {
|
||||
const res = new OpenLocationSuccessImpl()
|
||||
options.success?.(res)
|
||||
options.complete?.(res)
|
||||
})
|
||||
const failEventId = uni.$on(failEventName, (errCode : OpenLocationErrorCode) => {
|
||||
const res = new OpenLocationFailImpl(errCode)
|
||||
options.fail?.(res)
|
||||
options.complete?.(res)
|
||||
})
|
||||
uni.openDialogPage({
|
||||
url: `/uni_modules/uni-openLocation/pages/openLocation/openLocation?readyEventName=${readyEventName}&optionsEventName=${optionsEventName}&successEventName=${successEventName}&failEventName=${failEventName}`,
|
||||
fail(err) {
|
||||
const res = new OpenLocationFailImpl(4)
|
||||
options.fail?.(res)
|
||||
options.complete?.(res)
|
||||
uni.$off(readyEventName, readyEventId)
|
||||
uni.$off(successEventName, successEventId)
|
||||
uni.$off(failEventName, failEventId)
|
||||
}
|
||||
})
|
||||
};
|
||||
Reference in New Issue
Block a user