apply_bookLists.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
  2. import {ApplyBookHis } from '../../../utils/api.js'
  3. const { navigateTo, redirectTo, navigateBack } = routers()
  4. const { globalData } = getApp()
  5. const { baseImgUrl, thumbnail } = globalData
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. baseImgUrl,
  12. thumbnail,
  13. isLoaded: 0,
  14. title: '',
  15. pageNo: 1,
  16. pageSize: 10,
  17. isAll: false,
  18. navIndex: 0,
  19. list: [],
  20. isAllCheck: 0,
  21. isManage: 0,
  22. totalNum: 0,
  23. isDelete: false,
  24. nodataArray: {
  25. text: "暂无数据"
  26. }
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function (options) {
  32. options.vipId = getGlobalVal('vipId', `vipId_${getGlobalVal('userId')}`) || ''
  33. options.libId = getGlobalVal('library').id || ''
  34. this.setData({ options })
  35. this.getData(res => {
  36. this.setData({ isLoaded: 1 })
  37. })
  38. },
  39. /**
  40. * 生命周期函数--监听页面初次渲染完成
  41. */
  42. onReady: function () {
  43. const obj = { navigateTo, redirectTo, navigateBack, viewImage }
  44. for (const i in obj) {
  45. this[i] = obj[i]
  46. }
  47. },
  48. /**
  49. * 生命周期函数--监听页面显示
  50. */
  51. onShow: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面隐藏
  55. */
  56. onHide: function () {
  57. },
  58. /**
  59. * 生命周期函数--监听页面卸载
  60. */
  61. onUnload: function () {
  62. },
  63. /**
  64. * 页面相关事件处理函数--监听用户下拉动作
  65. */
  66. onPullDownRefresh: function () {
  67. },
  68. /**
  69. * 页面上拉触底事件的处理函数
  70. */
  71. onReachBottom: function () {
  72. },
  73. /**
  74. * 用户点击右上角分享
  75. */
  76. onShareAppMessage: function () {
  77. if (isFn(sharePage)) return sharePage()
  78. },
  79. getData: function (cb) {
  80. const continuousFn = { fn: this.getData, param: { ...arguments } }
  81. const { libId, vipId } = this.data.options
  82. ApplyBookHis({ data: { libId, vipId }, continuousFn }).then(res => {
  83. const { list}=res.data
  84. this.setData({ list })
  85. cb && cb(res)
  86. }).catch(res => {
  87. cb && cb(res)
  88. })
  89. },
  90. })