123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- // dispatcher/pages/dispatch_leave/dispatch_leave.js
- import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
- import { DispatcherScanning } from '../../../utils/api.js'
- const { navigateTo, redirectTo, navigateBack } = routers()
- const { globalData } = getApp()
- const { baseImgUrl, qrcodeInvalidToastText } = globalData
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- baseImgUrl,
- type: 1,
- footerData: {
- actIndex: 1,
- list: [
- {
- text: '送书到馆',
- icon: '../../../assets/song_shu_dao_guan_gray.png',
- actIcon: '../../../assets/song_shu_dao_guan_blue.png',
- url: 'dispatcher/pages/dispatch_go/dispatch_go',
- zindex: 3
- },
- {
- text: '带书离馆',
- icon: '../../../assets/dai_shu_li_guan_gray.png',
- actIcon: '../../../assets/dai_shu_li_guan_blue.png',
- url: 'dispatcher/pages/dispatch_leave/dispatch_leave',
- zindex: 3
- },
- {
- text: '我的',
- icon: '../../../assets/me_gray.png',
- actIcon: '../../../assets/me_blue.png',
- url: 'dispatcher/pages/me/me',
- zindex: 3
- }
- ]
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- options.userId = getGlobalVal('userId')
- options.libId = (options.libId ? options.libId : getGlobalVal(`dispatchLibId_${options.userId}`) ? getGlobalVal(`dispatchLibId_${options.userId}`) : '')
- this.setData({ options })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- const obj = { navigateTo, redirectTo, navigateBack, viewImage }
- for (const i in obj) {
- this[i] = obj[i]
- }
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- if (isFn(sharePage)) return sharePage()
- },
- /**
- * 扫书
- */
- scanCtl: function () {
- wx.scanCode({
- success: res => {
- const url = res.result
- const detailsId = url.split('_')[1].split('.')[0]
- if (!detailsId) {
- wx.showToast({
- title: qrcodeInvalidToastText,
- icon: 'none'
- })
- return
- }
- this.dispatcherScanningFn(detailsId)
- }
- })
- },
- /**
- * 送书离馆
- */
- dispatcherScanningFn: function (detailsId) {
- const continuousFn = { fn: this.dispatcherScanningFn, param: { ...arguments } }
- const { options = {}, type = 0 } = this.data
- const { libId = '' } = options
- DispatcherScanning({ data: { detailsId, libId, type }, continuousFn }).then(res => {
- wx.showToast({
- title: '扫书成功',
- icon: 'success'
- })
- setTimeout(() => {
- this.scanCtl()
- }, 2000)
- }).catch(res => {
- wx.showToast({
- title: res.msg,
- icon: 'none'
- })
- })
- }
- })
|