|
|
@@ -20,6 +20,14 @@
|
|
|
<Text>请输入家乡名称,然后选择地图位置定位哦</Text>
|
|
|
</FlexRow>
|
|
|
<Field v-model="currentVillageName" placeholder="请输入家乡名称,例如:大庆村" />
|
|
|
+ <Field
|
|
|
+ v-model="currentVillageDesc"
|
|
|
+ placeholder="输入家乡的介绍,可以让大家了解更多"
|
|
|
+ multiline
|
|
|
+ showWordLimit
|
|
|
+ :maxLength="300"
|
|
|
+ :inputStyle="{ height: '100px' }"
|
|
|
+ />
|
|
|
<Field label="类型" placeholder="请选择村社类型">
|
|
|
<FlexRow>
|
|
|
<RadioGroup v-model="currentVillageType">
|
|
|
@@ -52,7 +60,7 @@
|
|
|
:enable-satellite="enableSatellite"
|
|
|
:style="{
|
|
|
width: '100%',
|
|
|
- height: '500px',
|
|
|
+ height: '340px',
|
|
|
}"
|
|
|
@regionchange="handleRegionchange"
|
|
|
>
|
|
|
@@ -62,7 +70,7 @@
|
|
|
<Button :text="'切换' + (enableSatellite ? '地图' : '卫星')" @click="enableSatellite = !enableSatellite" />
|
|
|
</FlexRow>
|
|
|
<FlexCol gap="gap.md">
|
|
|
- <Button text="返回上一步" @click="step = 'selectArea'" />
|
|
|
+ <Button text="返回上一步" @click="handleBack" />
|
|
|
<Button text="立即建村" type="primary" @click="handleConfirm()" />
|
|
|
</FlexCol>
|
|
|
</template>
|
|
|
@@ -109,7 +117,7 @@ import Text from '@/components/basic/Text.vue';
|
|
|
import Button from '@/components/basic/Button.vue';
|
|
|
import Field from '@/components/form/Field.vue';
|
|
|
import LightVillageApi, { type VillageListItem } from '@/api/light/LightVillageApi';
|
|
|
-import { backAndCallOnPageBack } from '@/components/utils/PageAction';
|
|
|
+import { back, backAndCallOnPageBack } from '@/components/utils/PageAction';
|
|
|
import RadioGroup from '@/components/form/RadioGroup.vue';
|
|
|
import Radio from '@/components/form/Radio.vue';
|
|
|
import CommonDialog from '@/common/components/CommonDialog.vue';
|
|
|
@@ -118,14 +126,45 @@ import Touchable from '@/components/feedback/Touchable.vue';
|
|
|
import Image from '@/components/basic/Image.vue';
|
|
|
import { getCascaderItemByValue } from '@/components/form/CascaderUtils';
|
|
|
import { isValidLonLat } from '../composeabe/LonLat';
|
|
|
+import { useLoadQuerys } from '@/components/composeabe/LoadQuerys';
|
|
|
+
|
|
|
+const { querys } = useLoadQuerys({
|
|
|
+ villageName: '',
|
|
|
+ areaCode: 0,
|
|
|
+ longitude: 0,
|
|
|
+ latitude: 0,
|
|
|
+}, (query) => {
|
|
|
+ if (query.villageName && query.areaCode) {
|
|
|
+
|
|
|
+ step.value = 'inputInfo';
|
|
|
+ currentVillageName.value = query.villageName;
|
|
|
+ currentAreaCode.value = query.areaCode;
|
|
|
+ currentFromPreData.value = true;
|
|
|
+
|
|
|
+ if (!isValidLonLat(query)) {
|
|
|
+ alert({
|
|
|
+ title: '提示',
|
|
|
+ content: '您的家乡暂时没有经纬度信息,麻烦您拖动地图至您的家乡准确位置',
|
|
|
+ confirmText: '好',
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ mapCtx.moveToLocation({
|
|
|
+ longitude: Number(query.longitude),
|
|
|
+ latitude: Number(query.latitude),
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+});
|
|
|
|
|
|
const mapCtx = uni.createMapContext('prevMap');
|
|
|
|
|
|
const step = ref<'selectArea'|'inputInfo'>('selectArea');
|
|
|
-const selectedRegion = ref<RegionItem>();
|
|
|
+const currentFromPreData = ref(false);
|
|
|
const currentLonLat = ref({ longitude: 0, latitude: 0 });
|
|
|
const currentVillageName = ref('')
|
|
|
+const currentVillageDesc = ref('')
|
|
|
const currentVillageType = ref<number>(95);
|
|
|
+const currentAreaCode = ref(0);
|
|
|
|
|
|
const showSearchedList = ref(false);
|
|
|
const searchedList = ref<VillageListItem[]>([]);
|
|
|
@@ -147,6 +186,13 @@ function getReSelectAddress() {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+function handleBack() {
|
|
|
+ if (currentFromPreData.value) {
|
|
|
+ back();
|
|
|
+ } else {
|
|
|
+ step.value = 'selectArea';
|
|
|
+ }
|
|
|
+}
|
|
|
async function asyncLoadData(item: CascaderItem) {
|
|
|
const list = await RegionApi.getChildList(Number(item.value));
|
|
|
return list.map(region => ({
|
|
|
@@ -157,7 +203,6 @@ async function asyncLoadData(item: CascaderItem) {
|
|
|
}
|
|
|
async function handlePickEnd(values: CascaderItem[]) {
|
|
|
if (values.length > 0) {
|
|
|
- selectedRegion.value = values[values.length - 1].data;
|
|
|
let i = values.length - 1;
|
|
|
for (; i >= 0; i--) {
|
|
|
const lonlat = {
|
|
|
@@ -170,16 +215,16 @@ async function handlePickEnd(values: CascaderItem[]) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const areaCode = Number(selectedValue.value[selectedValue.value.length - 1]);
|
|
|
+ currentAreaCode.value = Number(selectedValue.value[selectedValue.value.length - 1]);
|
|
|
try {
|
|
|
- const mapVillages = await LightVillageApi.getMapVillage({ areaCode });
|
|
|
- const existingVillages = mapVillages.filter(v => v.village_id !== null);
|
|
|
+ const mapVillages = await LightVillageApi.getMapVillage({ areaCode: currentAreaCode.value });
|
|
|
+ const existingVillages = mapVillages.filter(v => v.villageId !== null);
|
|
|
if (existingVillages.length > 0) {
|
|
|
searchedList.value = existingVillages.map(v => ({
|
|
|
- id: v.village_id!,
|
|
|
- name: v.village_name || v.name,
|
|
|
+ id: v.villageId!,
|
|
|
+ name: v.villageName || v.name,
|
|
|
image: '',
|
|
|
- address: v.merger_name?.replace(/,/g, '') || '',
|
|
|
+ address: v.mergerName?.replace(/,/g, '') || '',
|
|
|
}) as unknown as VillageListItem);
|
|
|
showSearchedList.value = true;
|
|
|
return;
|
|
|
@@ -220,7 +265,7 @@ async function handleConfirm(skipSearch?: boolean) {
|
|
|
//先尝试搜索已有村社
|
|
|
if (!skipSearch) {
|
|
|
const searchRes = (await LightVillageApi.getVillageList({
|
|
|
- areaCode: selectedValue.value[2] as number,
|
|
|
+ areaCode: currentAreaCode.value,
|
|
|
keyword: currentVillageName.value.trim() || undefined,
|
|
|
page: 1,
|
|
|
pageSize: 10
|
|
|
@@ -236,9 +281,10 @@ async function handleConfirm(skipSearch?: boolean) {
|
|
|
//否则添加村社
|
|
|
const res = (await LightVillageApi.createVillage({
|
|
|
name: currentVillageName.value,
|
|
|
+ desc: currentVillageDesc.value,
|
|
|
longitude: String(currentLonLat.value.longitude),
|
|
|
latitude: String(currentLonLat.value.latitude),
|
|
|
- area_code: selectedValue.value[selectedValue.value.length - 1] as number,
|
|
|
+ area_code: currentAreaCode.value,
|
|
|
village_type: currentVillageType.value,
|
|
|
})).data;
|
|
|
|