123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- // pages/ranking_list/ranking_list.js
- // pages/child_list/child_list.js
- import { routers, viewImage, sharePage, isFn, getGlobalVal, formatDateTime, formateNumber } from '../../utils/util.js'
- import { GetServiceRecordsV1,HomeworkUploadRecord,CoreRanking} from '../../utils/api.js'
- const { navigateTo, redirectTo, navigateBack } = routers()
- const { globalData, saveUserInfo, getWxloginCode, checkStatus } = getApp()
- const { baseImgUrl, thumbnail } = globalData
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- baseImgUrl,
- thumbnail,
- statusBar: app.globalData.statusBar,
- isLoaded: false,
- isChild:false,
- searchKey: '',
- checkNum:0,
- isCheck:false,
- pageNo: 1,
- pageSize: 20,
- isAll: false,
- list:[],
- nodata: [
- {
- text: '暂无数据'
- }
- ],
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- options.libId = wx.getStorageSync('libId')||options.libId;
- if (options.isType==1){
- wx.setNavigationBarTitle({
- title: '校区排行榜',
- })
- }else if(options.isType==2){
- wx.setNavigationBarTitle({
- title: '消费记录',
- })
- }else if(options.isType==3){
- wx.setNavigationBarTitle({
- title: '班级排行榜',
- })
- }else if(options.isType==4){
- wx.setNavigationBarTitle({
- title: '班级作业上传记录',
- })
- }else if(options.isType==5){
- wx.setNavigationBarTitle({
- title: `${options.childName}`,
- })
- }
- this.setData(options)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- const obj = { navigateTo, redirectTo, navigateBack, viewImage }
- for (const i in obj) {
- this[i] = obj[i]
- }
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- wx.showLoading({
- title: '加载中',
- })
- this.getData();
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- this.setData({ pageNo: 1 })
- this.getData(res => {
- wx.stopPullDownRefresh()
- })
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- const { isAll} = this.data
- if (isAll) {
- return
- }
- this.getData()
-
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- if (app.sharePageDefaultCtl) {
- return app.sharePageDefaultCtl()
- }
- },
- /**
- * 获取学生数据
- */
- getData: function (cb) {
- const continuousFn = { fn: this.getData, param: { ...arguments } }
- const {pageNo, pageSize, list=[], classId,libId,vipId,isType}=this.data;
- var obj = [CoreRanking,GetServiceRecordsV1,CoreRanking,HomeworkUploadRecord,GetServiceRecordsV1]
- var dataList=[{pageNo,pageSize},{pageNo,pageSize,libId},{pageNo,pageSize,classId},{pageNo,pageSize,classId},{pageNo,pageSize,libId,vipId}]
- obj[isType-1]({ data:dataList[isType-1], continuousFn }).then(res => {
- wx.hideLoading();
- const temp = res.data.list;
- const tempList = (res => {
- if(isType==2||isType==5){
- for (let i in res) {
- if (res[i].consumer.length>5){
- res[i].consumer = res[i].consumer.slice(0, 5)+ '...'
- }else{
- res[i].consumer = res[i].consumer
- }
- }
- }
- return res
- })(temp || [])
- let arr = []
- if (pageNo == 1) {
- arr = [...tempList]
- } else {
- arr = [...list, ...tempList]
- }
- this.setData({
- list: arr,
- pageNo: tempList.length == pageSize ? Number(pageNo) + 1 : pageNo,
- isAll: tempList.length < pageSize,
- isLoaded: true
- })
- if (isFn(cb)) cb()
- }).catch(res => {
- this.setData({ isLoaded: true })
- if (isFn(cb)) cb()
- })
- }
- })
|