From e789db0f9916cc2eab9ecbfd2564b83fc948c42a Mon Sep 17 00:00:00 2001 From: heweishui Date: Fri, 26 Jan 2024 17:38:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20chooseLocation=E6=8E=A5=E5=8F=A3harmony?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/apis/comments.ts | 8 - .../src/api/apis/location/chooseLocation.ts | 192 ++++++++++++++++++ .../src/api/apis/location/index.ts | 3 +- 3 files changed, 194 insertions(+), 9 deletions(-) create mode 100644 packages/taro-platform-harmony-hybrid/src/api/apis/location/chooseLocation.ts diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts index becc77eefa..45380bea18 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts @@ -55,14 +55,6 @@ * @canNotUse checkIsSupportSoterAuthentication */ -/** - * 打开地图选择位置。 - * - * @canUse chooseLocation - * @__object [mapOpts] - * @__success [address, latitude, longitude, name] - */ - /** * 拍摄视频或从手机相册中选视频 * diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/location/chooseLocation.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/location/chooseLocation.ts new file mode 100644 index 0000000000..3a77f11ff4 --- /dev/null +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/location/chooseLocation.ts @@ -0,0 +1,192 @@ +import Taro from '@tarojs/api' +import { stringify } from 'query-string' + +import { MethodHandler } from '../utils/handler' + +let container: HTMLDivElement | null = null +function createLocationChooser (handler, mapOpt: Taro.chooseLocation.Option['mapOpts'] = {}) { + // @ts-ignore + const systemBarHeight = window.systemBarHeight ? window.systemBarHeight : 0 + const { key = LOCATION_APIKEY, referer = 'myapp', ...opts } = mapOpt + const query = { + key, + type: 1, + referer, + ...opts, + } + if (!container) { + const css = ` +.taro_choose_location { + display: flex; + position: fixed; + top: 100%; + z-index: 1; + flex-direction: column; + width: 100%; + height: 100%; + background-color: #fff; + transition: ease top 0.3s; +} +.taro_choose_location_bar { + display: flex; + flex: 0 60px; + height: 60px; + background-color: #ededed; + color: #090909; + align-items: center; +} +.taro_choose_location_back { + position: relative; + flex: 0 40px; + margin-left: 10px; + width: 25px; + height: 30px; +} +.taro_choose_location_back::before { + display: block; + position: absolute; + left: 0; + top: 0; + border: solid 15px; + border-color: transparent #090909 transparent transparent; + width: 0; + height: 0; + content: ""; +} +.taro_choose_location_back::after { + display: block; + position: absolute; + left: 3px; + top: 0; + border: solid 15px; + border-color: transparent #ededed transparent transparent; + width: 0; + height: 0; + content: ""; +} +.taro_choose_location_title { + flex: 1; + padding-left: 30px; + line-height: 60px; +} +.taro_choose_location_submit { + margin-right: 25px; + padding: 0; + border: none; + width: 75px; + height: 40px; + background-color: #08bf62; + line-height: 40px; + font-size: 20px; + color: #fff; +} +.taro_choose_location_frame { + flex: 1; +} +` + const style = document.createElement('style') + style.innerHTML = css + document.getElementsByTagName('head')[0].appendChild(style) + + const html = ` +
+
+
+
+

位置

+ +
+