index.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. Page({
  2. data: {
  3. array: ['美国', '中国', '巴西', '日本'],
  4. objectArray: [
  5. {
  6. id: 0,
  7. name: '美国'
  8. },
  9. {
  10. id: 1,
  11. name: '中国'
  12. },
  13. {
  14. id: 2,
  15. name: '巴西'
  16. },
  17. {
  18. id: 3,
  19. name: '日本'
  20. }
  21. ],
  22. index: 0,
  23. multiArray: [['无脊柱动物', '脊柱动物'], ['扁性动物', '线形动物', '环节动物', '软体动物', '节肢动物'], ['猪肉绦虫', '吸血虫']],
  24. objectMultiArray: [
  25. [
  26. {
  27. id: 0,
  28. name: '无脊柱动物'
  29. },
  30. {
  31. id: 1,
  32. name: '脊柱动物'
  33. }
  34. ], [
  35. {
  36. id: 0,
  37. name: '扁性动物'
  38. },
  39. {
  40. id: 1,
  41. name: '线形动物'
  42. },
  43. {
  44. id: 2,
  45. name: '环节动物'
  46. },
  47. {
  48. id: 3,
  49. name: '软体动物'
  50. },
  51. {
  52. id: 3,
  53. name: '节肢动物'
  54. }
  55. ], [
  56. {
  57. id: 0,
  58. name: '猪肉绦虫'
  59. },
  60. {
  61. id: 1,
  62. name: '吸血虫'
  63. }
  64. ]
  65. ],
  66. multiIndex: [0, 0, 0],
  67. date: '2016-09-01',
  68. time: '12:01',
  69. region: ['广东省', '广州市', '海珠区'],
  70. customItem: '全部'
  71. },
  72. bindPickerChange: function (e) {
  73. console.log('picker发送选择改变,携带值为', e.detail.value)
  74. this.setData({
  75. index: e.detail.value
  76. })
  77. },
  78. bindMultiPickerChange: function (e) {
  79. console.log('picker发送选择改变,携带值为', e.detail.value)
  80. this.setData({
  81. multiIndex: e.detail.value
  82. })
  83. },
  84. bindMultiPickerColumnChange: function (e) {
  85. console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
  86. var data = {
  87. multiArray: this.data.multiArray,
  88. multiIndex: this.data.multiIndex
  89. };
  90. data.multiIndex[e.detail.column] = e.detail.value;
  91. switch (e.detail.column) {
  92. case 0:
  93. switch (data.multiIndex[0]) {
  94. case 0:
  95. data.multiArray[1] = ['扁性动物', '线形动物', '环节动物', '软体动物', '节肢动物'];
  96. data.multiArray[2] = ['猪肉绦虫', '吸血虫'];
  97. break;
  98. case 1:
  99. data.multiArray[1] = ['鱼', '两栖动物', '爬行动物'];
  100. data.multiArray[2] = ['鲫鱼', '带鱼'];
  101. break;
  102. }
  103. data.multiIndex[1] = 0;
  104. data.multiIndex[2] = 0;
  105. break;
  106. case 1:
  107. switch (data.multiIndex[0]) {
  108. case 0:
  109. switch (data.multiIndex[1]) {
  110. case 0:
  111. data.multiArray[2] = ['猪肉绦虫', '吸血虫'];
  112. break;
  113. case 1:
  114. data.multiArray[2] = ['蛔虫'];
  115. break;
  116. case 2:
  117. data.multiArray[2] = ['蚂蚁', '蚂蟥'];
  118. break;
  119. case 3:
  120. data.multiArray[2] = ['河蚌', '蜗牛', '蛞蝓'];
  121. break;
  122. case 4:
  123. data.multiArray[2] = ['昆虫', '甲壳动物', '蛛形动物', '多足动物'];
  124. break;
  125. }
  126. break;
  127. case 1:
  128. switch (data.multiIndex[1]) {
  129. case 0:
  130. data.multiArray[2] = ['鲫鱼', '带鱼'];
  131. break;
  132. case 1:
  133. data.multiArray[2] = ['青蛙', '娃娃鱼'];
  134. break;
  135. case 2:
  136. data.multiArray[2] = ['蜥蜴', '龟', '壁虎'];
  137. break;
  138. }
  139. break;
  140. }
  141. data.multiIndex[2] = 0;
  142. console.log(data.multiIndex);
  143. break;
  144. }
  145. this.setData(data);
  146. },
  147. bindDateChange: function (e) {
  148. console.log('picker发送选择改变,携带值为', e.detail.value)
  149. this.setData({
  150. date: e.detail.value
  151. })
  152. },
  153. bindTimeChange: function (e) {
  154. console.log('picker发送选择改变,携带值为', e.detail.value)
  155. this.setData({
  156. time: e.detail.value
  157. })
  158. },
  159. bindRegionChange: function (e) {
  160. console.log('picker发送选择改变,携带值为', e.detail.value)
  161. this.setData({
  162. region: e.detail.value
  163. })
  164. }
  165. })