withdraw_library.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. // dispatcher/pages/withdraw_library/withdraw_library.js
  2. import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
  3. import { GetWithdrawLibrary } from '../../../utils/api.js'
  4. const { navigateTo, redirectTo, navigateBack } = routers()
  5. const { globalData } = getApp()
  6. const { baseImgUrl } = globalData
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. isLoaded: false,
  13. content: '',
  14. pageNo: 1,
  15. pageSize: 10,
  16. isAll: false,
  17. list: [
  18. // {
  19. // league_name: '私塾家华景新城文字文字文字文字文字文文字门店GZ100',
  20. // id: ''
  21. // },
  22. // {
  23. // league_name: '私塾家华景新城文字文字文字文字文字文文字门店GZ100',
  24. // id: ''
  25. // },
  26. // {
  27. // league_name: '私塾家华景新城文字文字文字文字文字文文字门店GZ100',
  28. // id: ''
  29. // },
  30. // {
  31. // league_name: '私塾家华景新城文字文字文字文字文字文文字门店GZ100',
  32. // id: ''
  33. // },
  34. // {
  35. // league_name: '私塾家华景新城文字文字文字文字文字文文字门店GZ100',
  36. // id: ''
  37. // },
  38. // {
  39. // league_name: '私塾家华景新城文字文字文字文字文字文文字门店GZ100',
  40. // id: ''
  41. // },
  42. ],
  43. nodataArray: {
  44. text: "搜索无结果"
  45. }
  46. },
  47. /**
  48. * 生命周期函数--监听页面加载
  49. */
  50. onLoad: function (options) {
  51. this.setData({ options })
  52. this.getData()
  53. },
  54. /**
  55. * 生命周期函数--监听页面初次渲染完成
  56. */
  57. onReady: function () {
  58. const obj = { navigateTo, redirectTo, navigateBack, viewImage }
  59. for (const i in obj) {
  60. this[i] = obj[i]
  61. }
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面隐藏
  70. */
  71. onHide: function () {
  72. },
  73. /**
  74. * 生命周期函数--监听页面卸载
  75. */
  76. onUnload: function () {
  77. },
  78. /**
  79. * 页面相关事件处理函数--监听用户下拉动作
  80. */
  81. onPullDownRefresh: function () {
  82. this.setData({ pageNo: 1 })
  83. this.getData(() => {
  84. wx.stopPullDownRefresh()
  85. })
  86. },
  87. /**
  88. * 页面上拉触底事件的处理函数
  89. */
  90. onReachBottom: function () {
  91. const { isAll } = this.data
  92. if (isAll) return
  93. this.getData()
  94. },
  95. /**
  96. * 用户点击右上角分享
  97. */
  98. onShareAppMessage: function () {
  99. if (isFn(sharePage)) return sharePage()
  100. },
  101. /**
  102. * 获取撤馆列表
  103. */
  104. getData: function (cb) {
  105. const continuousFn = { fn: this.getData, param: { ...arguments } }
  106. const { content, pageNo, pageSize, list } = this.data
  107. GetWithdrawLibrary({ data: { content, pageNo, pageSize }, continuousFn }).then(res => {
  108. const newList = res.data.list
  109. let tempList = []
  110. if (pageNo == 1) {
  111. tempList = newList
  112. } else {
  113. tempList = [...list, ...newList]
  114. }
  115. const temp = {}
  116. temp['list'] = tempList
  117. temp['pageNo'] = newList.length == pageSize ? ~~pageNo + 1 : pageNo
  118. temp['isAll'] = newList.length < pageSize
  119. temp['isLoaded'] = true
  120. this.setData(temp)
  121. if (isFn(cb)) cb()
  122. }).catch(res => {
  123. this.setData({ isLoaded: true })
  124. if (isFn(cb)) cb()
  125. })
  126. },
  127. /**
  128. * 输入搜索值
  129. */
  130. inputSearchCtl: function (e) {
  131. const { value } = e.detail
  132. const { content } = this.data
  133. if (content == value) return
  134. this.setData({ content: value })
  135. },
  136. /**
  137. * 清除搜索值
  138. */
  139. clearSearchCtl: function () {
  140. this.setData({ content: '' })
  141. },
  142. /**
  143. * 提交搜索值
  144. */
  145. submitSearchCtl: function () {
  146. this.setData({ isReturn: 1, pageNo: 1 })
  147. this.getData()
  148. },
  149. /**
  150. * 选择馆
  151. */
  152. selectLiCtl: function (e) {
  153. const { index } = e.currentTarget.dataset
  154. const { list } = this.data
  155. const { id } = list[index]
  156. if (!id) {
  157. wx.showToast({
  158. title: '当前馆没有馆ID',
  159. icon: 'none'
  160. })
  161. return
  162. }
  163. redirectTo({ url: 'dispatcher/pages/withdraw_detail/withdraw_detail', paras: { libId: id, type: 1 }, zindex: 3 })
  164. }
  165. })