码迷,mamicode.com
首页 > 其他好文 > 详细

vue--支付宝支付

时间:2019-07-05 10:53:24      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:nbsp   header   mamicode   img   replace   支付宝   mat   form   catch   

1、支付宝支付:前端发起一个请求,后台返回一个页面,直接将返回的页面(一个表单),再执行表单提交

okFryOtherPayHandler(){
        let reqBody = {};
        reqBody.orderId = this.orderId;
        reqBody.payType = this.payType;
        fetchOrderPayMsg(reqBody).then((res) => {
          let resData = res.data;
          if(resData.respHeader.resultCode == 0){
            document.querySelector(‘#submitFormDiv‘).innerHTML = resData.respBody;
            this.executeScript(resData.respBody);
          }else{
            this.submitActive = false;
            Toast({
              message: resData.respHeader.message,
            });
          }
        });
      },
      executeScript(html){
        let reg = /<script[^>]*>([^\x00]+)$/i;
        let htmlBlock = html.split("<\/script>");
        for (let i in htmlBlock){
          let blocks;
          if (blocks = htmlBlock[i].match(reg)){
            let code = blocks[1].replace(/<!--/, ‘‘);
            try{
              eval(code) //执行脚本
            }
            catch (e){
            }
          }
        }
      },

  

fetchOrderPayMsg() axios 返回的参数如下:

技术图片

 

vue--支付宝支付

标签:nbsp   header   mamicode   img   replace   支付宝   mat   form   catch   

原文地址:https://www.cnblogs.com/ilovexiaoming/p/11136923.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!