Commit 71fc9f37 authored by Edwise's avatar Edwise 🍷

校验emoji

parent 68b47ae8
......@@ -62,7 +62,7 @@ Component({
/**随机名字,需要根据运营数据可配置 */
randomName() {
console.log("随即名字")
let index = Math.floor(Math.random()*nameArr.length)
let index = Math.floor(Math.random() * nameArr.length)
let name = nameArr[index];
this.setData({
catNameText: name
......@@ -92,15 +92,20 @@ Component({
}
},
/**检测空格 */
isSqure(str){
isSqure(str) {
var regu = "^[ ]+$";
var re = new RegExp(regu);
return re.test(str);
},
/**检测emoji */
haveEmoji(str) {
var regRule = /\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g;
return str.match(regRule)
},
/**确认领养 */
async catNameSure() {
let name = this.props.catName;
if(this.isSqure(name)){
if (this.isSqure(name)||this.haveEmoji(name)) {
my.showToast({
content: "您输入的昵称不可用",
});
......@@ -116,7 +121,7 @@ Component({
my.showToast({
content: "您输入的昵称不可用",
});
} else if(regEn.test(name)||regCn.test(name)){
} else if (regEn.test(name) || regCn.test(name)) {
my.showToast({
content: "您输入的昵称不可用",
});
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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