plan.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. wx.showLoading({
  54. title: '',
  55. })
  56. var parm={}
  57. if (this.data.index1>=0){
  58. parm.subject_item0 = this.data.array1[this.data.index1].name
  59. }
  60. if (this.data.index2 >= 0) {
  61. parm.subject_item1 = this.data.array2[this.data.index2].name
  62. }
  63. if (this.data.index3 >= 0) {
  64. parm.subject_item2 = this.data.array3[this.data.index3].name
  65. }
  66. wx.request({
  67. url: host+'/api/wx/class/list',
  68. method:'GET',
  69. data: parm,
  70. success:res=>{
  71. wx.hideLoading()
  72. this.setData({
  73. list:res.data.data
  74. })
  75. }
  76. })
  77. },
  78. onReady: function () {
  79. },
  80. /**
  81. * 生命周期函数--监听页面显示
  82. */
  83. onShow: function () {
  84. },
  85. /**
  86. * 生命周期函数--监听页面隐藏
  87. */
  88. onHide: function () {
  89. },
  90. /**
  91. * 生命周期函数--监听页面卸载
  92. */
  93. onUnload: function () {
  94. },
  95. /**
  96. * 页面相关事件处理函数--监听用户下拉动作
  97. */
  98. onPullDownRefresh: function () {
  99. },
  100. /**
  101. * 页面上拉触底事件的处理函数
  102. */
  103. onReachBottom: function () {
  104. },
  105. /**
  106. * 用户点击右上角分享
  107. */
  108. onShareAppMessage: function () {
  109. }
  110. })