美化了样式
This commit is contained in:
49
pages/personCenter/component/modifyNamePop/modifyNamePop.js
Normal file
49
pages/personCenter/component/modifyNamePop/modifyNamePop.js
Normal file
@ -0,0 +1,49 @@
|
||||
Component({
|
||||
properties: {
|
||||
show: {
|
||||
type: Boolean,
|
||||
value: false
|
||||
},
|
||||
nickname: {
|
||||
type: String,
|
||||
value: ''
|
||||
}
|
||||
},
|
||||
data: {
|
||||
inputVal: ''
|
||||
},
|
||||
methods: {
|
||||
onInput(e) {
|
||||
this.setData({
|
||||
inputVal: e.detail.value
|
||||
});
|
||||
},
|
||||
onCancel() {
|
||||
this.triggerEvent('cancel');
|
||||
},
|
||||
onConfirm() {
|
||||
const newName = this.data.inputVal.trim();
|
||||
if (!newName) {
|
||||
wx.showToast({
|
||||
title: '昵称不能为空',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (newName.length > 20) {
|
||||
wx.showToast({
|
||||
title: '昵称最长不超过20个字符',
|
||||
icon: 'none'
|
||||
})
|
||||
return ;
|
||||
}
|
||||
this.triggerEvent('confirm', { nickname: newName });
|
||||
}
|
||||
},
|
||||
observers: {
|
||||
nickname(val) {
|
||||
this.setData({ inputVal: val });
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user