custom-input.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const processDataSet = require('../utils/processDataSet')
  2. Component({
  3. props: {
  4. value: '',
  5. type: '',
  6. password: false,
  7. placeholder: '',
  8. placeholderStyle: '',
  9. placeholderClass: '',
  10. disabled: false,
  11. maxlength: 140,
  12. focus: false,
  13. confirmType: 'done',
  14. confirmHold: false,
  15. cursor: 0,
  16. selectionStart: -1,
  17. selectionEnd: -1,
  18. name: '',
  19. onInput: () => {},
  20. onFocus: () => {},
  21. onBlur: () => {},
  22. onConfirm: () => {},
  23. onTap: () => {},
  24. catchTap: () => {},
  25. },
  26. methods: {
  27. inputHandler(e) {
  28. if (this.props.onInput) {
  29. const tapEvent = processDataSet(e, this.props)
  30. this.props.onInput(tapEvent)
  31. }
  32. },
  33. focusHandler(e) {
  34. if (this.props.onFocus) {
  35. const tapEvent = processDataSet(e, this.props)
  36. this.props.onFocus(tapEvent)
  37. }
  38. },
  39. blurHandler(e) {
  40. if (this.props.onBlur) {
  41. const tapEvent = processDataSet(e, this.props)
  42. this.props.onBlur(tapEvent)
  43. }
  44. },
  45. bindconfirmHandler(e) {
  46. if (this.props.onConfirm) {
  47. const tapEvent = processDataSet(e, this.props)
  48. this.props.onConfirm(tapEvent)
  49. }
  50. },
  51. tapHandler(e) {
  52. const tapEvent = processDataSet(e, this.props)
  53. this.props.onTap && this.props.onTap(tapEvent)
  54. },
  55. catchtapHandler(e) {
  56. const tapEvent = processDataSet(e, this.props)
  57. this.props.catchTap && this.props.catchTap(tapEvent)
  58. },
  59. },
  60. })