提交 e9d0a0d7 编写于 作者: DCloud-yyl's avatar DCloud-yyl

Merge branch 'alpha'

......@@ -54,18 +54,16 @@ class CanvasContextImpl implements CanvasContext {
export const createCanvasContextAsync =
function (options: CreateCanvasContextAsyncOptions) {
const currentPage: ComponentPublicInstance = options.component ?? (getCurrentPages()[getCurrentPages().length - 1]).vm as ComponentPublicInstance
if (currentPage != null) {
const element = currentPage.$el?.querySelector('#' + options.id)
if (element != null) {
const canvas = element as UniCanvasElement
options.success?.(new CanvasContextImpl(canvas))
currentPage.createSelectorQuery().select('#' + options.id).fields({
node: true
} as NodeField, (ret) => {
const node = (ret as NodeInfo).node
if (node != null) {
options.success?.(new CanvasContextImpl(node as UniCanvasElement))
} else {
const uniError = new UniError('uni-createCanvasContextAsync', -1, 'canvas id invalid.')
options.fail?.(uniError)
}
} else {
const uniError = new UniError('uni-createCanvasContextAsync', -1, 'No found current page.')
options.fail?.(uniError)
}
options.complete?.()
}).exec()
}
......@@ -260,6 +260,9 @@
} else {
this.chooseLocationOptions.keyword = "";
}
if (data['payload'] != null) {
this.chooseLocationOptions.payload = data['payload'] as UTSJSONObject;
}
});
uni.$emit(this.readyEventName, {});
},
......@@ -348,21 +351,28 @@
customUI: true,
});
// #endif
uniMapCo.chooseLocation({
let chooseLocationData = {
action: action,
data: data
}).then((res : UTSJSONObject) => {
} as UTSJSONObject;
if (this.chooseLocationOptions.payload != null) {
chooseLocationData['payload'] = this.chooseLocationOptions.payload;
}
uniMapCo.chooseLocation(chooseLocationData).then((res : UTSJSONObject) => {
resolve(res);
}).catch((err) => {
if (err instanceof UniCloudError) {
const errCode = (err as UniCloudError).errCode;
const errMsg = (err as UniCloudError).errMsg;
const cloudError = err as UniCloudError;
const errCode = cloudError.errCode;
const errMsg = cloudError.errMsg;
const errSubject = cloudError.errSubject;
if (errMsg.indexOf("在云端不存在") > -1 || errMsg.indexOf("未匹配") > -1) {
this.errMsg = "uni.chooseLocation 依赖 uniCloud 的 uni-map-common 插件,请安装 uni-map-common 插件,插件地址:https://ext.dcloud.net.cn/plugin?id=13872";
console.error(this.errMsg);
} else {
this.errMsg = errMsg;
console.error("获取POI信息失败," + JSON.stringify({ errCode, errMsg }));
console.error("获取POI信息失败," + JSON.stringify({ errCode, errMsg, errSubject }));
}
}
reject(err);
......@@ -370,8 +380,8 @@
});
promise.then((res) => {
this.callUniMapCoErr = false;
});
promise.catch((err) => {
})
.catch((err) => {
this.callUniMapCoErr = true;
});
return promise as Promise<UTSJSONObject>;
......@@ -1037,7 +1047,7 @@
}
.uni-choose-location-dark .uni-choose-location-poi-search-box {
background-color: #181818;
background-color: #111111;
}
.uni-choose-location-dark .uni-choose-location-search-icon {
......@@ -1077,6 +1087,10 @@
color: #d1d1d1;
}
.uni-choose-location-dark .uni-choose-location-poi-search-error-text {
color: #d1d1d1;
}
/* 暗黑模式样式结束 */
/* #ifdef WEB */
......@@ -1085,6 +1099,5 @@
height: 100%;
background-repeat: no-repeat;
}
/* #endif */
</style>
......@@ -4,12 +4,59 @@
export type ChooseLocationErrorCode =
/**
* 取消
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.34"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.34"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "x",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.34"
* }
* }
*/
1 |
/**
* 框架内部错误
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.34"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.34"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "x",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.34"
* }
* }
*/
4;
export interface ChooseLocationSuccess extends AsyncApiSuccessResult {
name : string,
address : string,
......@@ -32,26 +79,191 @@ type ChooseLocationCompleteCallback = (result : ChooseLocationComplete) => void
export type ChooseLocationOptions = {
/**
* 指示位置的经度
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
latitude ?: number | null,
/**
* 指示位置的纬度
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
longitude ?: number | null,
/**
* 指示位置的名称
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
keyword ?: string | null,
/**
* 用户自定义参数
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.35"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.35"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.35"
* }
* }
*/
payload ?: UTSJSONObject | null,
/**
* 接口调用成功的回调函数
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
success ?: ChooseLocationSuccessCallback | null,
/**
* 接口调用失败的回调函数
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
fail ?: ChooseLocationFailCallback | null,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
complete ?: ChooseLocationCompleteCallback | null
};
......@@ -66,12 +278,12 @@ export type ChooseLocationOptions = {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9.0"
* "unixVer": "4.33"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* "unixVer": "4.33"
* },
* "harmony": {
* "osVer": "3.0",
......@@ -151,10 +363,10 @@ export class ChooseLocationSuccessImpl extends AsyncApiSuccessResult implements
}
export class ChooseLocationFailImpl extends UniError implements ChooseLocationFail {
override errCode : ChooseLocationErrorCode
constructor(errMsg : string = 'chooseLocation:fail cancel', errCode : ChooseLocationErrorCode = 4) {
super(errMsg)
constructor(errMsg : string = 'chooseLocation:fail cancel', errCode : ChooseLocationErrorCode = 1) {
super()
this.errCode = errCode
this.errMsg = errMsg
}
}
// #endif
......@@ -235,7 +235,7 @@ export type LoadFontFaceOptions = {
* }
* }
*/
source: string
source: string.FontURIString
/**
* 可选的字体描述符
* @uniPlatform {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册