select_teaching.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // pages/select_teaching/select_teaching.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. pageNo:1,
  9. pageSize:10,
  10. list: [],
  11. bookName:'',
  12. isAdd:true
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. console.log(options)
  19. this.setData(options)
  20. },
  21. /**
  22. * 生命周期函数--监听页面初次渲染完成
  23. */
  24. onReady: function () {
  25. },
  26. /**
  27. * 生命周期函数--监听页面显示
  28. */
  29. onShow: function () {
  30. this.getTeachingList();
  31. },
  32. /**
  33. * 生命周期函数--监听页面隐藏
  34. */
  35. onHide: function () {
  36. },
  37. /**
  38. * 生命周期函数--监听页面卸载
  39. */
  40. onUnload: function () {
  41. },
  42. /**
  43. * 页面相关事件处理函数--监听用户下拉动作
  44. */
  45. onPullDownRefresh: function () {
  46. },
  47. /**
  48. * 页面上拉触底事件的处理函数
  49. */
  50. onReachBottom: function () {
  51. },
  52. /**
  53. * 用户点击右上角分享
  54. */
  55. onShareAppMessage: function () {
  56. },
  57. /**
  58. * 跳转
  59. */
  60. navigateCtl: app.navigateCtl,
  61. /**
  62. * 底部导航跳转
  63. */
  64. redirectCtl: app.redirectCtl,
  65. /**
  66. * 查询书名
  67. */
  68. inputCtl: function (e) {
  69. const { value } = e.detail
  70. this.setData({
  71. bookName: value
  72. })
  73. this.getTeachingList()
  74. },
  75. /**
  76. * 获取教辅
  77. */
  78. getTeachingList: function () {
  79. const postData = { fn: this.getTeachingList, param: { ...arguments } }
  80. let { pageNo, pageSize, grade, subject, list = [], bookName } = this.data
  81. // let { list } = this.data.libData
  82. app.post('/api/parents/parents/V2/bookList', {
  83. grade,
  84. subject,
  85. pageSize,
  86. pageNo,
  87. bookName
  88. }, 0, postData).then(res => {
  89. if (pageNo == 1) {
  90. list = res.data.list
  91. } else {
  92. list = list.concat(res.data.list)
  93. }
  94. this.setData({
  95. list,
  96. pageNo: list.length == pageSize * pageNo ? pageNo + 1 : pageNo,
  97. isAll: list.length < pageSize
  98. })
  99. })
  100. },
  101. })