Commit 71fc9f37 authored by Edwise's avatar Edwise 🍷

校验emoji

parent 68b47ae8
...@@ -62,7 +62,7 @@ Component({ ...@@ -62,7 +62,7 @@ Component({
/**随机名字,需要根据运营数据可配置 */ /**随机名字,需要根据运营数据可配置 */
randomName() { randomName() {
console.log("随即名字") console.log("随即名字")
let index = Math.floor(Math.random()*nameArr.length) let index = Math.floor(Math.random() * nameArr.length)
let name = nameArr[index]; let name = nameArr[index];
this.setData({ this.setData({
catNameText: name catNameText: name
...@@ -92,15 +92,20 @@ Component({ ...@@ -92,15 +92,20 @@ Component({
} }
}, },
/**检测空格 */ /**检测空格 */
isSqure(str){ isSqure(str) {
var regu = "^[ ]+$"; var regu = "^[ ]+$";
var re = new RegExp(regu); var re = new RegExp(regu);
return re.test(str); return re.test(str);
}, },
/**检测emoji */
haveEmoji(str) {
var regRule = /\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g;
return str.match(regRule)
},
/**确认领养 */ /**确认领养 */
async catNameSure() { async catNameSure() {
let name = this.props.catName; let name = this.props.catName;
if(this.isSqure(name)){ if (this.isSqure(name)||this.haveEmoji(name)) {
my.showToast({ my.showToast({
content: "您输入的昵称不可用", content: "您输入的昵称不可用",
}); });
...@@ -116,7 +121,7 @@ Component({ ...@@ -116,7 +121,7 @@ Component({
my.showToast({ my.showToast({
content: "您输入的昵称不可用", content: "您输入的昵称不可用",
}); });
} else if(regEn.test(name)||regCn.test(name)){ } else if (regEn.test(name) || regCn.test(name)) {
my.showToast({ my.showToast({
content: "您输入的昵称不可用", content: "您输入的昵称不可用",
}); });
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment