withdraw_detail.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // dispatcher/pages/withdraw_detail/withdraw_detail.js
  2. import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
  3. import { GetWithdrawLibraryDetail, ComfirmWithdrawLibrary } 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. baseImgUrl,
  13. isLoaded: false,
  14. league_name: '',
  15. league_address: '',
  16. count_total: '',
  17. in_book: '',
  18. out_book: '',
  19. itemIndex: 0,
  20. items: [
  21. {
  22. icon: '../../../assets/dispatch_icon_1_gray.png',
  23. actIcon: '../../../assets/dispatch_icon_1_blue.png',
  24. text: '开始撤馆'
  25. },
  26. {
  27. icon: '../../../assets/dispatch_icon_2_gray.png',
  28. actIcon: '../../../assets/dispatch_icon_2_blue.png',
  29. text: '书籍回收'
  30. },
  31. {
  32. icon: '../../../assets/dispatch_icon_3_gray.png',
  33. actIcon: '../../../assets/dispatch_icon_3_blue.png',
  34. text: '盘点归库'
  35. },
  36. ]
  37. },
  38. /**
  39. * 生命周期函数--监听页面加载
  40. */
  41. onLoad: function (options) {
  42. this.setData({ options })
  43. this.getData()
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady: function () {
  49. const obj = { navigateTo, redirectTo, navigateBack, viewImage }
  50. for (const i in obj) {
  51. this[i] = obj[i]
  52. }
  53. },
  54. /**
  55. * 生命周期函数--监听页面显示
  56. */
  57. onShow: function () {
  58. },
  59. /**
  60. * 生命周期函数--监听页面隐藏
  61. */
  62. onHide: function () {
  63. },
  64. /**
  65. * 生命周期函数--监听页面卸载
  66. */
  67. onUnload: function () {
  68. },
  69. /**
  70. * 页面相关事件处理函数--监听用户下拉动作
  71. */
  72. onPullDownRefresh: function () {
  73. },
  74. /**
  75. * 页面上拉触底事件的处理函数
  76. */
  77. onReachBottom: function () {
  78. },
  79. /**
  80. * 用户点击右上角分享
  81. */
  82. onShareAppMessage: function () {
  83. if (isFn(sharePage)) return sharePage()
  84. },
  85. /**
  86. * 获取图书馆详情
  87. */
  88. getData: function (cb) {
  89. const continuousFn = { fn: this.getData, param: { ...arguments } }
  90. const { libId } = this.data.options
  91. GetWithdrawLibraryDetail({ data: { libId }, continuousFn }).then(res => {
  92. this.setData({ ...res.data, isLoaded: true })
  93. if (isFn(cb)) cb()
  94. }).catch(res => {
  95. this.setData({ isLoaded: true })
  96. if (isFn(cb)) cb()
  97. })
  98. },
  99. /**
  100. * 确定撤馆
  101. */
  102. submitCtl: function () {
  103. const continuousFn = { fn: this.getData, param: { ...arguments } }
  104. const { libId, type } = this.data.options
  105. ComfirmWithdrawLibrary({ data: { libId }, continuousFn }).then(res => {
  106. wx.showModal({
  107. title: '确定撤馆?',
  108. content: '一旦确定撤馆将无法取消,同时该馆无完成撤销,无法选择其他馆。请谨慎选择!',
  109. success: res => {
  110. if (res.confirm) {
  111. redirectTo({ url: 'dispatcher/pages/withdraw/withdraw', paras: { libId, type }, zindex: 3 })
  112. }
  113. }
  114. })
  115. })
  116. },
  117. })