123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- // teacher/pages/classes/classes.js
- import {
- request,
- throttle,
- debounce
- } from "../../utils/api"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- searchValue: "",
- // 分页数据
- pageNo: 1,
- pageSize: 10,
- total: 11,
- // 筛选项
- classesName: '',
- classList: []
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- wx.hideHomeButton()
- },
- // 确认搜索
- onSearch(e) {
- if (!e.detail.x) {
- this.setData({
- searchValue: e.detail,
- pageNo: 1,
- total: 11,
- })
- }
- this.getClassesList()
- },
- onCancel(e) {
- // onCancel
- console.log(e)
- },
- onStudentList(e) {
- // let
- console.log(e)
- // 跳转学生列表
- wx.navigateTo({
- url: '/teacher/pages/studentList/studentList',
- })
- },
- getClassesList: throttle(async function () {
- let {
- pageNo,
- pageSize,
- total,
- searchValue
- } = this.data
- const res = await request("/app-api/tutor/h5/getClassPage", "GET", {
- pageNo,
- pageSize,
- className: searchValue
- })
- wx.stopPullDownRefresh()
- if (this.data.pageNo === 1) {
- this.setData({
- total: res.data.total,
- classList: res.data.list
- })
- return;
- }
- // 如果还有数据
- if (pageNo * pageSize < total) {
- this.setData({
- total: res.data.total,
- classList: [...this.data.classList, ...res.data.list]
- })
- }
- }),
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.getClassesList()
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- // console.log("2")
- this.setData({
- pageNo: 1
- })
- this.getClassesList()
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- let {
- pageNo,
- pageSize,
- total,
- searchValue
- } = this.data
- this.setData({
- pageNo: pageNo += 1
- })
- this.getClassesList()
- // console.log("1")
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|