Browse Source

修改添加支付

lex 2 years ago
parent
commit
564530a442

+ 1 - 1
public/project/manageTeacher.html

@@ -104,7 +104,7 @@
         <div class="submit-container">
           <p class="submit-title">恭喜您已成功登记为</p>
           <p class="submit-o">{{ decodeURI(name) }} <span>【管理老师】</span></p>
-          <p class="submit-tips">请下载管乐团管理端APP进行授课</p>
+          <p class="submit-tips">请下载管乐团管理端APP</p>
           <van-button type="primary" color="#64A9FF" block round @click="submitStatus = false">立即下载</van-button>
         </div>
       </div>

+ 2 - 0
src/school/companion-teacher/index.module.less

@@ -114,6 +114,8 @@
       font-weight: bold;
       color: #ffffff;
       text-shadow: 1px 1px 7px #f4672a;
+      max-width: 90%;
+      padding-left: 5%;
     }
 
     .codeName {

+ 1 - 1
src/school/companion-teacher/index.tsx

@@ -274,7 +274,7 @@ export default defineComponent({
           <div class={styles.codeContainer}>
             <div class={styles.codeImg}>
               <div class={styles.codeContent}>
-                <h2 class={styles.codeTitle}>{form.schoolName}</h2>
+                <h2 class={[styles.codeTitle, 'van-ellipsis']}>{form.schoolName}</h2>
                 <div class={styles.codeName}>邀请您成为乐团伴学老师</div>
 
                 <div class={styles.codeQr}>

+ 2 - 0
src/school/manage-teacher/index.module.less

@@ -58,6 +58,8 @@
       font-weight: bold;
       color: #ffffff;
       text-shadow: 1px 1px 7px #f4672a;
+      max-width: 90%;
+      padding-left: 5%;
     }
 
     .codeName {

+ 1 - 1
src/school/manage-teacher/index.tsx

@@ -178,7 +178,7 @@ export default defineComponent({
           <div class={styles.codeContainer}>
             <div class={styles.codeImg}>
               <div class={styles.codeContent}>
-                <h2 class={styles.codeTitle}>{form.schoolName}</h2>
+                <h2 class={[styles.codeTitle, 'van-ellipsis']}>{form.schoolName}</h2>
                 <div class={styles.codeName}>邀请您成为乐团管理老师</div>
 
                 <div class={styles.codeQr}>

+ 9 - 9
src/school/train-planning/component/practice/index.tsx

@@ -124,14 +124,14 @@ export default defineComponent({
             placeholder="请选择课程周次"
             readonly
             modelValue={weekFormat(forms.week)}
-            isLink
+            // isLink
             onClick={() => {
-              forms.weekStatus = true
+              // forms.weekStatus = true
 
-              // if (!forms.trainStartDate) {
-              //   showToast('请选择课程开始日期')
-              //   return
-              // }
+              if (!forms.trainStartDate) {
+                showToast('请选择课程开始日期')
+                return
+              }
             }}
           />
 
@@ -197,9 +197,9 @@ export default defineComponent({
               forms.calendarStatus = false
               forms.trainStartDate = date.selectedValues.join('-')
 
-              // const days = dayjs(forms.trainStartDate).day()
-              // const selectDays = weekdays[days === 0 ? 6 : days - 1]
-              // forms.week = selectDays.value
+              const days = dayjs(forms.trainStartDate).day()
+              const selectDays = weekdays[days === 0 ? 6 : days - 1]
+              forms.week = selectDays.value
             }}
           />
         </Popup>

+ 4 - 0
src/school/train-planning/component/standard/index.tsx

@@ -273,6 +273,10 @@ export default defineComponent({
             prevMonth={(date: Date) => getList(date)}
             onSelect={(date: any) => {
               forms.calendarStatus = false
+              console.log(date, 'data')
+              if (forms.trainStartDate == date) {
+                console.log('true ------')
+              }
               forms.trainStartDate = date
 
               const days = dayjs(date).day()

+ 2 - 2
src/student/main.ts

@@ -8,8 +8,8 @@ import 'normalize.css'
 import '../styles/index.less'
 
 
-import Vconsole from 'vconsole'
-const vconsole = new Vconsole()
+// import Vconsole from 'vconsole'
+// const vconsole = new Vconsole()
 const app = createApp(App)
 app.use(router)
 

+ 5 - 3
src/student/music-group/pre-apply/order-detail.tsx

@@ -18,7 +18,6 @@ import Payment from '@/views/adapay/payment'
 import { useRoute, useRouter } from 'vue-router'
 import OQrcode from '@/components/o-qrcode'
 import request from '../request-music'
-import item from '@/student/coupons/item'
 import { browser, moneyFormat } from '@/helpers/utils'
 import { state as baseState } from '@/state'
 
@@ -121,7 +120,7 @@ export default defineComponent({
 
     const getPaymentOrderStatus = async () => {
       // 循环查询订单
-      const orderNo = state.orderNo
+      // const orderNo = state.orderNo
       const orderTimer = setInterval(async () => {
         // 判断是否在当前路由,如果不是则清除定时器
         if (route.name != 'orderDetail') {
@@ -131,7 +130,10 @@ export default defineComponent({
         state.orderTimer = orderTimer
         try {
           const { data } = await request.post(
-            '/api-student/open/userOrder/paymentStatus/' + state.orderNo
+            '/api-student/open/userOrder/paymentStatus/' + state.orderNo,
+            {
+              hideLoading: true
+            }
           )
           console.log(data)
           if (data.status !== 'WAIT_PAY') {

+ 7 - 122
src/views/adapay/pay-define/index.tsx

@@ -47,20 +47,6 @@ export default defineComponent({
 
         console.log(data, 'payment')
         scanCodePay(data.reqParams)
-        // let payment = result.data
-        //           if (payment.status === "succeeded") {
-        //             this.scanCodePay(payment);
-        //           } else if (payment.status == "failed") {
-        //             this.browserStatus = false;
-        //             this.errorText = payment.error_msg;
-        //             document.title = "ERROR";
-        //           } else if (payment.status == "pending") {
-        //             this.$dialog.alert({
-        //               title: "提示",
-        //               message: "订单处理中...",
-        //               confirmButtonColor: "#269a93",
-        //             });
-        //           }
       } catch (e) {
         //
         console.log(e)
@@ -117,122 +103,21 @@ export default defineComponent({
             res.err_msg == 'get_brand_wcpay_request:cancel' ||
             res.err_msg == 'get_brand_wcpay_request:fail'
           ) {
-            alert('支付失败')
+            window.location.replace(
+              location.origin + '/orchestra-student/#/payment-result?orderNo=' + state.orderNo
+            )
           } else {
             // 使用以上方式判断前端返回,微信团队郑重提示:
             //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
-            alert('支付成功')
+            // alert('支付成功')
+            window.location.replace(
+              location.origin + '/orchestra-student/#/payment-result?orderNo=' + state.orderNo
+            )
           }
         }
       )
     }
 
-    //  getPayment: throttle(function() {
-    //   try {
-    //     if (!(parseFloat(this.amount) > 0)) {
-    //       this.$toast("f");
-    //       return;
-    //     }
-    //     removeAuthToken();
-    //     const returnUrl = this.returnUrl.replace(/\^\^/gi, "&");
-    //     let that = this,
-    //       payMap = {
-    //         orderNo: this.orderNo,
-    //         sign: this.sign,
-    //         amount: numeral(this.amount).format("0.00"),
-    //         payChannel: this.payType, // 支付渠道
-    //         orderBody: this.orderBody,
-    //         orderSubject: this.orderSubject,
-    //         tenantId: this.tenantId,
-    //         returnUrl: returnUrl,
-    //         notifyUrl: this.notifyUrl,
-    //         platform: this.platform,
-    //       };
-    //     // 判断是否是微信公众号支付
-    //     if (this.payType == "wx_pub") {
-    //       payMap.code = this.code;
-    //     }
-    //     this.$toast.loading({
-    //       duration: 0,
-    //       message: "加载中...",
-    //       forbidClick: true,
-    //     });
-    //     console.log(payMap);
-    //     executePayment(payMap)
-    //       .then((res) => {
-    //         this.$toast.clear();
-    //         let result = res.data;
-    //         if (result.code == 200) {
-    //           let payment = result.data;
-    //           if (payment.status === "succeeded") {
-    //             this.scanCodePay(payment);
-    //           } else if (payment.status == "failed") {
-    //             this.browserStatus = false;
-    //             this.errorText = payment.error_msg;
-    //             document.title = "ERROR";
-    //           } else if (payment.status == "pending") {
-    //             this.$dialog.alert({
-    //               title: "提示",
-    //               message: "订单处理中...",
-    //               confirmButtonColor: "#269a93",
-    //             });
-    //           }
-    //         } else {
-    //           this.$dialog.alert({
-    //             title: "提示",
-    //             message: result.msg,
-    //             confirmButtonColor: "#269a93",
-    //           });
-    //         }
-    //       })
-    //       .catch((err) => {
-    //         this.$toast.clear();
-    //         this.$dialog.alert({
-    //           title: "提示",
-    //           message: JSON.stringify(err),
-    //           confirmButtonColor: "#269a93",
-    //         });
-    //       });
-    //   } catch (error) {
-    //     this.$dialog.alert({
-    //       title: "提示",
-    //       message: "网络异常,请检查网络连接",
-    //       confirmButtonColor: "#269a93",
-    //     });
-    //   }
-    // }, 500),
-    // scanCodePay(data) {
-    //   // 判断支付方式 如果是 test 模式 支付用测试url 否则用生产url
-    //   if (this.payType == "alipay_qr") {
-    //     let url =
-    //       data.prod_mode === "false"
-    //         ? data.expend.qrcode_url +
-    //           "?payment_id=" +
-    //           data.id +
-    //           "&pay_channel=" +
-    //           data.pay_channel
-    //         : data.expend.qrcode_url;
-    //     window.location.href = url;
-    //   } else if (this.payType == "wx_pub") {
-    //     let tempPayInfo = JSON.parse(data.expend.pay_info);
-    //     this.payInfo = tempPayInfo;
-    //     if (typeof WeixinJSBridge == "undefined") {
-    //       if (document.addEventListener) {
-    //         document.addEventListener(
-    //           "WeixinJSBridgeReady",
-    //           this.onBridgeReady,
-    //           false
-    //         );
-    //       } else if (document.attachEvent) {
-    //         document.attachEvent("WeixinJSBridgeReady", this.onBridgeReady);
-    //         document.attachEvent("onWeixinJSBridgeReady", this.onBridgeReady);
-    //       }
-    //     } else {
-    //       this.onBridgeReady();
-    //     }
-    //   }
-    // },
-
     const goAuth = () => {
       // 用户授权
       const urlNow = encodeURIComponent(window.location.href)

+ 110 - 146
src/views/adapay/pay-result/index.tsx

@@ -1,5 +1,15 @@
+import request from '@/helpers/request'
 import { browser, getUrlCode } from '@/helpers/utils'
-import { Cell, CellGroup, closeToast, Icon, Loading, showConfirmDialog, showDialog } from 'vant'
+import {
+  Cell,
+  CellGroup,
+  closeToast,
+  Icon,
+  Loading,
+  showConfirmDialog,
+  showDialog,
+  showToast
+} from 'vant'
 import { defineComponent, onMounted, reactive } from 'vue'
 import { useRouter, useRoute } from 'vue-router'
 import styles from './index.module.less'
@@ -12,21 +22,25 @@ export default defineComponent({
     const state = reactive({
       errorText: '',
       browserStatus: false,
-      payType: '',
-      payMap: {} as any,
-      code: ''
+      code: null as any,
+      pay_channel: route.query.pay_channel as any,
+      wxAppId: route.query.wxAppId as any,
+      body: route.query.body as any,
+      price: route.query.price as any,
+      orderNo: route.query.orderNo as any,
+      userId: route.query.userId as any,
+      payInfo: {} as any
     })
 
     const init = () => {
       // 判断是否有支付对象
-      if (!state.payMap || !state.payType) {
+      if (!state.orderNo || !state.pay_channel) {
         showConfirmDialog({
           message: '支付订单信息错误请重新支付'
         }).then(() => {
           router.back()
         })
       } else {
-        // state.amount = changeTwoDecimal(state.payMap.amount)
         // 判断当前浏览器
         if (browser().weixin) {
           state.browserStatus = true
@@ -41,155 +55,105 @@ export default defineComponent({
       }
     }
 
-    const getPayment = () => {
+    const getPayment = async () => {
       try {
-        // if (!(parseFloat(this.amount) > 0)) {
-        //   this.$toast('支付金额异常')
-        //   return
-        // }
-        // let { orderNo, sign, amount, orderBody, orderSubject, tenantId, returnUrl, notifyUrl } =
-        //   this.payMap
-        // returnUrl = returnUrl.replace(/\^\^/gi, '&')
-        // // 处理老师支付问题
-        // const tempPlatform = this.platform == 'teacher' ? 'student' : this.platform
-        // let that = this,
-        //   payMap = {
-        //     orderNo: orderNo,
-        //     sign: sign,
-        //     amount: numeral(amount).format('0.00'),
-        //     orderBody: orderBody,
-        //     orderSubject: orderSubject,
-        //     payChannel: this.payType, // 支付渠道
-        //     platform: tempPlatform,
-        //     tenantId: tenantId,
-        //     returnUrl: returnUrl,
-        //     notifyUrl: notifyUrl
-        //   }
-        // // 判断是否是微信公众号支付
-        // if (this.payType == 'wx_pub') {
-        //   payMap.code = this.code
-        // }
-        // this.$toast.loading({
-        //   duration: 0,
-        //   message: '加载中...',
-        //   forbidClick: true
-        // })
-        // executePayment(payMap)
-        //   .then((res) => {
-        //     this.$toast.clear()
-        //     let result = res.data
-        //     if (result.code == 200) {
-        //       let payment = result.data
-        //       if (payment.status === 'succeeded') {
-        //         this.scanCodePay(payment)
-        //       } else if (payment.status == 'failed') {
-        //         this.browserStatus = false
-        //         this.errorText = payment.error_msg
-        //         document.title = 'ERROR'
-        //       } else if (payment.status == 'pending') {
-        //         this.$dialog.alert({
-        //           title: '提示',
-        //           message: '订单处理中...',
-        //           confirmButtonColor: '#269a93'
-        //         })
-        //       }
-        //     } else {
-        //       showDialog({
-        //         title: '提示',
-        //         message: result.msg,
-        //         confirmButtonColor: '#269a93'
-        //       })
-        //     }
-        //   })
-        //   .catch((err) => {
-        //     closeToast()
-        //     showDialog({
-        //       title: '提示',
-        //       message: JSON.stringify(err),
-        //       confirmButtonColor: '#269a93'
-        //     })
-        //   })
+        try {
+          if (parseFloat(state.price) <= 0) {
+            showToast('支付金额异常')
+            return
+          }
+          const payMap: any = {
+            merOrderNo: state.orderNo,
+            paymentChannel: state.pay_channel, // 支付渠道
+            userId: state.userId
+          }
+          //     // 判断是否是微信公众号支付
+          if (state.pay_channel == 'wx_pub') {
+            payMap.code = state.code
+          }
+
+          const { data } = await request.post('/api-student/open/userOrder/executePayment', {
+            data: {
+              ...payMap
+            }
+          })
+
+          console.log(data, 'payment')
+          scanCodePay(data.reqParams)
+        } catch (e) {
+          //
+          console.log(e)
+        }
       } catch {
         //
       }
     }
+
     const scanCodePay = (data: any) => {
       // 判断支付方式 如果是 test 模式 支付用测试url 否则用生产url
-      // if (state.payType == 'alipay_wap') {
-      //   window.location.href = data.expend.pay_info
-      // } else if (state.payType == 'wx_pub') {
-      //   const tempPayInfo = JSON.parse(data.expend.pay_info)
-      //   state.payInfo = tempPayInfo
-      //   if (typeof WeixinJSBridge == 'undefined') {
-      //     if (document.addEventListener) {
-      //       document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
-      //     } else if (document.attachEvent) {
-      //       document.attachEvent('WeixinJSBridgeReady', onBridgeReady)
-      //       document.attachEvent('onWeixinJSBridgeReady', onBridgeReady)
-      //     }
-      //   } else {
-      //     state.onBridgeReady()
-      //   }
-      // }
+      if (state.pay_channel == 'alipay_qr') {
+        const url =
+          data.prod_mode === 'false'
+            ? data.expend.qrcode_url + '?payment_id=' + data.id + '&pay_channel=' + data.pay_channel
+            : data.expend.qrcode_url
+        window.location.href = url
+      } else if (state.pay_channel == 'wx_pub') {
+        const tempPayInfo = JSON.parse(data.expend.pay_info)
+        state.payInfo = tempPayInfo
+        if (typeof (window as any).WeixinJSBridge == 'undefined') {
+          if (document.addEventListener) {
+            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false)
+          } else if ((document as any).attachEvent) {
+            ;(document as any)
+              .attachEvent(
+                'WeixinJSBridgeReady',
+                onBridgeReady
+              )(document as any)
+              .attachEvent('onWeixinJSBridgeReady', onBridgeReady)
+          }
+        } else {
+          onBridgeReady()
+        }
+      }
     }
+
     const onBridgeReady = () => {
-      // let payInfo = this.payInfo
-      // WeixinJSBridge.invoke(
-      //   'getBrandWCPayRequest',
-      //   {
-      //     appId: payInfo.appId, //公众号名称,由商户传入
-      //     timeStamp: payInfo.timeStamp, //时间戳,自1970年以来的秒数
-      //     nonceStr: payInfo.nonceStr, //随机串
-      //     package: payInfo.package,
-      //     signType: payInfo.signType, //微信签名方式:
-      //     paySign: payInfo.paySign //微信签名
-      //   },
-      //   (res) => {
-      //     // if(res.err_msg == "get_brand_wcpay_request:ok" ){
-      //     // 使用以上方式判断前端返回,微信团队郑重提示:
-      //     //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
-      //     // } else
-      //     // 支付取消或支付失败
-      //     let { orderNo } = this.payMap
-      //     if (
-      //       res.err_msg == 'get_brand_wcpay_request:cancel' ||
-      //       res.err_msg == 'get_brand_wcpay_request:fail'
-      //     ) {
-      //       // 用户取消支付
-      //       if (this.platform == 'manager') {
-      //         // 管理端
-      //         window.location.replace(
-      //           validManageUrl() + '/#/paymentResult?orderNo=' + orderNo + '&isBack=off'
-      //         )
-      //       } else if (this.platform == 'teacher') {
-      //         // 老师端
-      //         window.location.replace(
-      //           validTeacherUrl() + '/#/paymentResult?orderNo=' + orderNo + '&isBack=off'
-      //         )
-      //       } else {
-      //         this.$router.replace({
-      //           path: '/paymentResult',
-      //           query: {
-      //             type: 'error',
-      //             orderNo: orderNo,
-      //             isBack: 'off'
-      //           }
-      //         })
-      //       }
-      //     } else {
-      //       // 使用以上方式判断前端返回,微信团队郑重提示:
-      //       //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
-      //       // this.$router.replace({
-      //       //   path: "/paymentResult",
-      //       //   query: {
-      //       //     orderNo: orderNo,
-      //       //     isBack: "off",
-      //       //   },
-      //       // });
-      //     }
-      //   }
-      // )
+      const payInfo = state.payInfo
+      // let orderNo = state.orderNo
+      ;(window as any).WeixinJSBridge.invoke(
+        'getBrandWCPayRequest',
+        {
+          appId: payInfo.appId, //公众号名称,由商户传入
+          timeStamp: payInfo.timeStamp, //时间戳,自1970年以来的秒数
+          nonceStr: payInfo.nonceStr, //随机串
+          package: payInfo.package,
+          signType: payInfo.signType, //微信签名方式:
+          paySign: payInfo.paySign //微信签名
+        },
+        (res: any) => {
+          // if(res.err_msg == "get_brand_wcpay_request:ok" ){
+          // 使用以上方式判断前端返回,微信团队郑重提示:
+          //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
+          // } else
+          if (
+            res.err_msg == 'get_brand_wcpay_request:cancel' ||
+            res.err_msg == 'get_brand_wcpay_request:fail'
+          ) {
+            window.location.replace(
+              location.origin + '/orchestra-student/#/payment-result?orderNo=' + state.orderNo
+            )
+          } else {
+            // 使用以上方式判断前端返回,微信团队郑重提示:
+            //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
+            // alert('支付成功')
+            window.location.replace(
+              location.origin + '/orchestra-student/#/payment-result?orderNo=' + state.orderNo
+            )
+          }
+        }
+      )
     }
+
     const getWxPay = () => {
       // 微信公众号支付
       //授权
@@ -197,7 +161,7 @@ export default defineComponent({
       if (!code) {
         goAuth()
       } else {
-        // state.code = code
+        state.code = code
         getPayment()
       }
     }