guhongwei 2 năm trước cách đây
mục cha
commit
42741b8a8e

+ 3 - 3
pages/coaAdmin/course/add.js

@@ -66,9 +66,9 @@ Page({
             wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
             return false
         } else {
-            params.time_start = params.start_date + '-' + params.start_time;
-            params.time_end = params.end_date + '-' + params.end_time;
-            params.refund_hour = params.refund_date + '-' + params.refund_time;
+            params.time_start = params.start_date + ' ' + params.start_time;
+            params.time_end = params.end_date + ' ' + params.end_time;
+            params.refund_hour = params.refund_date + ' ' + params.refund_time;
             let arr;
             if (params._id) { arr = await app.$post(`/lesson/${params._id}`, params) }
             else { arr = await app.$post(`/lesson`, params) }

+ 8 - 0
pages/coaAdmin/course/info.wxml

@@ -66,6 +66,10 @@
                                     <text>所属学校:</text>
                                     <text>{{item.school_id_name||'暂无'}}</text>
                                 </view>
+                                <view class="other_1">
+                                    <text>是否签到:</text>
+                                    <text>{{item.is_sign=='0'?'未签到':'已签到'}}</text>
+                                </view>
                             </view>
                         </view>
                     </view>
@@ -89,6 +93,10 @@
                                     <text>所属学院:</text>
                                     <text>{{item.school_id_name||'暂无'}}</text>
                                 </view>
+                                <view class="other_1">
+                                    <text>是否签到:</text>
+                                    <text>{{item.is_sign=='0'?'未签到':'已签到'}}</text>
+                                </view>
                             </view>
                         </view>
                     </view>

+ 19 - 1
pages/coaAdmin/course/list.js

@@ -7,6 +7,7 @@ Page({
      */
     data: {
         frameStyle: { useTop: true, name: '课程列表', leftArrow: true, useBar: false },
+        user: {},
         list: [],
         total: 0,
         page: 0,
@@ -28,6 +29,22 @@ Page({
         that.setData({ skip: 0, page: 0, list: [] });
         wx.navigateTo({ url: `/pages/${route}?id=${item && item._id ? item._id : ''}` })
     },
+    // 签到
+    toSign: async function (e) {
+        const that = this;
+        const user = that.data.user;
+        const { item } = e.currentTarget.dataset;
+        let arr;
+        arr = await app.$get(`/lessonCoach`, { school_id: item.school_id, lesson_id: item._id, coach_id: user.info._id });
+        if (arr.errcode == '0' && arr.total > 0) {
+            arr = await app.$post(`/lessonCoach/${arr.data[0]._id}`, { is_sign: '1' });
+            if (arr.errcode == '0') {
+                wx.showToast({ title: `签到成功`, icon: 'error', duration: 2000 })
+                that.watchLogin();
+            } else { wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 }) }
+        }
+        console.log(arr);
+    },
     // 分页
     toPage: function () {
         const that = this;
@@ -86,6 +103,7 @@ Page({
         wx.getStorage({
             key: 'user',
             success: async res => {
+                that.setData({ user: res.data })
                 let info = { skip: that.data.skip, limit: that.data.limit };
                 let arr = await app.$get(`/lesson`, { ...info });
                 if (arr.errcode == '0') {
@@ -95,7 +113,7 @@ Page({
                         let type = typeList.find(i => i.value == val.type);
                         if (type) val.zhType = type.label;
                         // 课程状态
-                        let status = statusList.find(i => i.value == val.type);
+                        let status = statusList.find(i => i.value == val.status);
                         if (status) val.zhStatus = status.label;
                     }
                     that.setData({ list: list })

+ 1 - 0
pages/coaAdmin/course/list.wxml

@@ -23,6 +23,7 @@
                             <button size="mini" type="primary" bindtap="toCommon" data-item="{{item}}" data-route="coaAdmin/course/coachlist" wx:if="{{item.type=='1'}}">教练信息</button>
                             <button size="mini" type="primary" bindtap="toCommon" data-item="{{item}}" data-route="coaAdmin/course/add" wx:if="{{item.type=='1'}}">信息维护</button>
                             <button size="mini" type="primary" bindtap="toCommon" data-item="{{item}}" data-route="coaAdmin/course/statuslist" wx:if="{{item.type=='1'}}">临时添加学员</button>
+                            <button size="mini" type="primary" bindtap="toSign" data-item="{{item}}" wx:if="{{item.status=='3'}}">签到</button>
                         </view>
                     </view>
                 </view>

+ 83 - 7
pages/coaAdmin/course/statusadd.js

@@ -1,5 +1,7 @@
 const app = getApp()
 import WxValidate from '../../../utils/wxValidate';
+const moment = require("../../../utils/moment.min");
+import QRCode from '../../../utils/weapp-qrcode.js';
 Page({
     data: {
         frameStyle: { useTop: true, name: '信息维护', leftArrow: true, useBar: false },
@@ -10,7 +12,18 @@ Page({
         schoolInfo: {},
         // 学生列表
         studentList: [],
-
+        // 学生信息
+        studentInfo: {},
+        // 试课申请信息
+        elaInfo: {},
+        // 二维码信息
+        tpnInfo: {},
+        // 打折信息
+        lstInfo: {},
+        // dialog弹框
+        dialog: { title: '支付二维码', show: false, type: '1' },
+        // 是否支付成功
+        pay_status: ''
     },
     initValidate() {
         const rules = { student_id: { required: true }, money: { required: true }, img_url: { required: true } }
@@ -23,12 +36,28 @@ Page({
         wx.navigateBack({ delta: 1 })
     },
     // 选择学生
-    stuChange: function (e) {
+    stuChange: async function (e) {
         const that = this;
         let data = that.data.studentList[e.detail.value];
         if (data) {
             that.setData({ 'form.student_id': data.student_id })
-            that.setData({ 'form.student_id_name': data.student_id_name })
+            that.setData({ 'form.student_id_name': data.student_id_name });
+            // 查询学生信息
+            let studentInfo = {};
+            let student = await app.$get(`/student/${data.student_id}`);
+            if (student.errcode == '0') {
+                let user = await app.$get(`/user/${student.data.user_id}`);
+                if (user.errcode == '0') {
+                    studentInfo = { ...user.data, info: { ...student.data } }
+                    that.setData({ studentInfo })
+                }
+            }
+            // 查询真实付款金额
+            const arr = await app.$post(`/lessonStudent/toComputed`, { lesson_id: that.data.lesson_id, student_id: data.student_id });
+            if (arr.errcode == '0') {
+                that.setData({ 'form.money': arr.data.real_money });
+                that.setData({ lstInfo: arr.data })
+            }
         }
     },
     imgUpl: function (e) {
@@ -49,14 +78,61 @@ Page({
         const that = this;
         const params = e.detail.value;
         const form = that.data.form;
-        form.img_url = form.img_url;
+        params.img_url = form.img_url;
+        const studentInfo = that.data.studentInfo;
+        const schoolInfo = that.data.schoolInfo;
+        const lstInfo = that.data.lstInfo;
         if (!this.WxValidate.checkForm(params)) {
             const error = this.WxValidate.errorList[0];
             wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 })
             return false
         } else {
-            console.log(params);
-            //  config: { type: Object, required: false, zh: '设置' }, // 打折方式 discount_type:fixed 固定;subtract 减; discount折 ;number
+            // 创建试课信息;创建二维码信息;支付信息;查询支付状态;支付成功;
+            const arr = await app.$post(`/tempLessonApply`, params);
+            if (arr.errcode == '0') {
+                that.setData({ elaInfo: arr.data });
+                let obj = { school_id: params.school_id, pay_for: 'tempLessonApply', from_id: that.data.elaInfo._id, money: params.money, time: moment().format('YYYY-MM-DD HH:mm:ss'), desc: '临时上课申请', config: lstInfo.config };
+                const one = await app.$post(`/payOrder/toPayNative`, obj);
+                if (one.errcode == '0') {
+                    that.setData({ tpnInfo: JSON.parse(one.data) });
+                    // 生成支付二维码
+                    that.makeQRCode();
+                    that.setData({ dialog: { title: '支付二维码', show: true, type: '1' } });
+                }
+            } else {
+                wx.showToast({ title: `${arr.errmsg}`, icon: 'error', duration: 2000 })
+            }
+        }
+    },
+    makeQRCode(template = 0) {
+        const that = this;
+        const url = `${that.data.tpnInfo.code_url}`;
+        var qrcode = new QRCode(`myQrcode`, {
+            text: url,
+            width: 110,
+            height: 110,
+            padding: 3,
+            colorDark: "#000000",
+            colorLight: "#ffffff",
+            correctLevel: QRCode.CorrectLevel.L,
+        });
+    },
+    // 关闭弹框
+    toClose: function () {
+        const that = this;
+        that.setData({ dialog: { title: '支付二维码', show: false, type: '1' } })
+    },
+    // 查询支付状态
+    searchS: async function () {
+        const that = this;
+        const elaInfo = that.data.elaInfo;
+        let arr;
+        arr = await app.$get(`/tempLessonApply/${elaInfo._id}`);
+        if (arr.errcode == '0') {
+            arr = await app.$get(`/payOrder/${arr.data.pay_id}`);
+            if (arr.errcode == '0') {
+                that.setData({ pay_status: arr.data.status })
+            }
         }
     },
     /**
@@ -85,7 +161,7 @@ Page({
                 arr = await app.$get(`/rcs`, { coach_id: data.info.id });
                 if (arr.errcode == '0' && arr.total > 0) that.setData({ schoolInfo: arr.data[0] });
                 let form = { school_id: that.data.schoolInfo.school_id, lesson_id: that.data.lesson_id, coach_id: data.info._id, img_url: [] };
-                that.setData({ form })
+                that.setData({ form });
             },
             fail: async res => {
                 wx.redirectTo({ url: '/pages/index/index' })

+ 29 - 0
pages/coaAdmin/course/statusadd.less

@@ -31,4 +31,33 @@
             }
         }
     }
+}
+
+.dialog {
+    .dialog_1 {
+        .name {
+            text-align: center;
+            font-size: var(--font18Szie);
+            font-weight: bold;
+            margin: 3vw 0;
+        }
+
+        .image {
+            text-align: center;
+            height: 18vh;
+            overflow: hidden;
+
+            .qrcode {
+                height: 22vh;
+                position: absolute;
+                left: 32vw;
+            }
+        }
+
+        .remark {
+            text-align: center;
+            font-size: 15px;
+            margin: 0 0 4vw 0;
+        }
+    }
 }

+ 7 - 5
pages/coaAdmin/course/statusadd.wxml

@@ -31,7 +31,7 @@
                 <view class="content">
                     <view class="label">课程费用:</view>
                     <view class="value">
-                        <input type="number" name="money" value="{{form.money}}" placeholder="请输入课程费用" />
+                        <input type="number" name="money" value="{{form.money}}" placeholder="请输入课程费用" disabled/>
                     </view>
                 </view>
                 <view class="content">
@@ -47,14 +47,16 @@
         </view>
     </view>
 </mobile-main>
-<!-- <dialog dialog="{{dialog}}" bind:toClose="toClose">
+<dialog dialog="{{dialog}}" bind:toClose="toClose">
     <view slot="info" class="dialog">
         <view class="dialog_1" wx:if="{{dialog.type=='1'}}">
-            <view class="name">{{form.name}}</view>
             <view class="image">
                 <canvas class="qrcode" canvas-id="myQrcode"></canvas>
             </view>
-            <view class="remark">用户可扫描二维码进行缴费</view>
+            <view class="remark">
+                <button type="primary" size="mini" bindtap="searchS">查询支付状态</button>
+                <view>支付状态:{{pay_status=='0'?'未支付':pay_status=='1'?'已支付':pay_status=='-1'?'支付失败':pay_status=='2'?'已退款':'暂无'}}</view>
+            </view>
         </view>
     </view>
-</dialog> -->
+</dialog>

+ 21 - 0
pages/coaAdmin/course/statusadd.wxss

@@ -25,3 +25,24 @@
   margin: 0 2vw;
   padding: 1vw 0;
 }
+.dialog .dialog_1 .name {
+  text-align: center;
+  font-size: var(--font18Szie);
+  font-weight: bold;
+  margin: 3vw 0;
+}
+.dialog .dialog_1 .image {
+  text-align: center;
+  height: 18vh;
+  overflow: hidden;
+}
+.dialog .dialog_1 .image .qrcode {
+  height: 22vh;
+  position: absolute;
+  left: 32vw;
+}
+.dialog .dialog_1 .remark {
+  text-align: center;
+  font-size: 15px;
+  margin: 0 0 4vw 0;
+}

+ 4 - 7
pages/coaAdmin/course/statuslist.wxml

@@ -12,14 +12,11 @@
             <scroll-view scroll-y="true" class="scroll-view" bindscrolltolower="toPage">
                 <view class="list-scroll-view">
                     <view class="list" wx:for="{{list}}" wx:key="item">
-                        <view class="name">{{item.title}}</view>
+                        <view class="name">{{item.student_id_name}}</view>
                         <view class="other">
-                            <view class="other_1"><text>课程时间:</text><text>{{item.time_start}}至{{item.time_end}}</text></view>
-                            <view class="other_1"><text>课程类型:</text><text>{{item.zhType}}</text></view>
-                            <view class="other_1"><text>审核状态:</text><text>{{item.zhStatus}}</text></view>
-                        </view>
-                        <view class="btn">
-                            <button>信息维护</button>
+                            <view class="other_1"><text>课程名称:</text><text>{{item.lesson_id_title}}</text></view>
+                            <view class="other_1"><text>学校名称:</text><text>{{item.school_id_name}}</text></view>
+                            <view class="other_1"><text>支付金额:</text><text>{{item.money}}元</text></view>
                         </view>
                     </view>
                 </view>

+ 7 - 1
pages/school/index.js

@@ -1,4 +1,5 @@
 const app = getApp()
+const moment = require("../../utils/moment.min")
 Page({
     data: {
         frameStyle: { useTop: true, name: '羽校', leftArrow: false, useBar: true },
@@ -45,7 +46,12 @@ Page({
     /**
      * 生命周期函数--监听页面加载
      */
-    onLoad: function (options) { },
+    onLoad: function (options) {
+        let two = '2022-08-23 15:00';
+        let isBefore = moment().isBefore(two)
+        console.log(isBefore);
+
+    },
     /**
      * 生命周期函数--监听页面初次渲染完成
      */