index.js 4.2 KB

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