123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- // parents/pages/reservations/reservations.js
- import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
- import { LibVipList, ManagerList } from '../../../utils/api.js'
- const { navigateTo, redirectTo, navigateBack } = routers()
- const { globalData, hasLibraryService, hasVipService } = getApp()
- const { baseImgUrl, thumbnail,qrcodeInvalidToastText } = globalData
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- baseImgUrl,
- thumbnail,
- isLoaded: 1,
- content: '',
- navIndex: 0,
- pageNo:1,
- pageSize:10,
- isAll:0,
- index: 0,
- isDown: false,
- list:[],
- managerList:[],
- isreturn:0,
- navList: [
- {
- text: '会员管理',
- list: [],
- nodataArray: {
- text: '暂没有预约书单',
- image: '../../../assets/nodata_3.png',
- hasNodataBtn: 1,
- btnText: '去书库看看'
- }
- },
- {
- text: '馆内人员管理',
- list: [],
- nodataArray: {
- text: '暂没有已预约书单',
- image: '../../../assets/nodata_2.png',
- hasNodataBtn: 1,
- btnText: '去书库看看'
- }
- }
- ],
- footerData: {
- actIndex: 1,
- list: [
- {
- text: '日常事务',
- icon: '../../../assets/lock_gary.png',
- actIcon: '../../../assets/lock_blue.png',
- url: 'president/pages/home/home',
- zindex: 3,
- },
- {
- text: '人员管理',
- icon: '../../../assets/people_manager_gary.png',
- actIcon: '../../../assets/people_manager_blue.png',
- url: 'president/pages/Personnel_management/Personnel_management',
- zindex: 3,
- },
- {
- text: '我的',
- icon: '../../../assets/me_gray.png',
- actIcon: '../../../assets/me_blue.png',
- url: 'president/pages/me/me',
- zindex: 3,
- }
- ]
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- options.vipId = getGlobalVal('vipId', `vipId_${getGlobalVal('userId')}`)
- options.libId = getGlobalVal('list').length > 0 ? getGlobalVal('list')[0].libId : ''
- wx.setNavigationBarTitle({
- title: `人员管理`,
- })
- this.setData(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 () {
- const { isAll, options } = this.data
- const { type = 1 } = options
- if (type == 1) return
- this.setData({ pageNo: 1 })
- this.getData(res => {
- wx.stopPullDownRefresh()
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- const { isAll, isDown } = this.data
- if (isAll) {
- this.setData({ isDown: true })
- return
- } else {
- this.setData({ isLoad: true, isDown: false })
- this.getData(() => {
- this.setData({ isLoad: false })
- })
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- if (isFn(sharePage)) return sharePage()
- },
- pickChange: function (e) {
- this.setData({
- index: e.detail.value
- });
- },
- /**
- * 会员管理获取数据
- */
- getData: function (cb) {
- const continuousFn = { fn: this.getData, param: { ...arguments } }
- // if (!hasVipService()) {
- // cb && cb()
- // return
- // }
- // if (!hasLibraryService()) {
- // cb && cb()
- // return
- // }
- const { navIndex, navList, options, pageSize, pageNo, libId } = this.data
- LibVipList({ data: { pageSize, pageNo, libId,}, continuousFn }).then(res => {
- const { list, pages, todayAdd } = res.data
- const oneTemp = (res => {
- for (let i in res) {
- for (let j in res[i].valueList){
- if (res[i].valueList[j].summary.length > 30) {
- res[i].valueList[j].summary = res[i].valueList[j].summary.slice(0, 30) + '...'
- } else {
- res[i].valueList[j].summary = res[i].valueList[j].summary
- }
- }
- }
- return res
- })(list)
- let listTemp = []
- if (pageNo == 1) {
- listTemp = [].concat(oneTemp)
- } else {
- listTemp = [].concat(that.data.list, oneTemp)
- }
- this.setData({
- list: listTemp,
- pageNo: list.length == pageSize ? pageNo + 1 : pageNo,
- isAll: list.length < pageSize ,
- pages: pages,
- todayAdd: todayAdd
- })
- cb && cb()
- }).catch(res => {
- cb && cb()
- })
- },
- /**
- * 馆内人员管理获取数据
- */
- getLibraryData: function (cb) {
- const continuousFn = { fn: this.getData, param: { ...arguments } }
- // if (!hasVipService()) {
- // cb && cb()
- // return
- // }
- // if (!hasLibraryService()) {
- // cb && cb()
- // return
- // }
- const { navIndex, navList, options, pageSize, pageNo, libId } = this.data
- ManagerList({ data: { pageSize, pageNo, libId, }, continuousFn }).then(res => {
- const { managerList, pages } = res.data
- // debugger
- const oneTemp = (res => {
- for (let i in res) {
- for (let j in res[i].valueList) {
- if (res[i].valueList[j].summary.length > 30) {
- res[i].valueList[j].summary = res[i].valueList[j].summary.slice(0, 30) + '...'
- } else {
- res[i].valueList[j].summary = res[i].valueList[j].summary
- }
- }
- }
- return res
- })(managerList)
- let listTemp = []
- if (pageNo == 1) {
- listTemp = [].concat(oneTemp)
- } else {
- listTemp = [].concat(that.data.managerList, oneTemp)
- }
- this.setData({
- managerList: listTemp,
- pageNo: managerList.length == pageSize ? pageNo + 1 : pageNo,
- isAll: managerList.length < pageSize,
- managerpages: pages,
- })
-
- cb && cb()
- }).catch(res => {
- cb && cb()
- })
- },
- /**
- * 选择导航栏
- */
- selectNavCtl: function (e) {
- const { index } = e.currentTarget.dataset
- const { navIndex, navList, isreturn } = this.data
- if (navIndex == index) return
- this.setData({ navIndex: index })
- if (index == 0) {
- this.setData({ isreturn: 0 })
- if (navList[index]['list'].length == 0) {
- this.getData()
- }
- } else if (index == 1) {
- this.setData({ isreturn: 1 })
- this.getLibraryData()
- }
- },
- })
|