apply_book.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. // parents//pages/apply_book/apply_book.js
  2. import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
  3. import { GetThemeAllBook, PostApplyBookList, ApplyBook } 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. pageNo: 1,
  17. pageSize: 10,
  18. isAll: false,
  19. navIndex: 0,
  20. list: [],
  21. isAllCheck: 0,
  22. isManage: 0,
  23. totalNum: 0,
  24. hiddenModel:false,
  25. isDelete: false,
  26. infofromstorage:[],
  27. stepList: [
  28. {
  29. number: '1',
  30. text: '填写书单申请',
  31. unit: '->'
  32. },
  33. {
  34. number: '2',
  35. text: '通过申请采购',
  36. unit: '->'
  37. },
  38. {
  39. number: '3',
  40. text: '新书到馆',
  41. unit: ''
  42. }
  43. ],
  44. },
  45. /**
  46. * 生命周期函数--监听页面加载
  47. */
  48. onLoad: function (options) {
  49. let _this = this
  50. options.vipId = getGlobalVal('vipId', `vipId_${getGlobalVal('userId')}`) || ''
  51. // options.vipId ='ea4e93ee-8b22-41bd-bb09-ec36e88eab78'
  52. options.libId = getGlobalVal('library').id || ''
  53. // wx.setNavigationBarTitle({
  54. // title: `${options.theme}`,
  55. // })
  56. this.setData({ options, isAllCheck: options.status == 1 })
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady: function () {
  62. const obj = { navigateTo, redirectTo, navigateBack, viewImage }
  63. for (const i in obj) {
  64. this[i] = obj[i]
  65. }
  66. },
  67. /**
  68. * 生命周期函数--监听页面显示
  69. */
  70. onShow: function () {
  71. let _this = this
  72. wx.getStorage({
  73. key: 'parentsList',
  74. success: function (res) {
  75. _this.setData({
  76. infofromstorage: res.data,
  77. })
  78. console.log(res)
  79. }
  80. })
  81. },
  82. /**
  83. * 生命周期函数--监听页面隐藏
  84. */
  85. onHide: function () {
  86. },
  87. /**
  88. * 生命周期函数--监听页面卸载
  89. */
  90. onUnload: function () {
  91. },
  92. /**
  93. * 页面相关事件处理函数--监听用户下拉动作
  94. */
  95. onPullDownRefresh: function () {
  96. },
  97. /**
  98. * 页面上拉触底事件的处理函数
  99. */
  100. onReachBottom: function () {
  101. },
  102. /**
  103. * 用户点击右上角分享
  104. */
  105. onShareAppMessage: function () {
  106. if (isFn(sharePage)) return sharePage()
  107. },
  108. /**
  109. * 提示框隐藏
  110. */
  111. allShowModel: function () {
  112. this.setData({ hiddenModel: false})
  113. },
  114. /**
  115. * 提示框打开
  116. */
  117. showModel: function () {
  118. this.setData({ hiddenModel: true })
  119. },
  120. /**
  121. * 确认调入
  122. */
  123. getCallin: function () {
  124. const continuousFn = { fn: this.getCallin, param: { ...arguments } }
  125. const { infofromstorage=[], options } = this.data
  126. if (infofromstorage.length==0)return
  127. const { vipId, libId} = options
  128. ApplyBook({ data: { libId, vipId, detailList: infofromstorage }, continuousFn }).then(res => {
  129. wx.removeStorageSync('parentsList')
  130. this.setData({
  131. infofromstorage: [],
  132. })
  133. wx.showToast({
  134. title: `已加入调入列表`
  135. })
  136. })
  137. },
  138. /**
  139. * 管理
  140. */
  141. cancelCallin: function () {
  142. const { isDelete, infofromstorage = [] } = this.data
  143. if (infofromstorage.length == 0) return
  144. this.setData({ isDelete: !isDelete })
  145. },
  146. /**
  147. * 删除
  148. */
  149. deleteBtn: function (e) {
  150. const { index } = e.currentTarget.dataset
  151. const { infofromstorage } = this.data
  152. infofromstorage.splice(index, 1)
  153. this.setData({ infofromstorage })
  154. wx.setStorageSync('parentsList', infofromstorage)
  155. },
  156. /**
  157. * 提交搜索值
  158. */
  159. submitSearchCtl: function () {
  160. const temp = {}
  161. temp[`pageNo`] = 1
  162. this.setData(temp)
  163. this.getData()
  164. },
  165. })