lex 2 سال پیش
والد
کامیت
8950b7077e

+ 2 - 2
public/project/schoolRegister.html

@@ -76,11 +76,11 @@
             <van-radio-group checked-color="#64A9FF" v-model="forms.schoolSystem" direction="horizontal">
               <van-tag size="large" type="primary" :plain="!(forms.schoolSystem === 'fiveYearSystem')" color="#64A9FF"
                 class="radioSection">
-                <van-radio class="radioItem" name="fiveYearSystem"></van-radio>年制
+                <van-radio class="radioItem" name="fiveYearSystem"></van-radio>年制
               </van-tag>
               <van-tag size="large" type="primary" :plain="!(forms.schoolSystem === 'sixYearSystem')" color="#64A9FF"
                 class="radioSection">
-                <van-radio class="radioItem" name="sixYearSystem"></van-radio>年制
+                <van-radio class="radioItem" name="sixYearSystem"></van-radio>年制
               </van-tag>
             </van-radio-group>
           </template>

+ 24 - 0
src/router/routes-common.ts

@@ -16,6 +16,30 @@ export const rootRouter = [
     }
   },
   {
+    path: '/payCenter',
+    name: 'payCenter',
+    component: () => import('@/views/adapay/pay-center'),
+    meta: {
+      title: '支付'
+    }
+  },
+  {
+    path: '/payDefine',
+    name: 'payDefine',
+    component: () => import('@/views/adapay/pay-define'),
+    meta: {
+      title: '支付'
+    }
+  },
+  {
+    path: '/payResult',
+    name: 'payResult',
+    component: () => import('@/views/adapay/pay-result'),
+    meta: {
+      title: '支付'
+    }
+  },
+  {
     path: '/:pathMatch(.*)*',
     component: () => import('@/views/404'),
     meta: {

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

@@ -296,7 +296,6 @@ export default defineComponent({
           v-model:modelValue={forms.timerStatus}
           position="bottom"
           style={{ background: '#F6F6F6' }}
-          destroy
         >
           <Timer
             timerList={forms.timerList}

+ 3 - 0
src/student/main.ts

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

+ 8 - 4
src/student/music-group/pre-apply/component/payment.tsx

@@ -81,8 +81,8 @@ export default defineComponent({
       details.forEach((item: any) => {
         // 是否选中
         if (state.check.includes(item.goodsId)) {
-          tempPrice.needPrice += Number(item.currentPrice)
-          tempPrice.originalPrice += Number(item.originalPrice)
+          tempPrice.needPrice += parseFloat(item.currentPrice)
+          tempPrice.originalPrice += parseFloat(item.originalPrice)
         }
       })
 
@@ -100,7 +100,9 @@ export default defineComponent({
         if (countUpRef.needPrice) {
           countUpRef.needPrice.update(state.orderInfo.needPrice)
         } else {
-          countUpRef.needPrice = new CountUp('needPrice', state.orderInfo.needPrice)
+          countUpRef.needPrice = new CountUp('needPrice', state.orderInfo.needPrice, {
+            decimalPlaces: 2
+          })
           if (!countUpRef.needPrice.error) {
             countUpRef.needPrice.start()
           } else {
@@ -110,7 +112,9 @@ export default defineComponent({
         if (countUpRef.originalPrice) {
           countUpRef.originalPrice.update(state.orderInfo.originalPrice)
         } else {
-          countUpRef.originalPrice = new CountUp('originalPrice', state.orderInfo.originalPrice)
+          countUpRef.originalPrice = new CountUp('originalPrice', state.orderInfo.originalPrice, {
+            decimalPlaces: 2
+          })
           if (!countUpRef.originalPrice.error) {
             countUpRef.originalPrice.start()
           } else {

+ 30 - 10
src/student/music-group/pre-apply/order-detail.tsx

@@ -10,6 +10,7 @@ import OQrcode from '@/components/o-qrcode'
 import request from '../request-music'
 import item from '@/student/coupons/item'
 import { moneyFormat } from '@/helpers/utils'
+import { state as baseState } from '@/state'
 
 export default defineComponent({
   name: 'order-detail',
@@ -19,6 +20,7 @@ export default defineComponent({
     const state = reactive({
       paymentStatus: false,
       showQrcode: false,
+      qrCodeUrl: '',
       orderNo: route.query.orderNo,
       orderInfo: {} as any, // 订单信息
       goodsInfos: [] as any // 订单信息列表
@@ -140,15 +142,33 @@ export default defineComponent({
                   }
                 })
               } else {
-                router.push({
-                  path: '/payCenter',
-                  query: {
-                    pay_channel: val.pay_channel,
-                    wxAppId: config.wxAppId,
-                    body: config.body,
-                    price: config.price
-                  }
-                })
+                // router.push({
+                //   path: '/payCenter',
+                //   query: {
+                //     pay_channel: val.pay_channel,
+                //     wxAppId: config.wxAppId,
+                //     body: config.body,
+                //     price: config.price
+                //   }
+                // })
+                console.log(baseState.user)
+                state.qrCodeUrl =
+                  window.location.origin +
+                  '/#/payCenter?pay_channel=' +
+                  val.pay_channel +
+                  '&wxAppId=' +
+                  config.wxAppId +
+                  '&body=' +
+                  config.body +
+                  '&price=' +
+                  config.price +
+                  '&orderNo=' +
+                  config.merOrderNo +
+                  '&userId=' +
+                  config.userId
+                console.log(state.qrCodeUrl, 'qrCodeUrl')
+                state.showQrcode = true
+                state.paymentStatus = false
               }
             }}
           />
@@ -168,7 +188,7 @@ export default defineComponent({
                 <div class={styles.codeName}>请截图下方二维码 登录支付宝扫码支付</div>
 
                 <div class={styles.codeQr}>
-                  <OQrcode text="http://ponline.dayaedu.com/" size={'400'} />
+                  <OQrcode text={state.qrCodeUrl} size={'400'} />
                 </div>
                 <div style={{ textAlign: 'center' }}>
                   <span class={styles.codeBtnText}>请在30分钟内扫码支付</span>

+ 2 - 1
src/views/adapay/pay-center/index.module.less

@@ -5,8 +5,9 @@
 .error-icon {
   display: block;
   color: #ffb07b;
-  font-size: 16px;
+  font-size: 30px;
   margin-bottom: 30px;
+  font-weight: bold;
 }
 .error-text {
   font-size: 15px;

+ 32 - 27
src/views/adapay/pay-center/index.tsx

@@ -1,27 +1,32 @@
 import { browser, getUrlCode } from '@/helpers/utils'
 import { Icon } from 'vant'
-import { defineComponent, reactive } from 'vue'
-import { useRouter } from 'vue-router'
+import { defineComponent, onMounted, reactive } from 'vue'
+import { useRoute, useRouter } from 'vue-router'
 import styles from './index.module.less'
 
 export default defineComponent({
   name: 'pay-center',
   setup() {
     const router = useRouter()
+    const route = useRoute()
     const state = reactive({
       errorText: '',
       code: null as any,
-      payType: null as any,
-      wxAppId: 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
     })
 
     const init = () => {
-      const payType = state.payType
-      const ua = window.navigator.userAgent.toLowerCase()
+      const pay_channel = state.pay_channel
       if (browser().weixin) {
-        if (payType === 'wx_pub') {
+        if (pay_channel === 'wx_pub') {
           //授权
           const code = getUrlCode()
+          console.log(code)
           if (code) {
             state.code = code // 赋值code码
             onPayPage() // 跳转支付页
@@ -29,13 +34,13 @@ export default defineComponent({
             goAuth()
           }
           document.title = '微信支付'
-        } else if (payType == 'alipay_qr') {
+        } else if (pay_channel == 'alipay_qr') {
           state.errorText = '请使用支付宝扫码'
         }
       } else if (browser().alipay) {
-        if (payType === 'wx_pub') {
+        if (pay_channel === 'wx_pub') {
           state.errorText = '请使用微信扫码'
-        } else if (payType == 'alipay_qr') {
+        } else if (pay_channel == 'alipay_qr') {
           // 支付宝支付
           document.title = '支付宝支付'
           onPayPage() // 跳转支付页
@@ -48,32 +53,32 @@ export default defineComponent({
 
     const onPayPage = () => {
       // 跳转对应支付页
-      // this.$router.replace({
-      //   path: 'payDefine',
-      //   query: {
-      //     amount: this.amount, // 支付金额
-      //     orderNo: this.orderNo, // 订单号
-      //     sign: this.sign, // 签名
-      //     payType: this.payType,
-      //     orderBody: this.orderBody,
-      //     orderSubject: this.orderSubject,
-      //     platform: this.platform, // 平台
-      //     tenantId: this.tenantId,
-      //     notifyUrl: this.notifyUrl,
-      //     returnUrl: this.returnUrl,
-      //     code: this.code // 获取授权码
-      //   }
-      // })
+      router.replace({
+        path: '/payDefine',
+        query: {
+          pay_channel: state.pay_channel,
+          wxAppId: state.wxAppId,
+          body: state.body,
+          price: state.price,
+          code: state.code,
+          orderNo: state.orderNo,
+          userId: state.userId
+        }
+      })
     }
     const goAuth = () => {
       // 用户授权
       const urlNow = encodeURIComponent(window.location.href)
       const scope = 'snsapi_base' //snsapi_userinfo   //静默授权 用户无感知
-      const appid = state.wxAppId || 'wx751141096e75a4ee'
+      const appid = state.wxAppId || 'wx8654c671631cfade'
       const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=STATE&connect_redirect=1#wechat_redirect`
       window.location.replace(url)
     }
 
+    onMounted(() => {
+      init()
+    })
+
     return () => (
       <div class={styles.payCenter}>
         <div class={styles['error-text']}>

+ 9 - 4
src/views/adapay/pay-define/index.module.less

@@ -6,7 +6,7 @@
   :global {
     .van-cell__title,
     .van-cell__value {
-      flex: auto;
+      // flex: auto;
       font-size: 15px;
       color: #4f4f4f;
     }
@@ -18,10 +18,15 @@
   }
 }
 .amount {
-  padding: 20px 0;
-  font-size: 20px;
+  padding: 35px 0 55px;
+  font-size: 41px;
+  font-weight: bold;
+  color: #333333;
+  line-height: 36px;
   text-align: center;
-  font-weight: 600;
+  span {
+    font-size: 31px;
+  }
 }
 .error-text {
   font-size: 15px;

+ 134 - 111
src/views/adapay/pay-define/index.tsx

@@ -1,26 +1,136 @@
-import { browser, getUrlCode } from '@/helpers/utils'
-import { Button, Cell, CellGroup, Icon } from 'vant'
+import request from '@/helpers/request'
+import { browser, getUrlCode, moneyFormat } from '@/helpers/utils'
+import numeral from 'numeral'
+import { Button, Cell, CellGroup, Icon, showToast } from 'vant'
 import { defineComponent, onMounted, reactive } from 'vue'
+import { useRoute } from 'vue-router'
 import styles from './index.module.less'
 
 export default defineComponent({
   name: 'pay-define',
   setup() {
+    const route = useRoute()
     const state = reactive({
-      amount: 0,
       browserStatus: false,
       errorText: '',
-      payType: '',
-      code: null as any,
-      wxAppId: ''
+      code: (route.query.code || '') 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 getPayment = () => {}
+    const getPayment = async () => {
+      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)
+        // 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)
+      }
+    }
+
+    const scanCodePay = (data: any) => {
+      // 判断支付方式 如果是 test 模式 支付用测试url 否则用生产url
+      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 = () => {
+      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'
+          ) {
+            alert('支付失败')
+          } else {
+            // 使用以上方式判断前端返回,微信团队郑重提示:
+            //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
+            alert('支付成功')
+          }
+        }
+      )
+    }
 
     //  getPayment: throttle(function() {
     //   try {
     //     if (!(parseFloat(this.amount) > 0)) {
-    //       this.$toast("支付金额异常");
+    //       this.$toast("f");
     //       return;
     //     }
     //     removeAuthToken();
@@ -122,109 +232,15 @@ export default defineComponent({
     //     }
     //   }
     // },
-    // onBridgeReady() {
-    //   let payInfo = this.payInfo;
-    //   let orderNo = this.orderNo;
-    //   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
-    //       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)
-    //           this.$router.replace({
-    //             path: "/paymentResult",
-    //             query: {
-    //               type: "error",
-    //               groupType: "REPAIR",
-    //               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,但并不保证它绝对可靠。
-    //         if (this.platform == "manager") {
-    //           // 管理端
-    //           // window.location.replace(validManageUrl() + '/#/paymentResult?orderNo=' + orderNo)
-    //           this.$router.replace({
-    //             path: "/paymentResult",
-    //             query: {
-    //               orderNo: this.orderNo,
-    //               isBack: "off",
-    //             },
-    //           });
-    //         } else if (this.platform == "teacher") {
-    //           // 老师端
-    //           window.location.replace(
-    //             validTeacherUrl() +
-    //               "/#/paymentResult?orderNo=" +
-    //               orderNo +
-    //               "&isBack=off"
-    //           );
-    //         } else {
-    //           this.$router.replace({
-    //             path: "/paymentResult",
-    //             query: {
-    //               orderNo: this.orderNo,
-    //               isBack: "off",
-    //             },
-    //           });
-    //         }
-    //       }
-    //     }
-    //   );
-    // },
-    const goAuth = () => {
-      // 用户授权
-      const urlNow = encodeURIComponent(window.location.href)
-      const scope = 'snsapi_base' //snsapi_userinfo   //静默授权 用户无感知
-      const appid = state.wxAppId || 'wx751141096e75a4ee'
-      const url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${urlNow}&response_type=code&scope=${scope}&state=STATE&connect_redirect=1#wechat_redirect`
-      window.location.replace(url)
-    }
 
     onMounted(() => {
       if (window.location.href.indexOf('?#') < 0) {
         window.location.href = window.location.href.replace('#', '?#')
       }
       // 判断当前浏览器
-      const payType = state.payType
+      const pay_channel = state.pay_channel
       if (browser().weixin) {
-        if (payType === 'wx_pub') {
+        if (pay_channel === 'wx_pub') {
           //授权
           const code = getUrlCode()
           if (code) {
@@ -232,13 +248,13 @@ export default defineComponent({
           }
           state.browserStatus = true
           document.title = '微信支付'
-        } else if (payType == 'alipay_qr') {
+        } else if (pay_channel == 'alipay_qr') {
           state.errorText = '请使用支付宝扫码'
         }
       } else if (browser().alipay) {
-        if (payType === 'wx_pub') {
+        if (pay_channel === 'wx_pub') {
           state.errorText = '请使用微信扫码'
-        } else if (payType == 'alipay_qr') {
+        } else if (pay_channel == 'alipay_qr') {
           // 支付宝支付
           state.browserStatus = true
           document.title = '支付宝支付'
@@ -252,10 +268,17 @@ export default defineComponent({
       <div class={styles.paydefine}>
         {state.browserStatus && (
           <div class={styles.container}>
-            <div class={styles.amount}>¥{state.amount}</div>
-            <CellGroup>
-              <Cell title={'支付方式'} value={''}></Cell>
-              <Cell title={'实付金额'} value={'¥0元'}></Cell>
+            <div class={styles.amount}>
+              <span>¥</span>
+              {moneyFormat(state.price)}
+            </div>
+            <CellGroup inset>
+              <Cell title="订单信息" value={state.body} valueClass={styles.values}></Cell>
+              <Cell
+                title="支付方式"
+                value={state.pay_channel === 'wx_pub' ? '微信' : '支付宝'}
+              ></Cell>
+              <Cell title="实付金额" value={`¥${moneyFormat(state.price)}元`}></Cell>
             </CellGroup>
 
             <Button type="primary" block size="large" onClick={getPayment} round color="#01C1B5">

+ 2 - 2
vite.config.ts

@@ -12,8 +12,8 @@ function resolve(dir: string) {
 // https://vitejs.dev/config/
 // https://github.com/vitejs/vite/issues/1930 .env
 // const proxyUrl = 'https://mstutest.dayaedu.com/';
-const proxyUrl = 'http://47.98.131.38:8989/'
-// const proxyUrl = 'http://192.168.3.143:8989/' // 尚科
+// const proxyUrl = 'http://47.98.131.38:8989/'
+const proxyUrl = 'http://192.168.3.143:8989/' // 尚科
 // const proxyUrl = 'http://192.168.3.26:8989/' // 刘俊驰
 export default defineConfig({
   base: './',