recommand-pop.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import {getDataSet, getEventParam, isMobile, toast} from "../../../../utils/utils";
  2. import User from "../../../../model/user";
  3. Component({
  4. properties: {
  5. show: {
  6. type: Boolean,
  7. value: false
  8. },
  9. },
  10. data: {
  11. name: '',
  12. phone: '',
  13. },
  14. attached() {
  15. const user = User.getUserInfoByLocal();
  16. this.setData({
  17. name: user.name,
  18. phone: user.phone,
  19. })
  20. },
  21. methods: {
  22. close(e) {
  23. this.setData({
  24. show: false
  25. })
  26. },
  27. onChange(e) {
  28. const field = getDataSet(e, "field");
  29. this.setData({
  30. [field]: getEventParam(e)
  31. })
  32. },
  33. submit() {
  34. if (!this.data.name) {
  35. toast("姓名不能为空")
  36. return
  37. }
  38. if (!isMobile(this.data.phone)) {
  39. toast('请输入正确的手机号')
  40. return;
  41. }
  42. this.triggerEvent('submit', {
  43. name: this.data.name,
  44. phone: this.data.phone
  45. })
  46. }
  47. }
  48. });