plan.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // pages/plan/plan.js
  2. const app = getApp()
  3. const host = app.globalData.host;
  4. Page({
  5. data: {
  6. array1:['特种作业'],
  7. array2: [],
  8. array3: [],
  9. index1:-1,
  10. index2: -1,
  11. index3: -1,
  12. list:[]
  13. },
  14. onLoad: function (options) {
  15. this.getData()
  16. wx.request({
  17. url: host + '/api/wx/sujectitem',
  18. success: res => {
  19. this.setData({
  20. array1: res.data.data
  21. })
  22. }
  23. })
  24. },
  25. bindPickerChange:function(e){
  26. if (e.target.dataset.id == 1) {
  27. let list = this.data.array1[e.detail.value].children
  28. console.log(list)
  29. this.setData({
  30. index1: e.detail.value,
  31. array2:list,
  32. array3:[],
  33. index2:-1,
  34. index3: -1
  35. })
  36. };
  37. if (e.target.dataset.id == 2) {
  38. let list = this.data.array2[e.detail.value].children
  39. this.setData({
  40. index2: e.detail.value,
  41. array3: list,
  42. index3: -1
  43. })
  44. };
  45. if (e.target.dataset.id == 3) {
  46. this.setData({
  47. index3: e.detail.value
  48. })
  49. };
  50. this.getData();
  51. },
  52. getData:function(){
  53. var parm={}
  54. if (this.data.index1>=0){
  55. parm.subject_item0 = this.data.array1[this.data.index1].name
  56. }
  57. if (this.data.index2 >= 0) {
  58. parm.subject_item1 = this.data.array2[this.data.index2].name
  59. }
  60. if (this.data.index3 >= 0) {
  61. parm.subject_item2 = this.data.array3[this.data.index3].name
  62. }
  63. wx.request({
  64. url: host+'/api/wx/class/list',
  65. method:'GET',
  66. data: parm,
  67. success:res=>{
  68. this.setData({
  69. list:res.data.data
  70. })
  71. }
  72. })
  73. },
  74. onReady: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面显示
  78. */
  79. onShow: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面隐藏
  83. */
  84. onHide: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面卸载
  88. */
  89. onUnload: function () {
  90. },
  91. /**
  92. * 页面相关事件处理函数--监听用户下拉动作
  93. */
  94. onPullDownRefresh: function () {
  95. },
  96. /**
  97. * 页面上拉触底事件的处理函数
  98. */
  99. onReachBottom: function () {
  100. },
  101. /**
  102. * 用户点击右上角分享
  103. */
  104. onShareAppMessage: function () {
  105. }
  106. })