guhongwei 3 سال پیش
والد
کامیت
a168b14b50
2فایلهای تغییر یافته به همراه90 افزوده شده و 29 حذف شده
  1. 64 20
      pages/school/info.js
  2. 26 9
      pages/school/info.wxml

+ 64 - 20
pages/school/info.js

@@ -5,19 +5,21 @@ Page({
         frameStyle: { useTop: true, name: '羽校信息', leftArrow: true, useBar: false },
         user: {},
         id: '',
-        form: {},
-
         // 选中
         tabs: {
-            active: '2',
+            active: '0',
             menu: [
                 { title: '羽校信息', active: '0' },
                 { title: '师资信息', active: '1' },
                 { title: '课程信息', active: '2' },
             ]
         },
+        // 学校信息
+        form: {},
         // 教练信息
         coachList: [],
+        // 课程信息
+        lessonList: [],
         // 分页
         total: 0,
         page: 0,
@@ -25,7 +27,11 @@ Page({
         limit: 5,
         // 字典表
         // 教练等级
-        levelList: []
+        levelList: [],
+        // 课程类型
+        typeList: [],
+        // 课程状态
+        statusList: [],
     },
     // 跳转菜单
     back(e) {
@@ -66,11 +72,11 @@ Page({
             }
         });
     },
-    //报名
-    toSign: function (e) {
+    //课程报名
+    lessonView: function (e) {
         const that = this;
         const { item } = e.currentTarget.dataset;
-        wx.navigateTo({ url: `/pages/stuAdmin/open/sign?id=${item._id}` })
+        wx.navigateTo({ url: `/pages/stuAdmin/course/sign?id=${item._id}` })
     },
     // 分页
     toPage: function () {
@@ -83,7 +89,7 @@ Page({
             that.setData({ page: page })
             let skip = page * limit;
             that.setData({ skip: skip })
-            that.searchRcs();
+            that.watchLogin();
             wx.hideLoading()
         } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
     },
@@ -104,6 +110,7 @@ Page({
         wx.getStorage({
             key: 'user',
             success: async res => {
+                that.setData({ user: res.data })
                 if (that.data.id) {
                     // 学校信息
                     await that.searchSchool(that.data.id);
@@ -120,26 +127,25 @@ Page({
     },
     // 学校信息
     searchSchool: async function (e) {
+        const that = this;
         const arr = await app.$get(`/school/${e}`)
         if (arr.errcode == '0') { that.setData({ form: arr.data }) }
         else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
     },
     // 师资信息
-    searchRcs: async function () {
+    searchRcs: async function (e) {
         const that = this;
-        if (that.data.id) {
-            let info = { skip: that.data.skip, limit: that.data.limit }
-            const arr = await app.$get(`/rcs`, { school_id: that.data.id, ...info });
-            if (arr.errcode == '0') {
-                let list = [...that.data.coachList, ...arr.data];
-                for (const val of list) { val.zhLevel = that.searchLevel(val.coach_id_level) }
-                that.setData({ coachList: list });
-                that.setData({ total: arr.total })
-            }
+        let info = { skip: that.data.skip, limit: that.data.limit }
+        const arr = await app.$get(`/rcs`, { school_id: e, ...info });
+        if (arr.errcode == '0') {
+            let list = [...that.data.coachList, ...arr.data];
+            for (const val of list) { val.zhLevel = that.searchLevel(val.coach_id_level) }
+            that.setData({ coachList: list });
+            that.setData({ total: arr.total })
         }
     },
     // 查询类型
-    searchLevel: function () {
+    searchLevel: function (e) {
         const that = this;
         let levelList = that.data.levelList;
         let data = levelList.find(i => i.value == e);
@@ -147,8 +153,34 @@ Page({
         else return '暂无'
     },
     // 查询课程信息
-    searchLesson: function () {
+    searchLesson: async function (e) {
+        const that = this;
+        let info = { skip: that.data.skip, limit: that.data.limit }
+        const arr = await app.$get(`/lesson`, { school_id: e, ...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 '暂无'
     },
     // 查询其他信息
     searchOther: async function () {
@@ -160,6 +192,18 @@ Page({
             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 })
+        }
     },
     /**
      * 生命周期函数--监听页面初次渲染完成

+ 26 - 9
pages/school/info.wxml

@@ -31,7 +31,7 @@
                                 </view>
                             </view>
                         </view>
-                        <view class="inSchool">
+                        <view class="inSchool" wx:if="{{user.type=='-1'||user.type=='3'}}">
                             <text class="btn" bindtap="toApply">申请入学</text>
                         </view>
                     </view>
@@ -53,21 +53,38 @@
                                 </view>
                             </view>
                             <view class="btn">
-                                <button type="primary" size="mini">详细信息</button>
+                                <button type="primary" size="mini" bindtap="coachView" data-item="{{item}}">详细信息</button>
                             </view>
                         </view>
                     </view>
                 </scroll-view>
             </view>
-            <view wx:elif="{{tabs.active=='2'}}" class="c">
-                <view class="cList" wx:for="{{openList}}" wx:key="index">
-                    <view class="name">{{item.title}}</view>
-                    <view class="btn">
-                        <button type="primary" size="mini" bindtap="toSign" data-item="{{item}}">报名</button>
+            <view wx:elif="{{tabs.active=='2'}}" class="b">
+                <scroll-view scroll-y="true" class="scroll-view" bindscrolltolower="toPage">
+                    <view class="list-scroll-view">
+                        <view class="list" wx:for="{{lessonList}}" wx:key="index">
+                            <view class="name">{{item.title}}</view>
+                            <view class="other">
+                                <view class="other_1">
+                                    <text>课程类型:</text>
+                                    <text>{{item.zhType}}</text>
+                                </view>
+                                <view class="other_1">
+                                    <text>课程时间:</text>
+                                    <text>{{item.time_start}}--{{item.time_end}}</text>
+                                </view>
+                                <view class="other_1">
+                                    <text>课程状态:</text>
+                                    <text>{{item.zhStatus}}</text>
+                                </view>
+                            </view>
+                            <view class="btn">
+                                <button type="primary" size="mini" bindtap="lessonView" data-item="{{item}}">详细信息</button>
+                            </view>
+                        </view>
                     </view>
-                </view>
+                </scroll-view>
             </view>
-            <view wx:elif="{{tabs.active=='3'}}" class="d">私教课</view>
         </view>
     </view>
 </mobile-main>