123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
- import { DispatcherIndex, DispatcherAudit } from '../../../utils/api.js'
- const { navigateTo, redirectTo, navigateBack } = routers()
- const { globalData } = getApp()
- const { baseImgUrl } = globalData
- Page({
-
- data: {
- baseImgUrl,
- isLoaded: 0,
- pageNo: 1,
- pageSize: 10,
- isAll: 0,
- list: [
-
-
-
-
-
-
-
- ]
- },
-
- onLoad: function (options) {
- this.getData(res => {
- this.setData({ isLoaded: 1 })
- })
- },
-
- 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 () {
- this.setData({ pageNo: 1 })
- this.getData(res => {
- wx.stopPullDownRefresh()
- })
- },
-
- onReachBottom: function () {
- const { isAll = false } = this.data
- if (isAll) return
- this.getData()
- },
-
- onShareAppMessage: function () {
- if (isFn(sharePage)) return sharePage()
- },
-
- getData: function (cb) {
- const continuousFn = { fn: this.getData, param: { ...arguments } }
- const { content, pageNo, pageSize, list } = this.data
- DispatcherIndex({ data: { content, pageNo, pageSize }, continuousFn }).then(res => {
- const newList = res.data.list
- let listTemp = []
- if (pageNo > 1) {
- listTemp = [].concat(list, newList)
- } else {
- listTemp = [].concat(newList)
- }
- this.setData({ list: listTemp, pageNo: newList.length == pageSize ? pageNo + 1 : pageNo, isAll: newList.length < pageSize })
- cb && cb(res)
- }).catch(res => {
- cb && cb(res)
- })
- },
-
- selectLiCtl: function (e) {
- const { index } = e.currentTarget.dataset
- const { list } = this.data
- const libId = list[index].id || ''
- if (libId) {
- getApp().globalData.dispatchLibId = libId
- wx.setStorageSync(`dispatchLibId_${getGlobalVal('userId')}`, libId)
- redirectTo({ url: 'dispatcher/pages/dispatch_go/dispatch_go', paras: { libId }, zindex: 3 })
- } else {
- wx.showToast({
- title: '该馆无效,请换一个馆',
- icon: 'none'
- })
- }
- },
-
- inputSearchCtl: function (e) {
- const { value } = e.detail
- const { content } = this.data
- if (content == value) return
- this.setData({ content: value })
- },
-
- clearSearchCtl: function () {
- this.setData({ content: '' })
- },
-
- submitSearchCtl: function () {
- this.setData({ pageNo: 1 })
- this.getData()
- },
-
- commitDispatcherAuditCtl: function (e) {
- const continuousFn = { fn: this.commitDispatcherAuditCtl, param: { ...arguments } }
- const { type = 0, index = 0 } = e.currentTarget.dataset
- const { list = [] } = this.data
- const { id = '' } = list[index]
- if (!type || !id) return
- DispatcherAudit({ data: { type, libId: id }, continuousFn }).then(res => {
-
-
-
-
-
- this.getData()
- cb && cb(res)
- }).catch(res => {
-
-
-
-
-
- cb && cb(res)
- })
- }
- })
|