index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // components/autoAdd/index.js
  2. import international from '../../international/appointment_scence/index'
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. // 显示标题
  9. label: {
  10. type: String,
  11. value: '受邀人员'
  12. },
  13. //placeholder
  14. placeholder: {
  15. type: String,
  16. value: '请输入手机号'
  17. },
  18. language: {
  19. type: String,
  20. value: 'ch'
  21. },
  22. showAddBut:{
  23. type:Boolean,
  24. },
  25. closeNum:{
  26. type:false,
  27. },
  28. },
  29. /**
  30. * 组件的初始数据
  31. */
  32. data: {
  33. international: international, //国际化语言包
  34. list: [''],
  35. },
  36. /**
  37. * 组件的方法列表
  38. */
  39. methods: {
  40. // 增加一行
  41. add(e) {
  42. var {
  43. list
  44. } = this.data;
  45. list.push('');
  46. this.setData({
  47. list
  48. })
  49. },
  50. //删除一行
  51. delete(e) {
  52. var {
  53. list
  54. } = this.data;
  55. list.splice(e.currentTarget.dataset.index, 1);
  56. this.setData({
  57. list
  58. })
  59. },
  60. //获得用户输入
  61. getValue(e) {
  62. var {
  63. list
  64. } = this.data;
  65. var index = "list[" + e.currentTarget.dataset.index + "]"
  66. this.setData({
  67. [index] : e.detail.value
  68. })
  69. list = list.filter((value) => {
  70. if (value != '') {
  71. return value
  72. }
  73. });
  74. if(e.detail.value.length >= 11) {
  75. wx.hideKeyboard()
  76. }
  77. this.triggerEvent('change', Array.from(new Set(list)))
  78. },
  79. },
  80. observers: {
  81. 'showAddBut': function(showAddBut) {
  82. if(!showAddBut){
  83. this.setData({
  84. list: [''],
  85. })
  86. }
  87. },
  88. 'closeNum':function(closeNum){
  89. if(closeNum){
  90. this.setData({
  91. list: [''],
  92. })
  93. }
  94. }
  95. }
  96. })