guhongwei преди 2 години
родител
ревизия
3760294906

+ 2 - 1
app.json

@@ -48,7 +48,8 @@
                 "superAdmin/user/add",
                 "superAdmin/dict/add",
                 "schAdmin/coach/add",
-                "schAdmin/student/add"
+                "schAdmin/student/add",
+                "schAdmin/course/add"
             ]
         },
         {

+ 18 - 2
pagesSchool/schAdmin/coach/list.js

@@ -15,7 +15,8 @@ Page({
         page: 0,
         // dialog弹框
         dialog: { title: '账号绑定', show: false, type: '1' },
-        form: {}
+        form: {},
+        levelList: []
     },
     // 跳转菜单
     back(e) {
@@ -119,6 +120,8 @@ Page({
      */
     onShow: async function () {
         const that = this;
+        // 查询其他信息
+        await that.searchOther();
         // 监听用户是否登录
         await that.watchLogin();
     },
@@ -131,6 +134,7 @@ Page({
                 const arr = await app.$get(`/rcs`, { ...info });
                 if (arr.errcode == '0') {
                     let list = [...that.data.list, ...arr.data];
+                    for (const val of list) { val.coach_id_zhlevel = that.searchLevel(val.coach_id_level); }
                     that.setData({ list });
                     that.setData({ total: arr.total });
                 }
@@ -141,6 +145,11 @@ Page({
             }
         })
     },
+    searchLevel(e) {
+        const that = this;
+        let data = that.data.levelList.find(i => i.value == e);
+        if (data) return data.label
+    },
     // 分页
     toPage: function () {
         const that = this;
@@ -156,7 +165,14 @@ Page({
             wx.hideLoading()
         } else { wx.showToast({ title: '没有更多数据了', icon: 'none', duration: 2000 }) }
     },
-
+    // 查询其他信息
+    async searchOther() {
+        const that = this;
+        let res;
+        // 运动等级
+        res = await app.$get(`/dict`, { code: 'coach_grade' });
+        if (res.errcode == '0' && res.total > 0) that.setData({ levelList: res.data[0].list })
+    },
     /**
      * 生命周期函数--监听页面隐藏
      */

+ 1 - 1
pagesSchool/schAdmin/coach/list.wxml

@@ -22,7 +22,7 @@
                                     <text>联系电话:{{item.coach_id_phone||'暂无'}}</text>
                                 </view>
                                 <view class="other_1">
-                                    <text>教练等级:{{item.coach_id_level||'暂无'}}</text>
+                                    <text>教练等级:{{item.coach_id_zhlevel||'暂无'}}</text>
                                 </view>
                             </view>
                         </view>

+ 167 - 0
pagesSchool/schAdmin/course/add.js

@@ -0,0 +1,167 @@
+const app = getApp()
+import WxValidate from '../../../utils/wxValidate'
+
+Page({
+
+    /**
+     * 页面的初始数据
+     */
+    data: {
+        frameStyle: { useTop: true, name: '课程信息', leftArrow: true, useBar: false },
+        id: '',
+        school_id: '',
+        form: {},
+        // 状态列表
+        statusList: [],
+    },
+    initValidate() {
+        const rules = { title: { required: true }, brief: { required: true }, limit: { required: true }, money: { required: true }, time_start: { required: true }, time_end: { required: true }, refund_hour: { required: true } }
+        // 验证字段的提示信息,若不传则调用默认的信息
+        const messages = { title: { required: '课程标题', }, brief: { required: '课程简介', }, limit: { required: '人数上限', }, money: { required: '课程费用', }, time_start: { required: '上课开始时间', }, time_end: { required: '上课结束时间', }, refund_hour: { required: '可退课时间', } };
+        this.WxValidate = new WxValidate(rules, messages)
+    },
+    // 返回
+    back: function () {
+        wx.navigateBack({ delta: 1 })
+    },
+    // 选择状态
+    statusChange: function (e) {
+        const that = this;
+        let data = that.data.statusList[e.detail.value];
+        if (data) {
+            that.setData({ 'form.status': data.value });
+            that.setData({ 'form.zhstatus': data.label });
+        }
+    },
+    // 时间确定选择
+    datetimeChange: function (e) {
+        const that = this;
+        that.setData({ [`form.${e.detail.name}`]: e.detail.datetime });
+    },
+    // 提交保存
+    onSubmit: async function (e) {
+        const that = this;
+        const params = e.detail.value;
+        let form = that.data.form;
+        params.school_id = that.data.school_id;
+        params.time_start = form.time_start;
+        params.time_end = form.time_end;
+        params.refund_hour = form.refund_hour;
+        if (!this.WxValidate.checkForm(params)) {
+            const error = this.WxValidate.errorList[0];
+            wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
+            return false
+        } else {
+            let res;
+            if (form._id) { res = await app.$post(`/lesson/${form._id}`, params); }
+            else { res = await app.$post(`/lesson`, params); }
+            if (res.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); }
+            else wx.showToast({ title: res.errmsg, icon: 'error', duration: 2000 })
+        }
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad: function (options) {
+        const that = this;
+        that.setData({ id: options.id || '' })
+        //验证规则函数
+        that.initValidate();
+        // 监听用户是否登录
+        that.watchLogin();
+    },
+    // 监听用户是否登录
+    watchLogin: async function () {
+        const that = this;
+        wx.getStorage({
+            key: 'user',
+            success: async res => {
+                that.setData({ school_id: res.data.info.id });
+                await that.searchOther();
+                await that.searchInfo()
+            },
+            fail: res => {
+                wx.redirectTo({ url: '/pages/index/index', })
+            }
+        })
+    },
+    // 查询详细信息
+    async searchInfo() {
+        const that = this;
+        let id = that.data.id;
+        if (id) {
+            let res = await app.$get(`/lesson/${id}`);
+            if (res.errcode == '0') {
+                let form = res.data;
+                form.zhstatus = that.searchStatus(form.status);
+                that.setData({ form })
+            } else {
+                wx.showToast({
+                    title: res.errmsg,
+                    icon: 'none'
+                })
+            }
+        }
+    },
+    searchStatus(e) {
+        const that = this;
+        let data = that.data.statusList.find(i => i.value == e);
+        if (data) return data.label
+    },
+    // 查询其他信息
+    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 });
+    },
+    /**
+     * 生命周期函数--监听页面初次渲染完成
+     */
+    onReady: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面显示
+     */
+    onShow: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面隐藏
+     */
+    onHide: function () {
+
+    },
+
+    /**
+     * 生命周期函数--监听页面卸载
+     */
+    onUnload: function () {
+
+    },
+
+    /**
+     * 页面相关事件处理函数--监听用户下拉动作
+     */
+    onPullDownRefresh: function () {
+
+    },
+
+    /**
+     * 页面上拉触底事件的处理函数
+     */
+    onReachBottom: function () {
+
+    },
+
+    /**
+     * 用户点击右上角分享
+     */
+    onShareAppMessage: function () {
+
+    }
+})

+ 7 - 0
pagesSchool/schAdmin/course/add.json

@@ -0,0 +1,7 @@
+{
+    "component": true,
+    "usingComponents": {
+        "mobile-main": "/commpents/mobile-frame/index",
+        "datatime-picker": "/commpents/datetime-picker/index"
+    }
+}

+ 37 - 0
pagesSchool/schAdmin/course/add.less

@@ -0,0 +1,37 @@
+@import (css) "/app.wxss";
+
+.main {
+    background-color: var(--mainColor);
+
+    .one {
+        .content {
+            display: flex;
+            flex-direction: row;
+            border-bottom: 1px dashed var(--f1Color);
+            padding: 2vw 0;
+            margin: 0 2vw 2vw 2vw;
+
+            .value {
+                flex-grow: 1;
+                color: var(--blackColor);
+
+                textarea {
+                    width: 100%;
+                    height: 120px;
+                }
+
+            }
+        }
+
+        .btn {
+            text-align: center;
+            margin: 5vw 0 0 0;
+
+            button {
+                width: 40vw;
+                margin: 0 2vw;
+                padding: 1vw 0;
+            }
+        }
+    }
+}

+ 62 - 0
pagesSchool/schAdmin/course/add.wxml

@@ -0,0 +1,62 @@
+<mobile-main frameStyle="{{frameStyle}}" bind:back="back">
+    <view slot="info" class="container main">
+        <view class="one">
+            <form catchsubmit="onSubmit">
+                <view class="content">
+                    <view class="label">课程标题:</view>
+                    <view class="value">
+                        <input name="title" value="{{form.title}}" placeholder="请输入课程标题" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">课程简介:</view>
+                    <view class="value">
+                        <textarea maxlength="500" name="brief" value="{{form.brief}}" placeholder="请输入课程简介" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">人数上限:</view>
+                    <view class="value">
+                        <input name="limit" type="number" value="{{form.limit}}" placeholder="请输入人数上限" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">课程费:</view>
+                    <view class="value">
+                        <input name="money" type="number" value="{{form.money}}" placeholder="请输入课程费" />
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">上课开始时间:</view>
+                    <view class="value">
+                        <datatime-picker datetime="{{form.time_start}}" name="time_start" bind:datetimeChange="datetimeChange"></datatime-picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">上课结束时间:</view>
+                    <view class="value">
+                        <datatime-picker datetime="{{form.time_end}}" name="time_end" bind:datetimeChange="datetimeChange"></datatime-picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">可退课时间:</view>
+                    <view class="value">
+                        <datatime-picker datetime="{{form.refund_hour}}" name="refund_hour" bind:datetimeChange="datetimeChange"></datatime-picker>
+                    </view>
+                </view>
+                <view class="content">
+                    <view class="label">状态:</view>
+                    <view class="value">
+                        <picker mode="selector" bindchange="statusChange" name="status" value="{{form.status}}" range="{{statusList}}" range-key="label">
+                            <view class="picker">{{form.zhstatus||'请选择状态'}}</view>
+                        </picker>
+                    </view>
+                </view>
+
+                <view class="btn">
+                    <button type="primary" size="mini" formType="submit">提交保存</button>
+                </view>
+            </form>
+        </view>
+    </view>
+</mobile-main>

+ 28 - 0
pagesSchool/schAdmin/course/add.wxss

@@ -0,0 +1,28 @@
+@import "/app.wxss";
+.main {
+  background-color: var(--mainColor);
+}
+.main .one .content {
+  display: flex;
+  flex-direction: row;
+  border-bottom: 1px dashed var(--f1Color);
+  padding: 2vw 0;
+  margin: 0 2vw 2vw 2vw;
+}
+.main .one .content .value {
+  flex-grow: 1;
+  color: var(--blackColor);
+}
+.main .one .content .value textarea {
+  width: 100%;
+  height: 120px;
+}
+.main .one .btn {
+  text-align: center;
+  margin: 5vw 0 0 0;
+}
+.main .one .btn button {
+  width: 40vw;
+  margin: 0 2vw;
+  padding: 1vw 0;
+}

+ 111 - 4
pagesSchool/schAdmin/course/list.js

@@ -5,12 +5,69 @@ 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.title': value })
+        else that.setData({ search: {} })
+        that.clearPage(); that.watchLogin();
+    },
+    // 清空列表
+    clearPage() {
+        const that = this;
+        that.setData({ list: [], skip: 0, limit: 6, page: 0 })
+    },
+    // 添加
+    toAdd() {
+        const that = this;
+        that.clearPage();
+        wx.navigateTo({
+            url: `/pagesSchool/schAdmin/course/add`,
+        })
+    },
+    // 修改
+    toEdit: function (e) {
+        const that = this;
+        let { item } = e.currentTarget.dataset;
+        that.clearPage();
+        wx.navigateTo({ url: `/pagesSchool/schAdmin/course/add?id=${item.id}` })
+    },
+    // 删除
+    toDel: async function (e) {
+        const that = this;
+        const { item } = e.currentTarget.dataset;
+        wx.showModal({
+            title: '提示',
+            content: '是否确认删除该条数据?',
+            async success(res) {
+                if (res.confirm) {
+                    const arr = await app.$delete(`/lesson/${item.id}`);
+                    if (arr.errcode == '0') {
+                        wx.showToast({ title: `删除信息成功`, icon: 'success', duration: 2000 })
+                        that.clearPage();
+                        that.watchLogin()
+                    } else {
+                        wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
+                    }
+                }
+            }
+        })
+    },
     /**
      * 生命周期函数--监听页面加载
      */
@@ -27,11 +84,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(`/lesson`, { ...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.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 });
     },
-
 
     /**
      * 生命周期函数--监听页面隐藏

+ 2 - 1
pagesSchool/schAdmin/course/list.json

@@ -1,6 +1,7 @@
 {
     "component": true,
     "usingComponents": {
-        "mobile-main": "/commpents/mobile-frame/index"
+        "mobile-main": "/commpents/mobile-frame/index",
+        "dialog": "/commpents/dialog/index"
     }
 }

+ 97 - 1
pagesSchool/schAdmin/course/list.less

@@ -1 +1,97 @@
-@import (css) "/app.wxss";
+@import (css) "/app.wxss";
+
+.main {
+    height: 91vh;
+
+    .one {
+        display: flex;
+        padding: 2vw;
+        border-bottom: 1px solid #858585;
+        margin: 0 0 2vw 0;
+
+        .one_1 {
+            flex-grow: 1;
+
+            input {
+                padding: 2vw;
+                font-size: 12px;
+                border-radius: 5px;
+                background-color: #fff;
+            }
+        }
+
+        .one_2 {
+            button {
+                line-height: 2.6;
+                font-size: 14px;
+            }
+        }
+    }
+
+    .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;
+                    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;
+    }
+}

+ 35 - 1
pagesSchool/schAdmin/course/list.wxml

@@ -1,5 +1,39 @@
 <mobile-main frameStyle="{{frameStyle}}" bind:back="back">
     <view slot="info" class="container main">
-        <view>课程管理</view>
+        <view class="one">
+            <view class="one_1">
+                <input type="text" value="{{search.title}}" bindconfirm="toInput" placeholder="请输入关键词" />
+            </view>
+            <view class="one_2">
+                <button type="primary" size="mini" bindtap="toAdd">添加</button>
+            </view>
+        </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.title}}
+                            <text class="status">[{{item.zhStatus}}]</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.refund_hour}}</text>
+                        </view>
+                        <view class="money">
+                            <text>¥</text>
+                            <text>{{item.money}}</text>
+                        </view>
+                        <view class="btn">
+                            <button type="primary" size="mini" bindtap="toEdit" data-item="{{item}}">信息维护</button>
+                            <button type="warn" size="mini" bindtap="toDel" data-item="{{item}}">删除信息</button>
+                        </view>
+                    </view>
+                </view>
+            </scroll-view>
+        </view>
     </view>
 </mobile-main>

+ 77 - 0
pagesSchool/schAdmin/course/list.wxss

@@ -1 +1,78 @@
 @import "/app.wxss";
+.main {
+  height: 91vh;
+}
+.main .one {
+  display: flex;
+  padding: 2vw;
+  border-bottom: 1px solid #858585;
+  margin: 0 0 2vw 0;
+}
+.main .one .one_1 {
+  flex-grow: 1;
+}
+.main .one .one_1 input {
+  padding: 2vw;
+  font-size: 12px;
+  border-radius: 5px;
+  background-color: #fff;
+}
+.main .one .one_2 button {
+  line-height: 2.6;
+  font-size: 14px;
+}
+.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;
+  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;
+}

+ 1 - 4
pagesSchool/schAdmin/student/list.js

@@ -135,10 +135,7 @@ Page({
                 const arr = await app.$get(`/rss`, { ...info });
                 if (arr.errcode == '0') {
                     let list = [...that.data.list, ...arr.data];
-                    for (const val of list) {
-                        // 等级
-                        val.student_id_zhlevel = that.searchLevel(val.student_id_level);
-                    }
+                    for (const val of list) { val.student_id_zhlevel = that.searchLevel(val.student_id_level); }
                     that.setData({ list });
                     that.setData({ total: arr.total });
                 }

+ 2 - 1
project.config.json

@@ -45,7 +45,8 @@
         "disableUseStrict": false,
         "minifyWXML": true,
         "showES6CompileOption": false,
-        "useCompilerPlugins": false
+        "useCompilerPlugins": false,
+        "ignoreUploadUnusedFiles": true
     },
     "compileType": "miniprogram",
     "libVersion": "2.19.4",