book_Imformation.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // president/pages/home/home.js
  2. import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
  3. import { BookDetailView, CallInBooks} from '../../../utils/api.js'
  4. const { navigateTo, redirectTo, navigateBack } = routers()
  5. const { globalData } = getApp()
  6. const { baseImgUrl, thumbnail } = globalData
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. baseImgUrl,
  13. thumbnail,
  14. isLoaded: 0,
  15. title: '',
  16. pageSize: 10,
  17. pageNo: 1,
  18. isAll: 0,
  19. isFold:0,
  20. isResult: false,
  21. bookInfoId:'',
  22. isShow: 0,
  23. itemIndex: 0,
  24. footerData: {
  25. actIndex: 0,
  26. list: [
  27. {
  28. text: '在馆书籍',
  29. icon: '../../../assets/zai_guan_shu_ji_gray.png',
  30. actIcon: '../../../assets/zai_guan_shu_ji_blue.png',
  31. url: 'president/pages/home/home',
  32. zindex: 3
  33. },
  34. {
  35. text: '好书推荐',
  36. icon: '../../../assets/wish_gray.png',
  37. actIcon: '../../../assets/wish_blue.png',
  38. url: 'president/pages/good_books_new/good_books_new',
  39. zindex: 3
  40. },
  41. {
  42. text: '调书清单',
  43. icon: '../../../assets/diao_shu_qing_dan_gray.png',
  44. actIcon: '../../../assets/diao_shu_qing_dan_blue.png',
  45. url: 'president/pages/book_inventory/book_inventory',
  46. zindex: 3
  47. }
  48. ]
  49. },
  50. nodataArray: {
  51. text: "暂时还没有这本书,可以申请哦~"
  52. }
  53. },
  54. /**
  55. * 生命周期函数--监听页面加载
  56. */
  57. onLoad: function (options) {
  58. options.vipId = getGlobalVal('vipId', `vipId_${getGlobalVal('userId')}`)
  59. options.libId = getGlobalVal('list').length > 0 ? getGlobalVal('list')[0].libId : ''
  60. this.setData(options)
  61. },
  62. /**
  63. * 生命周期函数--监听页面初次渲染完成
  64. */
  65. onReady: function () {
  66. const obj = { navigateTo, redirectTo, navigateBack, viewImage }
  67. for (const i in obj) {
  68. this[i] = obj[i]
  69. }
  70. },
  71. /**
  72. * 生命周期函数--监听页面显示
  73. */
  74. onShow: function () {
  75. this.getData()
  76. },
  77. /**
  78. * 生命周期函数--监听页面隐藏
  79. */
  80. onHide: function () {
  81. },
  82. /**
  83. * 生命周期函数--监听页面卸载
  84. */
  85. onUnload: function () {
  86. },
  87. /**
  88. * 页面相关事件处理函数--监听用户下拉动作
  89. */
  90. onPullDownRefresh: function () {
  91. },
  92. /**
  93. * 页面上拉触底事件的处理函数
  94. */
  95. onReachBottom: function () {
  96. },
  97. /**
  98. * 用户点击右上角分享
  99. */
  100. onShareAppMessage: function () {
  101. if (isFn(sharePage)) return sharePage()
  102. },
  103. /**
  104. * 获取书籍数据
  105. */
  106. getData: function (cb) {
  107. const continuousFn = { fn: this.getData, param: { ...arguments } }
  108. const { bookInfoId } = this.data
  109. BookDetailView({ data: { bookInfoId }, continuousFn }).then(res => {
  110. const { author, bookImg, bookInfoId, grade, heat, isbn13, summary, theme, title, sameList } = res.data
  111. this.setData({ author, bookImg, bookInfoId, grade, heat, isbn13, summary, theme, title, sameList, isLoaded:true})
  112. cb && cb(res)
  113. }).catch(res => {
  114. cb && cb(res)
  115. })
  116. },
  117. /**
  118. * 调入
  119. */
  120. addFold: function () {
  121. const { isbn13, libId, bookInfoId} = this.data
  122. const continuousFn = { fn: this.addFold, param: { ...arguments } }
  123. CallInBooks({ data: { libId, bookInfoId, isbn13 }, continuousFn }).then(res => {
  124. wx.showToast({
  125. title: `已加入调入清单`,
  126. icon: 'none',
  127. duration:2000
  128. })
  129. wx.navigateBack({
  130. delta: 1,
  131. })
  132. })
  133. },
  134. })