Browse Source

Merge branch 'master' of http://face3d.4dage.com:7005/shaogen1995/YFYC-H5 into master

shaogen1995 2 years ago
parent
commit
eb59689a90

+ 2 - 2
yfyc/src/router/index.js

@@ -177,7 +177,7 @@ const routes = [{
         name: 'HotelDetail',
         meta: {
           myInd: 2,
-          myTitle: '',
+          myTitle: '酒店',
         },
         component: () => import('../views/Serve/HotelDetail.vue')
       },
@@ -228,7 +228,7 @@ const routes = [{
         name: 'my',
         meta: {
           myInd: 4,
-          myTitle: '',
+          myTitle: '我的',
         },
         component: () => import('../views/My/index.vue')
       },

+ 59 - 0
yfyc/src/utils/index.js

@@ -1,6 +1,32 @@
 import { getCodeAPI, } from "@/api/interact.js";
 
 /**
+ * 返回一个自带节流效果的函数,用res表示。
+ * 
+ * fn:需要被节流的函数
+ * interval:最短多长时间允许执行一次fn
+ * 
+ * 功能要点:
+ * 1.fn代码里如有this,res被执行时,this会指向res的调用者;
+ * 2.res被执行时的实参会映射到fn的形参;
+ * 3.第一次调用res时,会立即执行fn。
+ */
+ export function throttle(fn, interval = 250) {
+  let lastRunTime = 0
+
+  return function (...args) {
+    let elapsedTime = Date.now() - lastRunTime
+    if (elapsedTime < interval) {
+      return null
+    }
+
+    let context = this
+    lastRunTime = Date.now()
+    return fn.apply(context, args)
+  }
+}
+
+/**
  * 返回一个自带消抖效果的函数,下文用fnDebounced表示。
  *
  * fn: 需要被消抖的函数
@@ -139,10 +165,43 @@ export function dateToWeekday(dateStr = '2022-11-29') {
   return number2String[date.getDay()]
 }
 
+/* 手机号校验 */
+export function validatePhoneNumber(str) {
+  const reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/
+  return reg.test(str)
+}
+
+/* 电子邮箱校验 */
+export function validateEmail(str) {
+  const reg = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
+  return reg.test(str)
+ }
+
+ /** 身份证号校验规则
+地址码规则: 地址码长6位 以数字1-9开头 后5位为0-9的数字 根据以上规则,写出地址码的正则表达式: /^[1-9]\d{5}/
+年份码规则: 年份码长4位 以数字18,19或20,30开头 剩余两位为0-9的数字 根据以上规则,写出年份码的正则表达式: /(18|19|20|(3\d))\d{2}/。如果想扩展可以自己添加
+月份码规则: 月份码长2位 第一位数字为0,第二位数字为1-9 或者第一位数字为1,第二位数字为0-2 根据以上规则,写出月份码的正则表达式: /((0[1-9])|(1[0-2]))/。
+日期码规则: 日期码长2位 第一位数字为0-2,第二位数字为1-9 或者是10,20,30,31 根据以上规则,写出日期码的正则表达式 :/(([0-2][1-9])|10|20|30|31)/。
+顺序码规则: 顺序码长3位 顺序码是数字 根据以上规则,写出顺序码的正则表达式 :/\d{3}/。
+校验码规则: 校验码长1位 可以是数字,字母x或字母X 根据以上规则,写出校验码的正则表达式 :/[0-9Xx]/。
+综上,总体正则:/^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
+*/
+export function isValidIdCardNumber(id) {
+  if (typeof (id) !== 'string') {
+    return false
+  }
+  const reg = /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
+  return reg.test(id)
+}
+
 export default {
+  throttle,
   debounce,
   getUserCode,
   checkLoginStatus,
   loginOnNeed,
   dateToWeekday,
+  validatePhoneNumber,
+  validateEmail,
+  isValidIdCardNumber,
 }

+ 1 - 1
yfyc/src/views/MapNav.vue

@@ -31,7 +31,7 @@ export default {
           // viewMode: '3D'
         });
         const marker = new AMap.Marker({
-          position: [this.$route.query.x, this.$route.query.y], // 位置
+          position: new AMap.LngLat(this.$route.query.x, this.$route.query.y), // 位置
           label: {
             offset: new AMap.Pixel(20, 20),
             content: "点击打开高德地图",

+ 31 - 11
yfyc/src/views/My/Feedback.vue

@@ -2,10 +2,10 @@
   <div class="feedback">
     <div class="text-card card">
       <div class="title-bar bar">
-        <div class="key">主题:</div>
+        <div class="key" maxlength="20"><span class="star">*</span>&nbsp;主题:</div>
         <input v-model="title" type="text">
       </div>
-      <textarea name="" id="" rows="8" minlength="10" maxlength="150"
+      <textarea name="" id="" rows="8" maxlength="150"
         placeholder="请填写10个字以上的描述,以便我们提供更好的帮助。"
         v-model="desc"
       ></textarea>
@@ -51,8 +51,10 @@
 
 
       <div class="phone-bar bar">
-        <div class="key">联系方式</div>
-        <input v-model="contact" type="text" placeholder="手机号 / 邮箱">
+        <div class="key"><span class="star">*</span>&nbsp;</span>联系方式</div>
+        <input v-model="contact" type="text" placeholder="手机号 / 邮箱"
+          maxlength="50"
+        >
       </div>
     </div>
 
@@ -63,6 +65,7 @@
           active: canSubmit,
         }"
         @click="onSubmit"
+        :disabled="!canSubmit"
       >
         <div>提交</div>
       </button>
@@ -100,7 +103,7 @@ export default {
   },
   computed: {
     canSubmit() {
-      return this.title && this.desc && this.imgList.length && this.contact
+      return this.title && this.desc && this.contact
     },
   },
   methods: {
@@ -152,17 +155,34 @@ export default {
         },
       });
     },
-    onSubmit() {
-      Toast.success("提交成功!");
-      setTimeout(() => {
-        this.$router.go(-1)
-      }, 1500);
+    onSubmit: globalUtils.throttle(function() {
+      if(this.validateForm()) {
+        Toast.success("提交成功!");
+        setTimeout(() => {
+          this.$router.go(-1)
+        }, 1500);
+      }
+    }),
+    // 此函数不检查必填项是否为空。那个已经通过canSubmit来保证了。
+    validateForm() {
+      if (this.desc.length < 10) {
+        Toast.fail('请填写10个字以上的描述')
+        return false
+      }
+      if (!globalUtils.validatePhoneNumber(this.contact) && !globalUtils.validateEmail(this.contact)) {
+        Toast.fail('请正确填写联系方式')
+        return false
+      }
+      return true
     }
   }
 }
 </script>
 
 <style lang="less" scoped>
