index.js 986 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { patientUpdate } from "../patient-detail/service";
  2. import getEncryptStr from "../../utils/getEncryptStr";
  3. import EventHub from "../../../abMall/utils/eventEmitter";
  4. Component({
  5. props: {},
  6. data: {
  7. phone: "",
  8. },
  9. didMount() {},
  10. methods: {
  11. onInput(e) {
  12. this.setData({
  13. phone: e.detail.value,
  14. });
  15. },
  16. async onSave() {
  17. const {
  18. query = {
  19. id: "", relationShip: "",
  20. },
  21. } = this.$page.data;
  22. const phoneNumber = this.data.phone;
  23. if (/^[1]([3-9])[0-9]{9}$/.test(phoneNumber)) {
  24. patientUpdate({
  25. id: query.id,
  26. // relationShip: query.relationShip,
  27. phoneNumber: await getEncryptStr(this.data.phone),
  28. }).then(() => {
  29. EventHub.dispatchEvent("onPatienDetailUpdate", true);
  30. my.navigateBack();
  31. });
  32. } else {
  33. my.showToast({
  34. type: "fail",
  35. content: "手机号错误",
  36. duration: 3000,
  37. success: () => {
  38. this.setData({
  39. phone: "",
  40. });
  41. },
  42. });
  43. }
  44. },
  45. },
  46. });