Browse Source

昵称敏感词校验

master
kola-web 2 months ago
parent
commit
ce94752aea
  1. 13
      src/pages/userInfo/index.ts
  2. 2
      src/pages/userInfo/index.wxml

13
src/pages/userInfo/index.ts

@ -2,6 +2,7 @@ const app = getApp<IAppOption>(); @@ -2,6 +2,7 @@ const app = getApp<IAppOption>();
Page({
data: {
username: '',
userInfo: {} as any,
},
onLoad() {
@ -17,11 +18,17 @@ Page({ @@ -17,11 +18,17 @@ Page({
this.updateUserInfo();
},
handleInputBlur(e) {
const { key } = e.currentTarget.dataset;
this.setData({
[`userInfo.${key}`]: e.detail.value,
username: e.detail.value,
});
this.updateUserInfo();
},
handleInputBlurPass(e) {
if (e.detail.pass) {
this.setData({
[`userInfo.username`]: this.data.username,
});
this.updateUserInfo();
}
},
updateUserInfo() {
const { avatar, username } = this.data.userInfo;

2
src/pages/userInfo/index.wxml

@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
<view class="row small">
<view class="label">头像</view>
<view class="wrap">
<uploadFile
class="avatar"
chooseAvatar
@ -35,6 +34,7 @@ @@ -35,6 +34,7 @@
placeholder="请输入昵称"
data-key="username"
bindblur="handleInputBlur"
bindnicknamereview="handleInputBlurPass"
></input>
</view>
</view>

Loading…
Cancel
Save