me.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. // dispatcher/pages/me/me.js
  2. import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
  3. import { GetDispatcherInfo,ScanForBookDetail} 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. routerFour:[
  37. {
  38. icon: '../../../assets/personal_info.png',
  39. text: '归还解绑图书',
  40. time: '',
  41. url: 'dispatcher/pages/book_entry/book_entry',
  42. paras: {
  43. type: 2
  44. },
  45. zindex: 3
  46. }
  47. ],
  48. footerData: {
  49. actIndex: 2,
  50. list: [
  51. {
  52. text: '送书到馆',
  53. icon: '../../../assets/song_shu_dao_guan_gray.png',
  54. actIcon: '../../../assets/song_shu_dao_guan_blue.png',
  55. url: 'dispatcher/pages/dispatch_go/dispatch_go',
  56. zindex: 3
  57. },
  58. {
  59. text: '带书离馆',
  60. icon: '../../../assets/dai_shu_li_guan_gray.png',
  61. actIcon: '../../../assets/dai_shu_li_guan_blue.png',
  62. url: 'dispatcher/pages/dispatch_leave/dispatch_leave',
  63. zindex: 3
  64. },
  65. {
  66. text: '我的',
  67. icon: '../../../assets/me_gray.png',
  68. actIcon: '../../../assets/me_blue.png',
  69. url: 'dispatcher/pages/me/me',
  70. zindex: 3
  71. }
  72. ]
  73. }
  74. },
  75. /**
  76. * 生命周期函数--监听页面加载
  77. */
  78. onLoad: function (options) {
  79. options.userInfo = getGlobalVal('userInfo')
  80. this.setData({ options, isLoaded: 1 })
  81. },
  82. /**
  83. * 生命周期函数--监听页面初次渲染完成
  84. */
  85. onReady: function () {
  86. const obj = { navigateTo, redirectTo, navigateBack, viewImage }
  87. for (const i in obj) {
  88. this[i] = obj[i]
  89. }
  90. },
  91. /**
  92. * 生命周期函数--监听页面显示
  93. */
  94. onShow: function () {
  95. },
  96. /**
  97. * 生命周期函数--监听页面隐藏
  98. */
  99. onHide: function () {
  100. },
  101. /**
  102. * 生命周期函数--监听页面卸载
  103. */
  104. onUnload: function () {
  105. },
  106. /**
  107. * 页面相关事件处理函数--监听用户下拉动作
  108. */
  109. onPullDownRefresh: function () {
  110. },
  111. /**
  112. * 页面上拉触底事件的处理函数
  113. */
  114. onReachBottom: function () {
  115. },
  116. /**
  117. * 用户点击右上角分享
  118. */
  119. onShareAppMessage: function () {
  120. if (isFn(sharePage)) return sharePage()
  121. },
  122. /**
  123. * 选择跳转进入页
  124. */
  125. selectNavCtl: function () {
  126. navigateTo({
  127. url: 'dispatcher/pages/book_entry/book_entry',
  128. })
  129. },
  130. /**
  131. * 扫一扫书籍标签二维码
  132. */
  133. codeScanCtl: function () {
  134. wx.scanCode({
  135. success: res => {
  136. const url = res.result
  137. const detailsId = url.split('_')[1].split('.')[0]
  138. console.log(res)
  139. if (!detailsId) {
  140. wx.showToast({
  141. title: qrcodeInvalidToastText,
  142. icon: 'none'
  143. })
  144. return
  145. }
  146. this.setData({ detailsId })
  147. wx.setStorageSync('detailsId', detailsId);
  148. this.setBookInfoByIsbn()
  149. }
  150. })
  151. },
  152. /**
  153. * 调用微信扫一扫
  154. */
  155. /**
  156. * 根据isbn13查询书籍信息
  157. */
  158. setBookInfoByIsbn: function () {
  159. const continuousFn = { fn: this.setBookInfoByIsbn, param: { ...arguments } }
  160. const { detailsId } = this.data
  161. const that=this
  162. ScanForBookDetail({ data: { detailId:detailsId }, continuousFn }).then(res => {
  163. const {bookInfo} = res.data
  164. wx.setStorageSync('bookInfo', bookInfo);
  165. this.selectNavCtl()
  166. cb && cb(res)
  167. }).catch(res => {
  168. // navigateBack()
  169. cb && cb(res)
  170. })
  171. },
  172. /**
  173. * 选择路由跳转
  174. */
  175. selectRouterCtl: function (e) {
  176. const continuousFn = { fn: this.selectRouterCtl, param: { ...arguments } }
  177. const { index } = e.currentTarget.dataset
  178. const { routerTwo } = this.data
  179. const { zindex = 3 } = routerTwo[index]
  180. GetDispatcherInfo({ continuousFn }).then(res => {
  181. const { cancelType, libId, cancelMsg = '没有撤馆权限' } = res.data
  182. let url = ''
  183. let paras = { libId }
  184. switch (~~cancelType) {
  185. case 0:
  186. url = 'dispatcher/pages/withdraw_library/withdraw_library'
  187. break
  188. case 1:
  189. url = 'dispatcher/pages/withdraw/withdraw'
  190. paras.type = 1
  191. break
  192. case 2:
  193. wx.showToast({
  194. title: cancelMsg,
  195. icon: 'none'
  196. })
  197. return
  198. break
  199. case 3:
  200. url = 'dispatcher/pages/withdraw/withdraw'
  201. paras.type = 2
  202. break
  203. }
  204. navigateTo({ url, zindex, paras })
  205. })
  206. },
  207. })