king
2024-10-11 6ca240a14ccf55d4e0a94fff77e95f64db2cdfcc
src/views/pay/index.jsx
@@ -27,37 +27,46 @@
    second: 60,
    overdue: false,
    overdone: false,
    appId: ''
    appId: '',
    merchId: ''
  }
  UNSAFE_componentWillMount () {
    let param = JSON.parse(window.decodeURIComponent(window.atob(this.props.match.params.param)))
    let _appId = param.appId || window.GLOB.WXAppID || window.GLOB.WXminiAppID || ''
    let appId = param.appId || window.GLOB.WXAppID || window.GLOB.WXminiAppID || ''
    let merchId = param.merchId || window.GLOB.WXMerchID || ''
    this.setState({
      orderId: param.ID,
      appId: _appId
      appId: appId,
      merchId: merchId
    })
    if (param.ID && _appId) {
      this.getOrder(param.ID, _appId)
    if (param.ID && appId && merchId) {
      this.getOrder(param.ID, appId, merchId)
    } else if (!param.ID) {
      notification.warning({
        top: 92,
        message: '未获取到订单ID!',
        duration: 5
      })
    } else if (!_appId) {
    } else if (!appId) {
      notification.warning({
        top: 92,
        message: '未获取到应用ID!',
        duration: 5
      })
    } else if (!merchId) {
      notification.warning({
        top: 92,
        message: '未获取到商户号!',
        duration: 5
      })
    }
  }
  getOrder = (Id, appId) => {
  getOrder = (Id, appId, merchId) => {
    let param = {
      func: 's_get_weixin_pay_native',
      ID: Id
@@ -108,7 +117,7 @@
          return
        }
        Api.getWxNativePay({ 'out_biz_no': res.out_trade_no, app_id: appId }).then(result => {
        Api.getWxNativePay({ 'out_biz_no': res.out_trade_no, app_id: appId, mchid: merchId }).then(result => {
          if (result.status && result.code_url) {
            this.setState({
              qrcode: result.code_url
@@ -183,7 +192,7 @@
  }
  resetQrcode = () => {
    const { orderNo, appId } = this.state
    const { orderNo, appId, merchId } = this.state
    if (!orderNo) {
      notification.warning({
@@ -199,9 +208,16 @@
        duration: 5
      })
      return
    } else if (!merchId) {
      notification.warning({
        top: 10,
        message: '未获取到商户号!',
        duration: 5
      })
      return
    }
    Api.getWxNativePay({ 'out_biz_no': orderNo, app_id: appId }).then(result => {
    Api.getWxNativePay({ 'out_biz_no': orderNo, app_id: appId, mchid: merchId }).then(result => {
      if (result.status && result.code_url) {
        this.setState({
          qrcode: result.code_url,
@@ -219,9 +235,9 @@
    })
  }
  onChange = () => {
  // onChange = () => {
  }
  // }
  render () {
    const { logo, name, orderNo, icp, copyRight, total, unit, qrcode, second, overdue, overdone } = this.state
@@ -243,17 +259,8 @@
                {!overdone ? <div className="qrcode-box">
                  {!overdue ? <p>距离二维码过期还剩<span>{second}</span>秒,过期后请刷新页面重新获取二维码。</p> : null}
                  {overdue ? <p className="overdue">二维码已过期,<span onClick={this.resetQrcode}>刷新</span>页面重新获取二维码。</p> : null}
                  <QRCode
                    value={qrcode}
                    size={250}
                    fgColor="#000000"
                    // imageSettings={{
                    //   src: '',
                    //   height: 60,
                    //   width: 60,
                    //   excavate: true
                    // }}
                  />
                  <QRCode value={qrcode} size={250} fgColor="#000000"/>
                  {!overdue && !qrcode ? <div className="qr-mask"></div> : null}
                  {overdue ? <div className="overdue-mask"><p onClick={this.resetQrcode}>获取失败 点击重新获取二维码</p></div> : null}
                  <div className="qrcode-tip">
                    <img src={WeiXinScan} alt=""/>