apply_booklists.js 3.6 KB

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