|
@@ -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') }
|
|
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)
|
|
const arr = await app.$post(`/payOrder`, obj)
|
|
if (arr.errcode == '0') {
|
|
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) => {
|
|
fail: async (res) => {
|
|
@@ -138,7 +148,6 @@ Page({
|
|
if (school.errcode == '0') arr.data.zhSchool = school.data.name;
|
|
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 })
|
|
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';
|
|
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 })
|
|
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';
|
|
if (lessonStudent.errcode == '0') arr.data.sign = '0';
|
|
else arr.data.sign = '1';
|
|
else arr.data.sign = '1';
|