|
@@ -268,6 +268,10 @@
|
|
const parts = text.split('第')[1]; // 分割并获取数字部分
|
|
const parts = text.split('第')[1]; // 分割并获取数字部分
|
|
return parts ? parseInt(parts, 10) : null; // 转换为整数
|
|
return parts ? parseInt(parts, 10) : null; // 转换为整数
|
|
},
|
|
},
|
|
|
|
+ backwardNumber(text) {
|
|
|
|
+ const parts = text.split('倒数第')[1]; // 分割并获取数字部分
|
|
|
|
+ return parts ? parseInt(parts, 10) : null; // 转换为整数
|
|
|
|
+ },
|
|
async textChange(text) {
|
|
async textChange(text) {
|
|
text = text.replaceAll(/ |,|。/ig, "");
|
|
text = text.replaceAll(/ |,|。/ig, "");
|
|
if (!text) {
|
|
if (!text) {
|
|
@@ -285,6 +289,16 @@
|
|
//全匹配轮一遍
|
|
//全匹配轮一遍
|
|
text = this.convertChineseToArabic(text);
|
|
text = this.convertChineseToArabic(text);
|
|
let houseIndex = this.extractNumber(text);//获取文字里面的数字 第三个 类似这样的
|
|
let houseIndex = this.extractNumber(text);//获取文字里面的数字 第三个 类似这样的
|
|
|
|
+ if(!houseIndex){
|
|
|
|
+ houseIndex = this.backwardNumber(text);//获取倒数的个数
|
|
|
|
+ houseIndex = this.houseList.length - houseIndex;
|
|
|
|
+ if(houseIndex < 0){//越界了
|
|
|
|
+ Toast({
|
|
|
|
+ message: '数据不合法,请再说一次',
|
|
|
|
+ });
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
// let curSpace = this.houseList.find(space => {
|
|
// let curSpace = this.houseList.find(space => {
|
|
// return text.includes(space.houseType)
|
|
// return text.includes(space.houseType)
|
|
// })
|
|
// })
|
|
@@ -310,7 +324,6 @@
|
|
houseIndex = index; //
|
|
houseIndex = index; //
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
//没有找到语音操作对象
|
|
//没有找到语音操作对象
|
|
if (!houseIndex) {
|
|
if (!houseIndex) {
|
|
Toast({
|
|
Toast({
|
|
@@ -318,6 +331,12 @@
|
|
});
|
|
});
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
+ if(houseIndex > this.houseList.length){
|
|
|
|
+ Toast({
|
|
|
|
+ message: '数据不合法,请再说一次',
|
|
|
|
+ });
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
this.changeHouse(houseIndex - 1);
|
|
this.changeHouse(houseIndex - 1);
|
|
console.log("textChange:", houseIndex);
|
|
console.log("textChange:", houseIndex);
|
|
|
|
|