From c8804ceb1fe2dea76f9949c5ea04423876ee2c81 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 28 六月 2024 14:02:47 +0800
Subject: [PATCH] 2024-06-28

---
 src/views/pay/index.jsx |   80 ++++++++++++++++++----------------------
 1 files changed, 36 insertions(+), 44 deletions(-)

diff --git a/src/views/pay/index.jsx b/src/views/pay/index.jsx
index 788a5c5..7230ba5 100644
--- a/src/views/pay/index.jsx
+++ b/src/views/pay/index.jsx
@@ -17,54 +17,47 @@
   state = {
     orderId: '',
     orderNo: '',
-    appid: '',
-    logo: '',
-    name: '',
-    copyRight: '',
-    icp: '',
+    logo: window.GLOB.doclogo || '',
+    name: sessionStorage.getItem('Full_Name') || '',
+    copyRight: window.GLOB.copyRight || '',
+    icp: window.GLOB.ICP || '',
     total: '',
     unit: '',
     qrcode: '',
     second: 60,
     overdue: false,
-    overdone: false
+    overdone: false,
+    appId: ''
   }
 
   UNSAFE_componentWillMount () {
-    let _urlparam = window.decodeURIComponent(window.atob(this.props.match.params.param))
-    let _params = {}
-    _urlparam.split('&').forEach(cell => {
-      let _cell = cell.split('=')
-      _params[_cell[0]] = _cell[1]
-    })
+    let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
 
-    if (!sessionStorage.getItem('LoginUID') && _params.LoginUID) {
-      sessionStorage.setItem('LoginUID', _params.LoginUID)
-    }
-    if (!sessionStorage.getItem('UserID') && _params.userid) {
-      sessionStorage.setItem('UserID', _params.userid)
-    }
+    let _appId = param.appId || window.GLOB.WXAppID || window.GLOB.WXminiAppID || ''
 
     this.setState({
-      orderId: _params.ID,
-      logo: _params.logo,
-      name: _params.name,
-      copyRight: _params.copyRight,
-      icp: _params.icp
+      orderId: param.ID,
+      appId: _appId
     })
 
-    if (_params.ID) {
-      this.getOrder(_params.ID)
-    } else {
+    if (param.ID && _appId) {
+      this.getOrder(param.ID, _appId)
+    } else if (!param.ID) {
       notification.warning({
         top: 92,
         message: '鏈幏鍙栧埌璁㈠崟ID锛�',
         duration: 5
       })
+    } else if (!_appId) {
+      notification.warning({
+        top: 92,
+        message: '鏈幏鍙栧埌搴旂敤ID锛�',
+        duration: 5
+      })
     }
   }
 
-  getOrder = (Id) => {
+  getOrder = (Id, appId) => {
     let param = {
       func: 's_get_weixin_pay_native',
       ID: Id
@@ -85,7 +78,6 @@
         }
 
         this.setState({
-          appid: res.appid,
           orderNo: res.out_trade_no,
           total: _total,
           unit: res.amount && res.amount.currency === 'CNY' ? '鍏�' : '鍏�',
@@ -114,19 +106,12 @@
             duration: 5
           })
           return
-        } else if (!res.appid) {
-          notification.warning({
-            top: 10,
-            message: '鏈幏鍙栧埌搴旂敤ID锛�',
-            duration: 5
-          })
-          return
         }
 
-        Api.getWxNativePay({ 'out_biz_no': res.out_trade_no, 'out_open_id': res.appid }).then(result => {
-          if (result.qrcode) {
+        Api.getWxNativePay({ 'out_biz_no': res.out_trade_no, app_id: appId }).then(result => {
+          if (result.status && result.code_url) {
             this.setState({
-              qrcode: result.qrcode
+              qrcode: result.code_url
             })
             setTimeout(this.resetSecond, 1000)
           } else {
@@ -135,7 +120,7 @@
             })
             notification.warning({
               top: 10,
-              message: result.msg || '鏈幏鍙栧埌鏀粯鐮侊紒',
+              message: result.message || '鏈幏鍙栧埌鏀粯鐮侊紒',
               duration: 5
             })
           }
@@ -198,7 +183,7 @@
   }
 
   resetQrcode = () => {
-    const { appid, orderNo } = this.state
+    const { orderNo, appId } = this.state
 
     if (!orderNo) {
       notification.warning({
@@ -207,12 +192,19 @@
         duration: 5
       })
       return
+    } else if (!appId) {
+      notification.warning({
+        top: 10,
+        message: '鏈幏鍙栧埌搴旂敤ID锛�',
+        duration: 5
+      })
+      return
     }
 
-    Api.getWxNativePay({ 'out_biz_no': orderNo, 'out_open_id': appid }).then(result => {
-      if (result.qrcode) {
+    Api.getWxNativePay({ 'out_biz_no': orderNo, app_id: appId }).then(result => {
+      if (result.status && result.code_url) {
         this.setState({
-          qrcode: result.qrcode,
+          qrcode: result.code_url,
           overdue: false,
           second: 60
         })
@@ -220,7 +212,7 @@
       } else {
         notification.warning({
           top: 10,
-          message: result.msg || '鏈幏鍙栧埌鏀粯鐮侊紒',
+          message: result.message || '鏈幏鍙栧埌鏀粯鐮侊紒',
           duration: 5
         })
       }

--
Gitblit v1.8.0