后端返回支付宝HTML,如何使用.H5端调用支付宝支付

// click 点击事件
  const goBuy = () => {
    dispatch({
      type: 'welfare/purchase',
      payload: {
        id: state?.id,
        tradeCount: state?.num,
        deductPoints: state?.points,
        realAmount: price - (state?.points || 0),
        totalAmount: price,
      },
    }).then((res) => {
      if (res?.code === 200) {
      // 后端返回code码正常  开始处理HTML
        const div = document.createElement('divform');
        div.innerHTML = res.data; // data就是接口返回的form 表单字符串
        document.body.appendChild(div);
        let len = document.forms.length - 1;
        document.forms[len].setAttribute('target', '_blank'); // 新开窗口跳转
        document.forms[len].submit();
      }
    });
  };

  

posted on 2022-05-18 17:07  水行者  阅读(557)  评论(0编辑  收藏  举报

导航