borrow_car.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // parents/pages/home/home.js
  2. import { routers, viewImage, sharePage, isFn, getGlobalVal, getWxLocationSetting } from '../../utils/util.js'
  3. import { CheckNext} from '../../utils/api.js'
  4. const { navigateTo, redirectTo, navigateBack } = routers()
  5. const { globalData, hasLibraryService, hasVipService } = getApp()
  6. const { baseImgUrl, qrcodeInvalidToastText, isIphoneX, noVipListToastText } = globalData
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. baseImgUrl,
  13. isIphoneX,
  14. isFirst: 0,
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. if(options.q){
  21.   var scene = decodeURIComponent(options.q) // 使用decodeURIComponent解析 获取当前二维码的网址
  22.   const detailsId = scene.split('=')[1].split('.')[0]
  23. if (!detailsId) {
  24. wx.showToast({
  25. title: qrcodeInvalidToastText,
  26. icon: 'none'
  27. })
  28. return
  29. }
  30. this.scanCtl(detailsId)
  31. }
  32. },
  33. /**
  34. * 生命周期函数--监听页面初次渲染完成
  35. */
  36. onReady: function () {
  37. const obj = { navigateTo, redirectTo, navigateBack, viewImage }
  38. for (const i in obj) {
  39. this[i] = obj[i]
  40. }
  41. },
  42. /**
  43. * 生命周期函数--监听页面显示
  44. */
  45. onShow: function () {
  46. },
  47. /**
  48. * 生命周期函数--监听页面隐藏
  49. */
  50. onHide: function () {
  51. },
  52. /**
  53. * 生命周期函数--监听页面卸载
  54. */
  55. onUnload: function () {
  56. },
  57. /**
  58. * 页面相关事件处理函数--监听用户下拉动作
  59. */
  60. onPullDownRefresh: function () {
  61. // this.getList(res => {
  62. // wx.stopPullDownRefresh()
  63. // })
  64. },
  65. /**
  66. * 页面上拉触底事件的处理函数
  67. */
  68. onReachBottom: function () {
  69. },
  70. /**
  71. * 用户点击右上角分享
  72. */
  73. onShareAppMessage: function () {
  74. if (isFn(sharePage)) return sharePage()
  75. },
  76. /**
  77. * 跳转页面
  78. */
  79. scanCtl: function (detailsId) {
  80. const continuousFn = { fn: this.scanCtl, param: { ...arguments } }
  81. const { library, vipId, userId } = this.data
  82. var roleType=wx.getStorageSync('isDispatcher')
  83. CheckNext({ data: { detailsId, roleType }, continuousFn }).then(res => {
  84. const { type, detailsId } = res.data
  85. if (type==1){
  86. redirectTo({ url: 'president/pages/book_entry/book_entry', paras: { detailsId,isTwo:true,isFirst:false} })
  87. }else if (type==2){
  88. redirectTo({ url: 'president/pages/book_entry/book_entry', paras: { detailsId,isTwo:false,isFirst:true} })
  89. }else if (type==3){
  90. redirectTo({ url: 'parents/pages/borrow_car/borrow_car', paras: { canBorrowNum } })
  91. }else if (type==4){
  92. redirectTo({ url: 'parents/pages/borrow_car/borrow_car', paras: { canBorrowNum } })
  93. }else if (type==5){
  94. redirectTo({ url: 'parents/pages/borrow_car/borrow_car', paras: { canBorrowNum } })
  95. }else if (type==6){
  96. redirectTo({ url: 'parents/pages/borrow_car/borrow_car', paras: { canBorrowNum } })
  97. }else if (type==7){
  98. redirectTo({ url: 'parents/pages/borrow_car/borrow_car', paras: { canBorrowNum } })
  99. }else if (type==8&&roleType==1){
  100. redirectTo({ url: 'dispatcher/pages/home/home', paras: {} })
  101. }else if (type==8&&roleType==2){
  102. redirectTo({ url: 'parents/pages/main/main', paras: {} })
  103. }else if (type==8&&roleType==3){
  104. redirectTo({ url: 'president/pages/home/home', paras: {} })
  105. }
  106. this.setData({ ...res.data })
  107. })
  108. },
  109. })