me.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. // dispatcher/pages/me/me.js
  2. import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
  3. import { GetDispatcherInfo } 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: 0,
  14. routerTwo: [
  15. {
  16. icon: '../../../assets/che_guan.png',
  17. text: '撤馆流程',
  18. time: '',
  19. url: '',
  20. paras: {},
  21. zindex: 3
  22. }
  23. ],
  24. routerThree: [
  25. {
  26. icon: '../../../assets/wen_ti.png',
  27. text: '常见问题',
  28. time: '',
  29. url: 'pages/question/question',
  30. paras: {
  31. type: 2
  32. },
  33. zindex: 3
  34. }
  35. ],
  36. footerData: {
  37. actIndex: 2,
  38. list: [
  39. {
  40. text: '送书到馆',
  41. icon: '../../../assets/song_shu_dao_guan_gray.png',
  42. actIcon: '../../../assets/song_shu_dao_guan_blue.png',
  43. url: 'dispatcher/pages/dispatch_go/dispatch_go',
  44. zindex: 3
  45. },
  46. {
  47. text: '带书离馆',
  48. icon: '../../../assets/dai_shu_li_guan_gray.png',
  49. actIcon: '../../../assets/dai_shu_li_guan_blue.png',
  50. url: 'dispatcher/pages/dispatch_leave/dispatch_leave',
  51. zindex: 3
  52. },
  53. {
  54. text: '我的',
  55. icon: '../../../assets/me_gray.png',
  56. actIcon: '../../../assets/me_blue.png',
  57. url: 'dispatcher/pages/me/me',
  58. zindex: 3
  59. }
  60. ]
  61. }
  62. },
  63. /**
  64. * 生命周期函数--监听页面加载
  65. */
  66. onLoad: function (options) {
  67. options.userInfo = getGlobalVal('userInfo')
  68. this.setData({ options, isLoaded: 1 })
  69. },
  70. /**
  71. * 生命周期函数--监听页面初次渲染完成
  72. */
  73. onReady: function () {
  74. const obj = { navigateTo, redirectTo, navigateBack, viewImage }
  75. for (const i in obj) {
  76. this[i] = obj[i]
  77. }
  78. },
  79. /**
  80. * 生命周期函数--监听页面显示
  81. */
  82. onShow: function () {
  83. },
  84. /**
  85. * 生命周期函数--监听页面隐藏
  86. */
  87. onHide: function () {
  88. },
  89. /**
  90. * 生命周期函数--监听页面卸载
  91. */
  92. onUnload: function () {
  93. },
  94. /**
  95. * 页面相关事件处理函数--监听用户下拉动作
  96. */
  97. onPullDownRefresh: function () {
  98. },
  99. /**
  100. * 页面上拉触底事件的处理函数
  101. */
  102. onReachBottom: function () {
  103. },
  104. /**
  105. * 用户点击右上角分享
  106. */
  107. onShareAppMessage: function () {
  108. if (isFn(sharePage)) return sharePage()
  109. },
  110. /**
  111. * 选择路由跳转
  112. */
  113. selectRouterCtl: function (e) {
  114. const continuousFn = { fn: this.selectRouterCtl, param: { ...arguments } }
  115. const { index } = e.currentTarget.dataset
  116. const { routerTwo } = this.data
  117. const { zindex = 3 } = routerTwo[index]
  118. GetDispatcherInfo({ continuousFn }).then(res => {
  119. const { cancelType, libId, cancelMsg = '没有撤馆权限' } = res.data
  120. let url = ''
  121. let paras = { libId }
  122. switch (~~cancelType) {
  123. case 0:
  124. url = 'dispatcher/pages/withdraw_library/withdraw_library'
  125. break
  126. case 1:
  127. url = 'dispatcher/pages/withdraw/withdraw'
  128. paras.type = 1
  129. break
  130. case 2:
  131. wx.showToast({
  132. title: cancelMsg,
  133. icon: 'none'
  134. })
  135. return
  136. break
  137. case 3:
  138. url = 'dispatcher/pages/withdraw/withdraw'
  139. paras.type = 2
  140. break
  141. }
  142. navigateTo({ url, zindex, paras })
  143. })
  144. },
  145. })