ソースを参照

feat: "定位信息录入优化"

Ritchie 1 年間 前
コミット
e00b26d865
2 ファイル変更19 行追加5 行削除
  1. 8 2
      src/views/fife/index.vue
  2. 11 3
      src/views/fife/modifyLoc.vue

+ 8 - 2
src/views/fife/index.vue

@@ -19,8 +19,8 @@
                 <van-popup v-model:show="showPicker" round position="bottom">
                     <van-picker :columns="columns" @confirm="onConfirm" @cancel="showPicker = false" />
                 </van-popup>
-
-                <van-field v-model="location" name="地区名称" label="地区名称" placeholder="城市/地区名称" />
+                <van-field v-model="location" name="地区名称" label="地区名称" placeholder="省市/地区名称" :required="isRequired"
+                    :rules="[{ required: isRequired, message: '国内必须精确到省市' }]" />
             </van-cell-group>
             <div style="margin: 16px; display: flex; justify-content: center; align-items: center;">
                 <van-button round class="custom-button" type="primary" size="small" native-type="submit" block>
@@ -37,6 +37,7 @@ import sHeader from "@/components/SimpleHeader";
 import { inputLocInfo } from "../../service/fife/index";
 import { ref, onMounted } from "vue";
 import { Toast } from "vant";
+import { computed } from "vue";
 
 export default {
     components: { sHeader },
@@ -50,6 +51,7 @@ export default {
         const clientId = ref('');
         const showPicker = ref(false);
         const columns = [
+            { text: '中国', value: '中国' },
             { text: '英国', value: '英国' },
             { text: '美国', value: '美国' },
             { text: '加拿大', value: '加拿大' },
@@ -131,6 +133,9 @@ export default {
                 Toast(data.message);
             }
         }
+        const isRequired = computed(() => {
+            return country.value === '中国';
+        });
 
         return {
             onSubmit,
@@ -144,6 +149,7 @@ export default {
             location,
             username,
             phone,
+            isRequired
         };
     }
 }

+ 11 - 3
src/views/fife/modifyLoc.vue

@@ -14,13 +14,14 @@
                 <van-field v-model="clientId" name="设备唯一码" label="设备唯一码" placeholder="设备唯一码" left-icon="setting-o"
                     :rules="[{ required: true, message: '设备唯一码不能为空' }]" />
 
-                <van-field v-model="country" is-link readonly name="发往国家" label="发往国家" placeholder="发往国家" left-icon="guide-o"
-                    :rules="[{ required: true, message: '请填写发往国家' }]" @click="showPicker = true" />
+                <van-field v-model="country" is-link readonly name="发往国家" label="发往国家" placeholder="发往国家"
+                    left-icon="guide-o" :rules="[{ required: true, message: '请填写发往国家' }]" @click="showPicker = true" />
                 <van-popup v-model:show="showPicker" round position="bottom">
                     <van-picker :columns="columns" @confirm="onConfirm" @cancel="showPicker = false" />
                 </van-popup>
 
-                <van-field v-model="location" name="地区名称" label="地区名称" placeholder="城市/地区名称" left-icon="location-o"/>
+                <van-field v-model="location" name="地区名称" label="地区名称" placeholder="省市/地区名称" left-icon="location-o"
+                    :required="isRequired" :rules="[{ required: isRequired, message: '国内必须精确到省市' }]" />
             </van-cell-group>
             <div style="margin: 16px; display: flex; justify-content: center; align-items: center;">
                 <van-button round class="custom-button" type="primary" size="small" native-type="submit" block>
@@ -37,6 +38,7 @@ import sHeader from "@/components/SimpleHeader";
 import { updateLocInfo } from "../../service/fife/modifyLoc";
 import { ref } from "vue";
 import { Toast } from "vant";
+import { computed } from "vue";
 
 export default {
     components: { sHeader },
@@ -50,6 +52,7 @@ export default {
         const clientId = ref('');
         const showPicker = ref(false);
         const columns = [
+            { text: '中国', value: '中国' },
             { text: '英国', value: '英国' },
             { text: '美国', value: '美国' },
             { text: '加拿大', value: '加拿大' },
@@ -124,6 +127,10 @@ export default {
             }
         }
 
+        const isRequired = computed(() => {
+            return country.value === '中国';
+        });
+
         return {
             onSubmit,
             clientId,
@@ -136,6 +143,7 @@ export default {
             // modUsername,
             modPhone,
             location,
+            isRequired
         };
     }
 }