123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- const app = getApp()
- const util = require('../../utils/util.js')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- frameStyle: { useTop: true, name: '羽校信息', leftArrow: true, useBar: false },
- id: '',
- // 选中
- tabs: {
- active: '0',
- menu: [
- { title: '羽校信息', active: '0' },
- { title: '师资信息', active: '1' },
- { title: '学员信息', active: '2' },
- { title: '课程信息', active: '3' },
- ]
- },
- // 学校详细信息
- info: {},
- // 师资信息
- teacherList: [],
- // 学员信息
- studentList: [],
- // 课程信息
- lessonList: [],
- // 分页
- total: 0,
- page: 0,
- skip: 0,
- limit: 10,
- // 字典表
- // 教练等级
- levelList: [],
- // 课程类型
- typeList: [],
- // 课程状态
- statusList: [],
- //运动等级
- stlevelList: [],
- },
- // 跳转菜单
- back(e) {
- wx.navigateBack({ delta: 1 })
- },
- // 清空列表
- clearPage() {
- const that = this;
- that.setData({ teacherList: [], studentList: [], lessonList: [], skip: 0, limit: 10, page: 0 })
- },
- // 选项卡选择
- tabsChange: function (e) {
- const that = this;
- let data = e.detail;
- that.setData({ 'tabs.active': data.active });
- if (data.active == '1' || data.active == '2' || data.active == '3') {
- that.clearPage();
- that.search();
- }
- },
- // 公共跳转
- toCommon(e) {
- const { route, id } = e.currentTarget.dataset;
- wx.navigateTo({ url: `/pagesSchool/${route}?id=${id}` })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: async function (options) {
- const that = this;
- that.setData({ id: options.id || '6355f251cb0f85380e83520b' });
- await that.searchOther();
- await that.search();
- },
- // 查询信息
- async search() {
- const that = this;
- let id = that.data.id;
- if (id) {
- let res = await app.$get(`/school/${id}`)
- if (res.errcode == '0') { that.setData({ info: res.data }) }
- else { wx.showToast({ title: res.errmsg, icon: 'none' }) }
- // 查询师资信息
- that.searchCoach();
- // 查询学员信息
- that.searchStu();
- // 查询课程信息
- that.searchLess();
- }
- },
- // 查询师资信息
- async searchCoach() {
- const that = this;
- let id = that.data.id;
- let info = { skip: that.data.skip, limit: that.data.limit, school_id: id }
- const arr = await app.$get(`/rcs`, { ...info });
- if (arr.errcode == '0') {
- let list = [...that.data.teacherList, ...arr.data];
- // 教练等级
- for (const val of list) {
- if (val.coach_id_phone) val.coach_id_phone = util.hidePhone(val.coach_id_phone);
- val.zhLevel = that.searchLevel(val.coach_id_level)
- }
- that.setData({ teacherList: list });
- that.setData({ total: arr.total })
- }
- },
- // 教練等級
- searchLevel: function (e) {
- const that = this;
- let levelList = that.data.levelList;
- let data = levelList.find(i => i.value == e);
- if (data) return data.label;
- else return '暂无'
- },
- // 查询学员信息
- async searchStu() {
- const that = this;
- let id = that.data.id;
- let info = { skip: that.data.skip, limit: that.data.limit, school_id: id }
- const arr = await app.$get(`/rss`, { ...info });
- if (arr.errcode == '0') {
- let list = [...that.data.studentList, ...arr.data];
- for (const val of list) {
- if (val.student_id_phone) val.student_id_phone = util.hidePhone(val.student_id_phone);
- val.student_id_zhlevel = that.searchstLevel(val.student_id_level)
- }
- that.setData({ studentList: list });
- that.setData({ total: arr.total })
- }
- },
- // 运动等级
- searchstLevel: function (e) {
- const that = this;
- let stlevelList = that.data.stlevelList;
- let data = stlevelList.find(i => i.value == e);
- if (data) return data.label;
- else return '暂无'
- },
- // 查询课程信息
- async searchLess() {
- const that = this;
- let id = that.data.id;
- let info = { skip: that.data.skip, limit: that.data.limit, school_id: id }
- const arr = await app.$get(`/lesson`, { ...info });
- if (arr.errcode == '0') {
- let list = [...that.data.lessonList, ...arr.data];
- for (const val of list) {
- val.zhType = that.searchType(val.type);
- val.zhStatus = that.searchStatus(val.status);
- }
- that.setData({ lessonList: list });
- that.setData({ total: arr.total })
- }
- },
- // 课程类型
- searchType: function (e) {
- const that = this;
- let typeList = that.data.typeList;
- let data = typeList.find(i => i.value == e);
- if (data) return data.label;
- else return '暂无'
- },
- // 课程状态
- searchStatus: function (e) {
- const that = this;
- let statusList = that.data.statusList;
- let data = statusList.find(i => i.value == e);
- if (data) return data.label;
- else return '暂无'
- },
- // 分页
- toPage: function () {
- const that = this;
- let active = that.data.tabs.active;
- let list = [];
- if (active == '1') list = that.data.teacherList;
- else if (active == '2') list = that.data.studentList;
- else if (active == '3') list = that.data.lessonList;
- let limit = that.data.limit;
- if (that.data.total > list.length) {
- wx.showLoading({ title: '加载中', mask: true })
- let page = that.data.page + 1;
- that.setData({ page: page })
- let skip = page * limit;
- that.setData({ skip: skip })
- that.search();
- wx.hideLoading()
- } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
- },
- // 查询其他信息
- searchOther: async function () {
- const that = this;
- let arr;
- // 教练等级
- arr = await app.$get(`/dict`, { code: 'coach_grade' })
- if (arr.errcode == '0' && arr.total > 0) {
- let data = arr.data[0];
- if (data.list && data.list.length > 0) that.setData({ levelList: data.list })
- }
- // 课程类型
- arr = await app.$get(`/dict`, { code: 'lesson_type' })
- if (arr.errcode == '0' && arr.total > 0) {
- let data = arr.data[0];
- if (data.list && data.list.length > 0) that.setData({ typeList: data.list })
- }
- // 课程状态
- arr = await app.$get(`/dict`, { code: 'lesson_status' })
- if (arr.errcode == '0' && arr.total > 0) {
- let data = arr.data[0];
- if (data.list && data.list.length > 0) that.setData({ statusList: data.list })
- }
- // 运动等级
- arr = await app.$get(`/dict`, { code: 'student_grade' });
- if (arr.errcode == '0' && arr.total > 0) {
- let list = arr.data[0].list;
- that.setData({ stlevelList: list })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|