plan.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. wx.showLoading({
  16. title: '',
  17. })
  18. this.getData()
  19. wx.request({
  20. url: host + '/api/wx/sujectitem',
  21. success: res => {
  22. this.setData({
  23. array1: res.data.data
  24. })
  25. }
  26. })
  27. },
  28. bindPickerChange:function(e){
  29. if (e.target.dataset.id == 1) {
  30. let list = this.data.array1[e.detail.value].children
  31. console.log(list)
  32. this.setData({
  33. index1: e.detail.value,
  34. array2:list,
  35. array3:[],
  36. index2:-1,
  37. index3: -1
  38. })
  39. };
  40. if (e.target.dataset.id == 2) {
  41. let list = this.data.array2[e.detail.value].children
  42. this.setData({
  43. index2: e.detail.value,
  44. array3: list,
  45. index3: -1
  46. })
  47. };
  48. if (e.target.dataset.id == 3) {
  49. this.setData({
  50. index3: e.detail.value
  51. })
  52. };
  53. this.getData();
  54. },
  55. getData:function(){
  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. })