index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. const _my = require("../../__antmove/api/index.js")(my);
  2. const wx = _my; // components/input/index.js
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. properties: {
  8. value: "",
  9. type: {
  10. type: String,
  11. value: ""
  12. },
  13. // 数组
  14. itemData: {
  15. type: Object,
  16. value: function () {
  17. return {};
  18. }
  19. },
  20. isDisable: {
  21. type: Boolean,
  22. value: true
  23. },
  24. // 空调
  25. aircondition: {
  26. type: Boolean,
  27. value: false
  28. },
  29. // 投影
  30. projection: {
  31. type: Boolean,
  32. value: false
  33. },
  34. // 左侧数组
  35. leftList: {
  36. type: Array,
  37. value: function () {
  38. return [];
  39. }
  40. },
  41. // 右侧数组
  42. rightList: {
  43. type: Array,
  44. value: function () {
  45. return [];
  46. }
  47. }
  48. },
  49. /**
  50. * 组件的初始数据
  51. */
  52. data: {},
  53. lifetimes: {
  54. attached: function () { },
  55. detached: function () {// 在组件实例被从页面节点树移除时执行
  56. }
  57. },
  58. /**
  59. * 组件的方法列表
  60. */
  61. methods: {
  62. getWater(e) {
  63. console.log(e);
  64. if (!this.data.isDisable) {
  65. this.triggerEvent("teaWater", e);
  66. }
  67. },
  68. cleaeTea(e) {
  69. console.log(e);
  70. this.triggerEvent('cleaeTea', e)
  71. },
  72. getSnack(e) {
  73. if (!this.data.isDisable) {
  74. this.triggerEvent("snack", e);
  75. }
  76. },
  77. getMonogram(e) {
  78. let dataset = e.currentTarget.dataset;
  79. let { leftList, rightList } = this.data
  80. // console.log(e, 1);
  81. if (!this.data.isDisable) {
  82. var that = this;
  83. my.prompt({
  84. title: "桌签内容",
  85. inputValue: dataset.type === 'left' ? leftList[dataset.index].monogram : rightList[dataset.index].monogram,
  86. placeholder: '请输入桌签内容',
  87. // showCancel: true,
  88. // editable: true,
  89. message: " ",
  90. okButtonText: '确定',
  91. cancelButtonText: '取消',
  92. success: function (res) {
  93. console.log(res, 2);
  94. dataset.val = res.inputValue;
  95. // console.log(dataset, 4);
  96. // console.log(dataset.val, 3);
  97. if (res.ok) {
  98. that.triggerEvent("monogram", dataset);
  99. } else if (res.cancel) { }
  100. }
  101. });
  102. }
  103. },
  104. largeScreenFun(e) {
  105. // console.log(e);
  106. if (!this.data.isDisable) {
  107. let index = e.currentTarget.dataset.index;
  108. switch (e.currentTarget.dataset.type) {
  109. case "1":
  110. this.triggerEvent("change", "projection");
  111. break;
  112. case "2":
  113. this.triggerEvent("change", "aircondition");
  114. break;
  115. case "3":
  116. this.setData({
  117. [`list[${index}].isTable`]: !this.data.list[index].isTable
  118. });
  119. break;
  120. case "4":
  121. this.setData({
  122. [`list[${index}].isWater`]: !this.data.list[index].isWater
  123. });
  124. break;
  125. case "5":
  126. this.setData({
  127. [`list[${index}].isDessert`]: !this.data.list[index].isDessert
  128. });
  129. break;
  130. case "6":
  131. this.setData({
  132. [`list1[${index}].isTable`]: !this.data.list1[index].isTable
  133. });
  134. break;
  135. case "7":
  136. this.setData({
  137. [`list1[${index}].isWater`]: !this.data.list1[index].isWater
  138. });
  139. break;
  140. case "8":
  141. this.setData({
  142. [`list1[${index}].isDessert`]: !this.data.list1[index].isDessert
  143. });
  144. break;
  145. default:
  146. break;
  147. }
  148. }
  149. },
  150. antmoveAction: function () {
  151. //执行时动态赋值,请勿删除
  152. }
  153. }
  154. });