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

Merge branch 'alpha'

......@@ -52,20 +52,18 @@ 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))
} 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?.()
}
function (options: CreateCanvasContextAsyncOptions) {
const currentPage: ComponentPublicInstance = options.component ?? (getCurrentPages()[getCurrentPages().length - 1]).vm as ComponentPublicInstance
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)
}
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,30 +351,37 @@
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);
});
});
promise.then((res) => {
this.callUniMapCoErr = false;
});
promise.catch((err) => {
})
.catch((err) => {
this.callUniMapCoErr = true;
});
return promise as Promise<UTSJSONObject>;
......@@ -404,7 +414,7 @@
}).catch((err) => {
this.searchLoading = false;
})
} else {
} else {
this.callUniMapCo("location2address", {
location: `${latitude},${longitude}`,
get_poi: 1,
......@@ -579,7 +589,7 @@
poiSearch(type : string) {
this.clearSearchValueChangeTimer();
this.pageIndex = 1;
this.selected = -1;
this.selected = -1;
this.getPoi(type);
},
cancelSearch() {
......@@ -604,7 +614,7 @@
this.scrollTop = scrollTop;
}, 10);
},
selectPoi(item : Poi, index : number) {
selectPoi(item : Poi, index : number) {
this.isFocus = false;
this.selected = index;
this.latitude = item.location.latitude;
......@@ -626,7 +636,7 @@
this.pageIndex++;
this.getPoi('scrolltolower');
},
mapReset() {
mapReset() {
this.isFocus = false;
this.pageIndex = 1;
this.getLocation();
......@@ -644,7 +654,7 @@
})
// #endif
},
back() {
back() {
uni.$emit(this.failEventName, 1);
this.closeDialogPage();
},
......@@ -794,12 +804,12 @@
display: flex;
justify-content: center;
align-items: center;
}
.uni-choose-location-map-reset.uni-choose-location-vertical {
transition-property: transform;
transition-duration: 0.25s;
transition-timing-function: ease-out;
}
.uni-choose-location-map-reset.uni-choose-location-vertical {
transition-property: transform;
transition-duration: 0.25s;
transition-timing-function: ease-out;
}
.uni-choose-location-map-reset-icon {
......@@ -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 {
......@@ -1075,16 +1085,19 @@
.uni-choose-location-dark .uni-choose-location-map-reset-icon {
color: #d1d1d1;
}
.uni-choose-location-dark .uni-choose-location-poi-search-error-text {
color: #d1d1d1;
}
/* 暗黑模式样式结束 */
/* 暗黑模式样式结束 */
/* #ifdef WEB */
uni-image > div {
width: 100%;
height: 100%;
background-repeat: no-repeat;
}
/* #endif */
</style>
</style>
......@@ -2,14 +2,61 @@
* 错误码
*/
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,
......@@ -30,28 +77,193 @@ type ChooseLocationCompleteCallback = (result : ChooseLocationComplete) => void
* uni.chooseLocation函数参数定义
*/
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,
/**
* 接口调用成功的回调函数
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,13 +278,13 @@ 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",
* "uniVer": "4.23",
......@@ -148,13 +360,13 @@ export class ChooseLocationSuccessImpl extends AsyncApiSuccessResult implements
this.latitude = latitude
this.longitude = longitude
}
}
}
export class ChooseLocationFailImpl extends UniError implements ChooseLocationFail {
override errCode : ChooseLocationErrorCode
constructor(errMsg : string = 'chooseLocation:fail cancel', errCode : ChooseLocationErrorCode = 4) {
super(errMsg)
this.errCode = errCode
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.
先完成此消息的编辑!
想要评论请 注册