plan.js 2.6 KB

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