zs 2 years ago
parent
commit
8d2945d985

+ 89 - 4
pagesSchool/coaAdmin/course/list.js

@@ -5,12 +5,47 @@ Page({
      */
     data: {
         frameStyle: { useTop: true, name: '课程管理', leftArrow: true, useBar: false },
+        // 查询
+        search: {},
+        list: [],
+        total: 0,
+        skip: 0,
+        limit: 6,
+        page: 0,
+        // 状态列表
+        statusList: [],
     },
     // 跳转菜单
     back(e) {
         wx.navigateBack({ delta: 1 })
     },
-
+    // 查询
+    toInput(e) {
+        const that = this;
+        let value = e.detail.value;
+        if (value) that.setData({ 'search.lesson_id_title': value })
+        else that.setData({ search: {} })
+        that.clearPage(); that.watchLogin();
+    },
+    // 清空列表
+    clearPage() {
+        const that = this;
+        that.setData({ list: [], skip: 0, limit: 6, page: 0 })
+    },
+    // 学员管理
+    toManage(e) {
+        const that = this;
+        let { item } = e.currentTarget.dataset;
+        // that.clearPage();
+        console.log(item);
+    },
+    // 详细信息
+    toView(e) {
+        const that = this;
+        let { item } = e.currentTarget.dataset;
+        that.clearPage();
+        wx.navigateTo({ url: `/pagesSchool/common/lessoninfo?id=${item.lesson_id}` })
+    },
     /**
      * 生命周期函数--监听页面加载
      */
@@ -27,11 +62,61 @@ Page({
     /**
      * 生命周期函数--监听页面显示
      */
-    onShow: function () {
+    onShow: async function () {
         const that = this;
-
+        // 查询其他信息
+        await that.searchOther();
+        // 监听用户是否登录
+        await that.watchLogin();
+    },
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                let info = { skip: that.data.skip, limit: that.data.limit };
+                const arr = await app.$get(`/lessonCoach`, { ...info, ...that.data.search });
+                if (arr.errcode == '0') {
+                    let list = [...that.data.list, ...arr.data];
+                    for (const val of list) { val.zhStatus = that.searchStatus(val.lesson_id_status) }
+                    that.setData({ list });
+                    that.setData({ total: arr.total })
+                }
+                else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }); }
+            },
+            fail: async res => {
+                wx.redirectTo({ url: '/pages/index/index' })
+            }
+        })
+    },
+    searchStatus(e) {
+        const that = this;
+        let data = that.data.statusList.find(i => i.value == e);
+        if (data) return data.label
+    },
+    // 分页
+    toPage: function () {
+        const that = this;
+        let list = that.data.list;
+        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.watchLogin();
+            wx.hideLoading()
+        } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
+    },
+    // 查询其他信息
+    async searchOther() {
+        const that = this;
+        let res;
+        // 状态
+        res = await app.$get(`/dict`, { code: "lesson_status" });
+        if (res.errcode == '0' && res.total > 0) that.setData({ statusList: res.data[0].list });
     },
