zjs_project 10 hónapja
szülő
commit
9b39e5e2a3

+ 14 - 10
src/pages/webgl_rxdz_recognizer_houseList/webgl_rxdz_recognizer_houseList.vue

@@ -232,15 +232,15 @@
             //求最长公共子集
             findSubStr(str1, str2) {
                 if (str1.length > str2.length) {
-                    var temp = str1;
+                    let temp = str1;
                     str1 = str2;
                     str2 = temp;
                 }
                 let len1 = str1.length;
                 let len2 = str2.length;
-                for (var j = len1; j > 0; j--) {
-                    for (var i = 0; i < len1 - j; i++) {
-                        var current = str1.substr(i, j);
+                for (let j = len1; j > 0; j--) {
+                    for (let i = 0; i <= len1 - j; i++) {
+                        let current = str1.substr(i, j);
                         if (str2.indexOf(current) >= 0) {
                             return current;
                         }
@@ -266,7 +266,7 @@
             },
             extractNumber(text) {  
                 const parts = text.split('第')[1]; // 分割并获取数字部分  
-                return parts ? parseInt(parts, 10) : null; // 转换为整数  
+                return parts ? (parseInt(parts, 10) - 1) : null; // 转换为整数  
             },
             backwardNumber(text) {
                 const parts = text.split('倒数第')[1]; // 分割并获取数字部分  
@@ -304,20 +304,24 @@
                 }                
 
                 if (!houseIndex) {
+                    //全匹配轮一遍
+                    // let curSpace = this.houseList.find(space => {
+                    //     return text.includes(space.namePY)
+                    // })
                     let list = this.houseList.map((space, index) => {
-                        let comStr = this.findSubStr(text, space.houseType + ' ' + space.houseArea + "㎡ " +
-                            space.note);
+                        let comStr = this.findSubStr(text, space.houseType + ' ' + space.houseArea + "㎡ " + space.note);
                         return {
                             spaceId: space.spaceId,
                             namePY: space.namePY,
                             name: space.name,
+                            str:space.houseType + ' ' + space.houseArea + "㎡ " + space.note,
                             comStr,
                             index,
                         }
                     })
                     //寻找5个字符串以上的
                     let tmpList = list.filter(it => {
-                        return it.comStr.length > 5;
+                        return it.comStr.length > 2;
                     })
                     if (tmpList && tmpList.length > 0) {
                         tmpList.sort((a, b) => a.comStr.length - b.comStr.length);
@@ -326,7 +330,7 @@
                     }
                 }
                 //没有找到语音操作对象
-                if (!houseIndex) {
+                if (houseIndex==null || houseIndex<0) {
                     Toast({
                         message: '请再说一次',
                     });
@@ -338,7 +342,7 @@
                     });
                    return false; 
                 }
-                this.changeHouse(houseIndex - 1);
+                this.changeHouse(houseIndex);
                 console.log("textChange:", houseIndex);