import { patientUpdate } from "../patient-detail/service"; import getEncryptStr from "../../utils/getEncryptStr"; Component({ props: {}, data: { phone: "", }, didMount() {}, methods: { onInput(e) { this.setData({ phone: e.detail.value, }); }, choosePhoneContact() { my.choosePhoneContact({ success: (result) => { const { mobile } = result; this.setData({ phone: mobile.replace(/(\s|-|\+)/g, ""), }); }, }); }, async onSave() { const { query = { id: "", relationShip: "", }, } = this.$page.data; const phoneNumber = this.data.phone; if (/^[1]([3-9])[0-9]{9}$/.test(phoneNumber)) { patientUpdate({ id: query.id, // relationShip: query.relationShip, phoneNumber: await getEncryptStr(this.data.phone), }).then(() => { my.navigateBack(); }); } else { my.showToast({ type: "fail", content: "手机号错误", duration: 3000, success: () => { this.setData({ phone: "", }); }, }); } }, }, });