index.js 930 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. async onSave() {
  16. const {
  17. query = {
  18. id: ''
  19. }
  20. } = this.$page.data;
  21. const phoneNumber = this.data.phone;
  22. if (/^[1]([3-9])[0-9]{9}$/.test(phoneNumber)) {
  23. patientUpdate({
  24. id: query.id,
  25. phoneNumber: await getEncryptStr(this.data.phone)
  26. }).then(() => {
  27. my.navigateBack();
  28. });
  29. } else {
  30. my.showToast({
  31. type: 'fail',
  32. content: '手机号错误',
  33. duration: 3000,
  34. success: () => {
  35. this.setData({
  36. phone: ''
  37. });
  38. }
  39. });
  40. }
  41. }
  42. }
  43. });