+.star {
+  color: red;
+}
 .feedback {
   background: #F5F5F5;
   height: calc(100% - 80px);
@@ -197,7 +217,7 @@ export default {
       .key {
         flex: 0 0 auto;
       }
-      input.text {
+      input {
         flex: 1 0 1px;
       }
     }

File diff suppressed because it is too large
+ 95 - 12
yfyc/src/views/Serve/Booking.vue


+ 1 - 1
yfyc/src/views/Serve/HotelDetail.vue

@@ -70,7 +70,7 @@
           v-show="!isExpanded"
           @click="isExpanded = true"
         >
-          收起
+          展开
         </button>
       </div>
     </div>

+ 1 - 1
yfyc/src/views/Serve/RecommendedPath.vue

@@ -170,7 +170,7 @@ export default {
         width: 69.7vw;
         padding: 2.2vw 2vw 2.7vw 2vw;
         > h3 {
-          font-size: 3.2vw;
+          font-size: 3.7vw;
           color: #333333;
           line-height: 6.4vw;
           display: -webkit-box;

+ 1 - 1
yfyc/src/views/Serve/RecommendedPathDetail.vue

@@ -65,7 +65,7 @@ export default {
     margin-bottom: 3.2vw;
     margin-left: 4.5vw;
     margin-right: 4.5vw;
-    font-size: 3.5vw;
+    font-size: 4.3vw;
     font-weight: bold;
     color: #000000;
   }

+ 3 - 3
yfyc/src/views/Serve/index.vue

@@ -314,19 +314,19 @@ activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
     border-radius: 1.1vw;
     > .entry {
       flex: 0 0 auto;
-      width: 12.2vw;
+      width: 18vw;
       height: 12.2vw;
       display: flex;
       flex-direction: column;
       justify-content: space-between;
       align-items: center;
-      font-size: 2.9vw;
+      font-size: 3.5vw;
       font-weight: bold;
       color: #535353;
       line-height: 1.1em;
       white-space: pre;
       > img {
-        width: 6.4vw;
+        width: 8vw;
         height: auto;
         margin-bottom: 2.7vw;
       }