zs %!s(int64=2) %!d(string=hai) anos
pai
achega
70b3922b42
Modificáronse 2 ficheiros con 44 adicións e 27 borrados
  1. 14 6
      pages/stuAdmin/course/list.js
  2. 30 21
      pages/stuAdmin/course/sign.js

+ 14 - 6
pages/stuAdmin/course/list.js

@@ -44,12 +44,20 @@ Page({
         const that = this;
         const user = that.data.user;
         const { item } = e.currentTarget.dataset;
-        let toRefund = await app.$post(`/lessonStudent/toRefund`, { student_id: user.info.id, lesson_id: item._id });
-        if (toRefund.errcode == '0') {
-            wx.showToast({ title: `退课成功 钱返回余额中`, icon: 'success', duration: 2000 });
-            that.setData({ skip: 0, page: 0, list: [] })
-            that.watchLogin();
-        } else wx.showToast({ title: `${toRefund.errmsg}`, icon: 'none', duration: 2000 })
+        wx.showModal({
+            title: '提示',
+            content: '您是否确定退课?',
+            async success(res) {
+                if (res.confirm) {
+                    let toRefund = await app.$post(`/lessonStudent/toRefund`, { student_id: user.info.id, lesson_id: item._id });
+                    if (toRefund.errcode == '0') {
+                        wx.showToast({ title: `退课成功`, icon: 'success', duration: 2000 });
+                        that.setData({ skip: 0, page: 0, list: [] })
+                        that.watchLogin();
+                    } else wx.showToast({ title: `${toRefund.errmsg}`, icon: 'none', duration: 2000 })
+                } else if (res.cancel) { }
+            }
+        });
     },
     // 签到
     toSign: async function (e) {

+ 30 - 21
pages/stuAdmin/course/sign.js

@@ -71,26 +71,36 @@ Page({
                             let obj = { openid: res.data.openid, money: money, school_id: form.school_id, payer_id: user.info.id, payer_role: 'Student', pay_for: 'lessonStudent', time: moment().format('YYYY-MM-DD HH:mm:ss') }
                             const arr = await app.$post(`/payOrder`, obj)
                             if (arr.errcode == '0') {
-                                wx.requestPayment({
-                                    "timeStamp": arr.data.wxSign.timestamp,
-                                    "nonceStr": arr.data.wxSign.nonceStr,
-                                    "package": `prepay_id=${arr.data.wxSign.prepay_id}`,
-                                    "signType": arr.data.wxSign.signType,
-                                    "paySign": arr.data.wxSign.paySign,
-                                    "success": async function (res) {
-                                        let params = { school_id: form.school_id, lesson_id: form._id, student_id: user.info.id, money: money, is_try: that.data.is_try, pay_id: arr.data.data._id, is_pay: '1' }
-                                        let lessonStudent = await app.$post(`/lessonStudent`, params);
-                                        if (lessonStudent.errcode == '0') {
-                                            wx.showToast({ title: `报名申请完成`, icon: 'success', duration: 2000 });
-                                            const pay = await app.$post(`/payOrder/${arr.data.data._id}`, { from_id: lessonStudent.data._id, status: '1' });
-                                            if (pay.errcode == '0') that.watchLogin();
-                                        }
-                                        else wx.showToast({ title: `${lessonStudent.errmsg}`, icon: 'error', duration: 2000 })
-                                    },
-                                    "fail": async function (res) {
-                                        const pay = await app.$delete(`/payOrder/${arr.data.data._id}`);
-                                    },
-                                })
+                                if (arr?.data?.wxSign) {
+                                    wx.requestPayment({
+                                        "timeStamp": arr.data.wxSign.timestamp,
+                                        "nonceStr": arr.data.wxSign.nonceStr,
+                                        "package": `prepay_id=${arr.data.wxSign.prepay_id}`,
+                                        "signType": arr.data.wxSign.signType,
+                                        "paySign": arr.data.wxSign.paySign,
+                                        "success": async function (res) {
+                                            let params = { school_id: form.school_id, lesson_id: form._id, student_id: user.info.id, money: money, is_try: that.data.is_try, pay_id: arr.data.data._id, is_pay: '1' }
+                                            let lessonStudent = await app.$post(`/lessonStudent`, params);
+                                            if (lessonStudent.errcode == '0') {
+                                                wx.showToast({ title: `报名申请完成`, icon: 'success', duration: 2000 });
+                                                const pay = await app.$post(`/payOrder/${arr.data.data._id}`, { from_id: lessonStudent.data._id, status: '1' });
+                                                if (pay.errcode == '0') that.watchLogin();
+                                            }
+                                            else wx.showToast({ title: `${lessonStudent.errmsg}`, icon: 'error', duration: 2000 })
+                                        },
+                                        "fail": async function (res) {
+                                            const pay = await app.$delete(`/payOrder/${arr.data.data._id}`);
+                                        },
+                                    })
+                                } else {
+                                    let params = { school_id: form.school_id, lesson_id: form._id, student_id: user.info.id, money: money, is_try: that.data.is_try, is_pay: '1' }
+                                    let lessonStudent = await app.$post(`/lessonStudent`, params);
+                                    if (lessonStudent.errcode == '0') {
+                                        wx.showToast({ title: `报名申请完成 从余额扣除`, icon: 'none', duration: 2000 });
+                                        that.watchLogin();
+                                    }
+                                    else wx.showToast({ title: `${lessonStudent.errmsg}`, icon: 'error', duration: 2000 })
+                                }
                             }
                         },
                         fail: async (res) => {
@@ -138,7 +148,6 @@ Page({
                                 if (school.errcode == '0') arr.data.zhSchool = school.data.name;
                                 const lesson = await app.$post(`/tryLessonApply/checkCanUse`, { school_id: arr.data.school_id, lesson_id: that.data.id, student_id: res.data.info.id })
                                 if (lesson.errcode == '0') arr.data.type_try = '0';
-                                else wx.showToast({ title: `${lesson.errmsg}`, icon: 'none', duration: 2000 })
                                 const lessonStudent = await app.$post(`/lessonStudent/checkCanUse`, { school_id: arr.data.school_id, student_id: res.data.info.id, lesson_id: that.data.id })
                                 if (lessonStudent.errcode == '0') arr.data.sign = '0';
                                 else arr.data.sign = '1';