From 0231109223d2ab5995d0d6e721ef4ea1ad8cccfd Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期五, 14 二月 2025 09:13:57 +0800
Subject: [PATCH] Merge branch 'master' of http://120.26.58.240:8888/r/flexJobMiniApp
---
packages/components/src/Input/ChooseLocationInput.vue | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 103 insertions(+), 0 deletions(-)
diff --git a/packages/components/src/Input/ChooseLocationInput.vue b/packages/components/src/Input/ChooseLocationInput.vue
new file mode 100644
index 0000000..d576d5e
--- /dev/null
+++ b/packages/components/src/Input/ChooseLocationInput.vue
@@ -0,0 +1,103 @@
+<template>
+ <nut-input
+ class="nut-input-text bole-input-text"
+ type="text"
+ input-align="right"
+ readonly
+ @click="handleChooseLocation"
+ :modelValue="props.modelValue.address"
+ alwaysEmbed
+ >
+ <template #clear>
+ <slot name="clear"></slot>
+ </template>
+ <template #left>
+ <slot name="left"></slot>
+ </template>
+ <template #right>
+ <slot name="right">
+ <img :src="IconLocation" class="choose-location-input-icon" />
+ </slot>
+ </template>
+ </nut-input>
+</template>
+
+<script setup lang="ts">
+import Taro from '@tarojs/taro';
+import IconLocation from '../../assets/components/icon-location.png';
+import { computed } from 'vue';
+import { useAllAreaList } from '@12333/hooks';
+
+defineOptions({
+ name: 'ChooseLocationInput',
+});
+
+type Props = {
+ modelValue: WeMapModel;
+};
+
+const props = defineProps<Props>();
+
+const emit = defineEmits<{
+ (e: 'update:modelValue', value: Props['modelValue']): void;
+}>();
+
+const { findAreaCodeFromName } = useAllAreaList();
+
+const innerModelValue = computed({
+ get() {
+ return props.modelValue;
+ },
+ set(val) {
+ emit('update:modelValue', val);
+ },
+});
+
+function handleChooseLocation() {
+ Taro.chooseLocation({
+ success: function (res) {
+ console.log('res: ', res);
+ const latitude = res.latitude as unknown as number;
+ const longitude = res.longitude as unknown as number;
+ let provinceName = '';
+ let cityName = '';
+ let countyName = '';
+ let nameList = res.address.match(
+ /.+?(鐪亅琛屾斂鍖簗甯倈鑷不鍖簗鑷不宸瀨琛屾斂鍗曚綅|鐩焲甯傝緰鍖簗鏃梶娴峰煙|宀泑鍘縷鍖�)/g
+ );
+ if (nameList) {
+ if (nameList?.length === 2) {
+ provinceName = nameList[0];
+ cityName = nameList[0];
+ countyName = nameList[1];
+ } else {
+ provinceName = nameList[0];
+ cityName = nameList[1];
+ countyName = nameList[2];
+ }
+ }
+ emit('update:modelValue', {
+ latitude,
+ longitude,
+ provinceName,
+ cityName,
+ countyName,
+ provinceCode: findAreaCodeFromName(provinceName),
+ cityCode: findAreaCodeFromName(cityName),
+ countyCode: findAreaCodeFromName(countyName),
+ address: res.address,
+ });
+ },
+ });
+}
+</script>
+
+<style lang="scss">
+@import '@/styles/common.scss';
+
+.choose-location-input-icon {
+ width: 19px;
+ height: 25px;
+ margin-left: 10px;
+}
+</style>
--
Gitblit v1.10.0