king
2024-07-01 866db6d8afa6980fd485570acda6b5fcebda4da3
src/views/pay/index.jsx
@@ -17,54 +17,56 @@
  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: '',
    merchId: ''
  }
  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 || ''
    let merchId = param.merchId || window.GLOB.WXMerchID || ''
    this.setState({
      orderId: _params.ID,
      logo: _params.logo,
      name: _params.name,
      copyRight: _params.copyRight,
      icp: _params.icp
      orderId: param.ID,
      appId: appId,
      merchId: merchId
    })
    if (_params.ID) {
      this.getOrder(_params.ID)
    } else {
    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) {
      notification.warning({
        top: 92,
        message: '未获取到应用ID!',
        duration: 5
      })
    } else if (!merchId) {
      notification.warning({
        top: 92,
        message: '未获取到商户号!',
        duration: 5
      })
    }
  }
  getOrder = (Id) => {
  getOrder = (Id, appId, merchId) => {
    let param = {
      func: 's_get_weixin_pay_native',
      ID: Id
@@ -85,7 +87,6 @@
        }
        this.setState({
          appid: res.appid,
          orderNo: res.out_trade_no,
          total: _total,
          unit: res.amount && res.amount.currency === 'CNY' ? '元' : '元',
@@ -114,19 +115,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, mchid: merchId }).then(result => {
          if (result.status && result.code_url) {
            this.setState({
              qrcode: result.qrcode
              qrcode: result.code_url
            })
            setTimeout(this.resetSecond, 1000)
          } else {
@@ -135,7 +129,7 @@
            })
            notification.warning({
              top: 10,
              message: result.msg || '未获取到支付码!',
              message: result.message || '未获取到支付码!',
              duration: 5
            })
          }
@@ -198,7 +192,7 @@
  }
  resetQrcode = () => {
    const { appid, orderNo } = this.state
    const { orderNo, appId, merchId } = this.state
    if (!orderNo) {
      notification.warning({
@@ -207,12 +201,26 @@
        duration: 5
      })
      return
    } else if (!appId) {
      notification.warning({
        top: 10,
        message: '未获取到应用ID!',
        duration: 5
      })
      return
    } else if (!merchId) {
      notification.warning({
        top: 10,
        message: '未获取到商户号!',
        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, mchid: merchId }).then(result => {
      if (result.status && result.code_url) {
        this.setState({
          qrcode: result.qrcode,
          qrcode: result.code_url,
          overdue: false,
          second: 60
        })
@@ -220,16 +228,16 @@
      } else {
        notification.warning({
          top: 10,
          message: result.msg || '未获取到支付码!',
          message: result.message || '未获取到支付码!',
          duration: 5
        })
      }
    })
  }
  onChange = () => {
  // onChange = () => {
  }
  // }
  render () {
    const { logo, name, orderNo, icp, copyRight, total, unit, qrcode, second, overdue, overdone } = this.state