import {getDataSet, getEventParam, isMobile, toast} from "../../../../utils/utils"; import User from "../../../../model/user"; Component({ properties: { show: { type: Boolean, value: false }, }, data: { name: '', phone: '', }, attached() { const user = User.getUserInfoByLocal(); this.setData({ name: user.name, phone: user.phone, }) }, methods: { close(e) { this.setData({ show: false }) }, onChange(e) { const field = getDataSet(e, "field"); this.setData({ [field]: getEventParam(e) }) }, submit() { if (!this.data.name) { toast("姓名不能为空") return } if (!isMobile(this.data.phone)) { toast('请输入正确的手机号') return; } this.triggerEvent('submit', { name: this.data.name, phone: this.data.phone }) } } });