-
 
     /**
      * 生命周期函数--监听页面隐藏

+ 85 - 1
pagesSchool/coaAdmin/course/list.less

@@ -1 +1,85 @@
-@import (css) "/app.wxss";
+@import (css) "/app.wxss";
+
+.main {
+    height: 91vh;
+
+    .one {
+        padding: 2vw;
+        border-bottom: 1px solid #858585;
+        margin: 0 0 2vw 0;
+
+        input {
+            padding: 2vw;
+            font-size: 12px;
+            border-radius: 5px;
+            background-color: #fff;
+        }
+    }
+
+    .two {
+        position: relative;
+        flex-grow: 1;
+
+        .list {
+            margin: 0 2vw 2vw 2vw;
+            padding: 2vw;
+            background-color: #fff;
+            border-radius: 5px;
+
+            .name {
+                text-align: center;
+                font-size: 16px;
+                font-weight: bold;
+                margin: 0 0 1vw 0;
+
+                .status {
+                    color: #ff0000;
+                }
+            }
+
+            .other_1 {
+                font-size: 14px;
+                color: #858585;
+                margin: 0 0 1vw 0;
+
+                text:last-child {
+                    color: #000000;
+                }
+            }
+
+            .money {
+                color: #ff0000;
+                font-size: 14px;
+                font-weight: bold;
+                text-align: center;
+                margin: 0 0 2vw 0;
+            }
+
+            .btn {
+                text-align: center;
+
+                button {
+                    margin: 0 2vw 2vw 2vw;
+                    font-size: 14px;
+                }
+            }
+        }
+
+        .list:last-child {
+            margin: 0 2vw 0 2vw;
+        }
+    }
+}
+
+.scroll-view {
+    position: absolute;
+    top: 0;
+    left: 0;
+    right: 0;
+    bottom: 0;
+
+    .list-scroll-view {
+        display: flex;
+        flex-direction: column;
+    }
+}

+ 30 - 1
pagesSchool/coaAdmin/course/list.wxml

@@ -1,5 +1,34 @@
 <mobile-main frameStyle="{{frameStyle}}" bind:back="back">
     <view slot="info" class="container main">
-        <view>课程信息</view>
+        <view class="one">
+            <input type="text" value="{{search.title}}" bindconfirm="toInput" placeholder="请输入关键词" />
+        </view>
+        <view class="two">
+            <scroll-view scroll-y="true" class="scroll-view" bindscrolltolower="toPage">
+                <view class="list-scroll-view">
+                    <view class="list" wx:for="{{list}}" wx:key="index">
+                        <view class="name">{{item.lesson_id_title}}
+                            <text class="status">[{{item.zhStatus}}]</text>
+                        </view>
+                        <view class="other_1">
+                            <text>上课时间:</text>
+                            <text>{{item.lesson_id_time_start}}至{{item.lesson_id_time_end}}</text>
+                        </view>
+                        <view class="other_1">
+                            <text>学校名称:</text>
+                            <text>{{item.school_id_name}}</text>
+                        </view>
+                        <view class="money">
+                            <text>¥</text>
+                            <text>{{item.money}}</text>
+                        </view>
+                        <view class="btn">
+                            <button type="primary" size="mini" bindtap="toView" data-item="{{item}}">详细信息</button>
+                            <button type="primary" size="mini" bindtap="toManage" data-item="{{item}}">学员管理</button>
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
     </view>
 </mobile-main>

+ 70 - 1
pagesSchool/coaAdmin/course/list.wxss

@@ -1 +1,70 @@
-/* pagesSchool/coaAdmin/course/list.wxss */
+@import "/app.wxss";
+.main {
+  height: 91vh;
+}
+.main .one {
+  padding: 2vw;
+  border-bottom: 1px solid #858585;
+  margin: 0 0 2vw 0;
+}
+.main .one input {
+  padding: 2vw;
+  font-size: 12px;
+  border-radius: 5px;
+  background-color: #fff;
+}
+.main .two {
+  position: relative;
+  flex-grow: 1;
+}
+.main .two .list {
+  margin: 0 2vw 2vw 2vw;
+  padding: 2vw;
+  background-color: #fff;
+  border-radius: 5px;
+}
+.main .two .list .name {
+  text-align: center;
+  font-size: 16px;
+  font-weight: bold;
+  margin: 0 0 1vw 0;
+}
+.main .two .list .name .status {
+  color: #ff0000;
+}
+.main .two .list .other_1 {
+  font-size: 14px;
+  color: #858585;
+  margin: 0 0 1vw 0;
+}
+.main .two .list .other_1 text:last-child {
+  color: #000000;
+}
+.main .two .list .money {
+  color: #ff0000;
+  font-size: 14px;
+  font-weight: bold;
+  text-align: center;
+  margin: 0 0 2vw 0;
+}
+.main .two .list .btn {
+  text-align: center;
+}
+.main .two .list .btn button {
+  margin: 0 2vw 2vw 2vw;
+  font-size: 14px;
+}
+.main .two .list:last-child {
+  margin: 0 2vw 0 2vw;
+}
+.scroll-view {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  bottom: 0;
+}
+.scroll-view .list-scroll-view {
+  display: flex;
+  flex-direction: column;
+}