index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. const _my = require("../../__antmove/api/index.js")(my);
  2. const wx = _my; // components/input/index.js
  3. const upload_image = require("../../utils/upload/upload_image");
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. value: "",
  10. // 标题
  11. title: {
  12. type: String,
  13. value: ""
  14. },
  15. // 注释
  16. placeholder: {
  17. type: String,
  18. value: "请输入"
  19. },
  20. // 类型
  21. type: {
  22. type: String,
  23. value: "text"
  24. },
  25. // input类型
  26. inputType: {
  27. type: String,
  28. value: "text"
  29. },
  30. // 是否必填
  31. isRequired: {
  32. type: Boolean,
  33. value: false
  34. },
  35. // 是否禁用
  36. disabled: {
  37. type: Boolean,
  38. value: false
  39. },
  40. maxLength: {
  41. type: Number,
  42. value: 200
  43. },
  44. // 遍历数组
  45. listErgodic: {
  46. type: Array,
  47. value: function () {
  48. return [];
  49. }
  50. },
  51. // key
  52. key1: {
  53. type: String,
  54. value: ""
  55. },
  56. // name
  57. name1: {
  58. type: String,
  59. value: ""
  60. },
  61. // 计数器最大值
  62. stepperMax: {
  63. type: Number,
  64. value: 10000000
  65. },
  66. // 日期-开始
  67. startDate: {
  68. type: String,
  69. value: ""
  70. },
  71. // 日期-结束
  72. endDate: {
  73. type: String,
  74. value: ""
  75. },
  76. // 时间-开始
  77. startTime: {
  78. type: String,
  79. value: ""
  80. },
  81. // 时间-结束
  82. endTime: {
  83. type: String,
  84. value: ""
  85. }
  86. },
  87. /**
  88. * 组件的初始数据
  89. */
  90. lifetimes: {
  91. attached: function () { },
  92. detached: function () {// 在组件实例被从页面节点树移除时执行
  93. }
  94. },
  95. /**
  96. * 组件的方法列表
  97. */
  98. methods: {
  99. getValue(e) {
  100. // console.log('getvslue', e);
  101. // console.log(e.currentTarget.dataset.type, 77777);
  102. // console.log(e.detail);
  103. let val = ''
  104. switch (e.currentTarget.dataset.type) {
  105. case 'radio':
  106. val = e.currentTarget.dataset.item.id
  107. this.setData({
  108. value: e.currentTarget.dataset.item.id
  109. })
  110. break;
  111. case 'stepper':
  112. val = e.detail
  113. this.setData({
  114. value: e.detail
  115. })
  116. break;
  117. default:
  118. // val = e.detail.value
  119. val = e.detail.value
  120. this.setData({
  121. value: e.detail.value
  122. })
  123. break;
  124. }
  125. this.triggerEvent('change', val)
  126. },
  127. //选择照片
  128. ChooseImage(e) {
  129. let that = this;
  130. wx.chooseImage({
  131. count: 1,
  132. mediaType: ["image"],
  133. sourceType: ["album", "camera"],
  134. success(res) {
  135. var image = {
  136. url: res.tempFiles[0]
  137. };
  138. wx.showLoading({
  139. title: "上传中~"
  140. });
  141. console.log(image);
  142. upload_image(image).then(img => {
  143. wx.hideLoading();
  144. that.triggerEvent("change", img.url);
  145. }).catch(() => {
  146. wx.hideLoading();
  147. });
  148. }
  149. });
  150. },
  151. // 删除照片
  152. clearImg(e) {
  153. this.triggerEvent("clearImg", true);
  154. },
  155. antmoveAction: function () {
  156. //执行时动态赋值,请勿删除
  157. }
  158. }
  159. });