index.js 1.0 KB

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