Просмотр исходного кода

🎨 按要求在提交时订阅消息

快乐的梦鱼 недель назад: 2
Родитель
Сommit
5a45441a51
3 измененных файлов с 39 добавлено и 1 удалено
  1. 1 1
      src/api/inhert/VillageApi.ts
  2. 17 0
      src/pages/components/LightMap.vue
  3. 21 0
      src/pages/home/light/submit.vue

+ 1 - 1
src/api/inhert/VillageApi.ts

@@ -237,7 +237,7 @@ export class VillageApi extends AppServerRequestModule<DataModel> {
     return transformArrayDataModel<VillageListItem>(VillageListItem, transformSomeToArray(res.data), `村落`, true);
   }
   async claimVallage(data: VillageClaimInfo) {
-    return this.post('/village/village/addVillageClaim', '认领村落', data);
+    return this.post('/village/village/addVillageClaim', '认领村落', data.toServerSide());
   }
   async getVallageList(level?: number, status?: number, region?: string) {
     const res = await this.get('/village/village/getList', '村落列表', {

+ 17 - 0
src/pages/components/LightMap.vue

@@ -121,6 +121,23 @@ const mapLoader = useSimpleDataLoader<MapMarker[]>(async () => {
     return maker as MapMarker;
   });
 
+  for (const marker of res) {
+    // 判断经纬度是否合法,不合法的输出日志
+    if (
+      typeof marker.longitude !== 'number' ||
+      typeof marker.latitude !== 'number' ||
+      isNaN(marker.longitude) ||
+      isNaN(marker.latitude) ||
+      marker.longitude < -180 ||
+      marker.longitude > 180 ||
+      marker.latitude < -90 ||
+      marker.latitude > 90
+    ) {
+      // 这里可以替换为你用的日志方式
+      console.warn(`[LightMap] villageId=${marker.id} 村名=${marker.title} 经纬度无效: longitude=${marker.longitude}, latitude=${marker.latitude}`, marker);
+    }
+  }
+
   mapCtx.addMarkers({
     clear: true,
     markers: res, 

+ 21 - 0
src/pages/home/light/submit.vue

@@ -189,6 +189,7 @@ async function registerSubmit() {
     registerFormModel.value!.villageId = querys.value.villageId;
     const loginRes = await VillageApi.shareAddVolunteer(registerFormModel.value as VolunteerInfo);
     await authStore.loginResultHandle(loginRes, UserApi.LOGIN_TYPE_USER);
+    await suscribePassMessage();
     toast({ content: '注册成功' });
     finishedMode.value = 'register';
     step.value = 'finished';
@@ -220,6 +221,7 @@ async function addSubmit() {
     addFormLoading.value = true;
     addFormModel.value.villageId = querys.value.villageId;
     await VillageApi.claimVallage(addFormModel.value as VillageClaimInfo);
+    await suscribePassMessage();
     toast({ content: '提交成功' });
     finishedMode.value = 'claim';
     step.value = 'finished';
@@ -229,4 +231,23 @@ async function addSubmit() {
     addFormLoading.value = false;
   }
 }
+
+async function suscribePassMessage() {
+  const TEMPLATE_ID = 'iNdqAKNyltLso9nFMvzrlcgCMGMALveIfZWfI2HYAQQ';
+  return new Promise<boolean>((resolve, reject) => {
+    uni.requestSubscribeMessage({
+      tmplIds: [TEMPLATE_ID],
+      success(res) {
+        if ((res as any)[TEMPLATE_ID] === 'accept')
+          resolve(true);
+        else
+          resolve(false);
+      },
+      fail(err) {
+        console.error('[suscribePassMessage] fail', err);
+        reject(err);
+      }
+    });
+  });
+}
 </script>