plan.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. show:1
  14. },
  15. onLoad: function (options) {
  16. this.getData()
  17. wx.request({
  18. url: host + '/api/wx/sujectitem',
  19. success: res => {
  20. this.setData({
  21. array1: res.data.data
  22. })
  23. }
  24. })
  25. },
  26. bindPickerChange:function(e){
  27. if (e.target.dataset.id == 1) {
  28. let list = this.data.array1[e.detail.value].children
  29. console.log(list)
  30. this.setData({
  31. index1: e.detail.value,
  32. array2:list,
  33. array3:[],
  34. index2:-1,
  35. index3: -1
  36. })
  37. };
  38. if (e.target.dataset.id == 2) {
  39. let list = this.data.array2[e.detail.value].children
  40. this.setData({
  41. index2: e.detail.value,
  42. array3: list,
  43. index3: -1
  44. })
  45. };
  46. if (e.target.dataset.id == 3) {
  47. this.setData({
  48. index3: e.detail.value
  49. })
  50. };
  51. // this.getData();
  52. },
  53. show:function(){
  54. this.setData({
  55. show: 1
  56. })
  57. },
  58. sure:function(){
  59. if(this.data.index1<0){
  60. wx.showToast({
  61. title: '请选择培训项目',
  62. icon: 'none',
  63. duration: 2000
  64. })
  65. }else{
  66. this.setData({
  67. show: 0
  68. })
  69. this.getData()
  70. }
  71. },
  72. getData:function(){
  73. wx.showLoading({
  74. title: '',
  75. })
  76. var parm={}
  77. if (this.data.index1>=0){
  78. parm.subject_item0 = this.data.array1[this.data.index1].name
  79. }
  80. if (this.data.index2 >= 0) {
  81. parm.subject_item1 = this.data.array2[this.data.index2].name
  82. }
  83. if (this.data.index3 >= 0) {
  84. parm.subject_item2 = this.data.array3[this.data.index3].name
  85. }
  86. wx.request({
  87. url: host+'/api/wx/class/list',
  88. method:'GET',
  89. data: parm,
  90. success:res=>{
  91. wx.hideLoading()
  92. this.setData({
  93. list:res.data.data
  94. })
  95. }
  96. })
  97. },
  98. onReady: function () {
  99. },
  100. /**
  101. * 生命周期函数--监听页面显示
  102. */
  103. onShow: function () {
  104. },
  105. /**
  106. * 生命周期函数--监听页面隐藏
  107. */
  108. onHide: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面卸载
  112. */
  113. onUnload: function () {
  114. },
  115. /**
  116. * 页面相关事件处理函数--监听用户下拉动作
  117. */
  118. onPullDownRefresh: function () {
  119. },
  120. /**
  121. * 页面上拉触底事件的处理函数
  122. */
  123. onReachBottom: function () {
  124. },
  125. /**
  126. * 用户点击右上角分享
  127. */
  128. onShareAppMessage: function () {
  129. }
  130. })