123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- // dispatcher/pages/sweeped_books/sweeped_books.js
- import { routers, viewImage, sharePage, isFn, getGlobalVal } from '../../../utils/util.js'
- import { SignMonthList, DayInfoList } from '../../../utils/api.js'
- const { navigateTo, redirectTo, navigateBack } = routers()
- const { globalData } = getApp()
- const { baseImgUrl, thumbnail, qrcodeInvalidToastText } = globalData
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- baseImgUrl,
- thumbnail,
- isLoaded: false,
- isAllCheck: 0,
- isManage: 0,
- totalNum: 0,
- month:'',
- Search_date:'',
- monthValue:'',
- dateL:'',
- ids: [],
- isMonthData:0,
- pageNo: 1,
- pageSize: 10,
- isAll: 0,
- isDown: false,
- totalNumbers: 0,
- list: [
- ],
- nodataMonthArray: {
- text: "本月无到馆会员数据",
- image: '../../../assets/Nosign.png',
- margin: '400rpx auto'
- },
- nodataArray: {
- text: "本日暂无数据统计",
- image: '../../../assets/Nosign.png',
- margin: '400rpx auto'
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- options.vipId = getGlobalVal('vipId', `vipId_${getGlobalVal('userId')}`)
- options.libId = getGlobalVal('list').length > 0 ? getGlobalVal('list')[0].libId : ''
- this.setData(options)
- this.GetMonthDate()
- const Search_date = wx.getStorageSync("date")
- const monthValue = wx.getStorageSync("monthValue")
-
- this.setData({
- isMonthData: options.isMonthData,
- Search_date: Search_date,
- monthValue: monthValue
- });
- if (options.isMonthData == 1) {
- this.getDayData(res => {
- this.setData({ isLoaded: 1 })
- wx.setNavigationBarTitle({
- title: `日统计数据`,
- })
- })
- }
- if (options.isMonthData == 2) {
- this.getMonthData(res => {
- this.setData({ isLoaded: 1 })
- wx.setNavigationBarTitle({
- title: `本月到馆会员`,
- })
- })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- 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, isMonthData } = this.data
- const { type = 1 } = options
- if (type == 1) return
- this.setData({ pageNo: 1 })
- if (isMonthData == 1) {
- this.getDayData(res => {
- wx.stopPullDownRefresh()
- })
- }
- if (isMonthData == 2) {
- this.getMonthData(res => {
- wx.stopPullDownRefresh()
- })
- }
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- const { isAll, isDown, isMonthData } = this.data
- if (isAll) {
- this.setData({ isDown: true })
- return
- } else {
- this.setData({ isLoad: true, isDown: false })
- if (isMonthData == 1) {
- this.getDayData(res => {
- this.setData({ isLoad: false })
- })
- }
- if (isMonthData == 2) {
- this.getMonthData(res => {
- this.setData({ isLoad: false })
- })
- }
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- if (isFn(sharePage)) return sharePage()
- },
- GetMonthDate: function () {
- const now = new Date();
- const year = now.getFullYear(); //年
- const month = now.getMonth() + 1; //月
- const nowdate = year + '-' + month
- this.setData({ month: nowdate })
- },
- /**
- * 本月签到人数
- */
- getMonthData: function (cb) {
- const continuousFn = { fn: this.getMonthData, param: { ...arguments } }
- const { pageNo, pageSize, list, libId, monthValue } = this.data
- SignMonthList({ data: { month: monthValue, libId, pageNo, pageSize }, continuousFn }).then(res => {
- const { list, pages } = res.data
- let listTemp = []
- if (pageNo == 1) {
- listTemp = [].concat(list)
- } else {
- listTemp = [].concat(this.data.list, list)
- }
- const correctListTemp = (res => {
- console.log(res)
- var d = []
- for (let i in res) {
- res[i].number = 0
- }
- return res
- })(listTemp)
- this.setData({ list: correctListTemp, monthpages: pages, pageNo: list.length == pageSize ? pageNo + 1 : pageNo, isAll: list.length < pageSize })
- cb && cb(res)
- }).catch(res => {
- cb && cb(res)
- })
- },
- /**
- * 本日签到人数
- */
- getDayData: function (cb) {
- const continuousFn = { fn: this.getDayData, param: { ...arguments } }
- const { pageNo, pageSize, list, libId, Search_date } = this.data
- DayInfoList({ data: { date: Search_date, libId, pageNo, pageSize }, continuousFn }).then(res => {
- const { list } = res.data
- let listTemp = []
- if (pageNo == 1) {
- listTemp = [].concat(list)
- } else {
- listTemp = [].concat(this.data.list, list)
- }
- const correctListTemp = (res => {
- console.log(res)
- var d = []
- for (let i in res) {
- res[i].number = 0
- }
- return res
- })(listTemp)
- this.setData({ list: correctListTemp, pageNo: list.length == pageSize ? pageNo + 1 : pageNo, isAll: list.length < pageSize })
- cb && cb(res)
- }).catch(res => {
- cb && cb(res)
- })
- },
- })
|