index.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. choosePhoneContact() {
  17. my.choosePhoneContact({
  18. success: ({ mobile }) => {
  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. EventHub.dispatchEvent("onPatienDetailUpdate", true);
  40. my.navigateBack();
  41. });
  42. } else {
  43. my.showToast({
  44. type: "fail",
  45. content: "手机号错误",
  46. duration: 3000,
  47. success: () => {
  48. this.setData({
  49. phone: "",
  50. });
  51. },
  52. });
  53. }
  54. },
  55. },
  56. });