PHP

2019-08-27 微信支付

2019-08-27  本文已影响0人  剑指流云
let dingdanhao = new Date().getTime();
this.$axios
  .get(
    "web/wxpay.php/?openid=" +
      sessionStorage.getItem("openid") +
      "&total_fee=" +
      this.price +
      "&dingdanhao=" +
      dingdanhao
  )
  .then(res => {
    let result = res.data;
    wx.config({
      appId: result.appId, // 必填,公众号的唯一标识
      timestamp: result.timeStamp, // 必填,生成签名的时间戳
      nonceStr: result.nonceStr, // 必填,生成签名的随机串
      signature: result.paySign, // 必填,签名,见附录1
      jsApiList: ["chooseWXPay"] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
    });
    wx.chooseWXPay({
      timestamp: result.timeStamp,
      nonceStr: result.nonceStr,
      package: result.package,
      signType: result.signType,
      paySign: result.paySign,
      success: function(res) {
        this.$axios
          .get(
            "web/updatevoter.php/?openid=" +
              sessionStorage.getItem("openid") +
              "&type=" +
              this.$config.type
          )
          .then(() => {
            this.upDatePiao();
          });
      },
      cancel: function(res) {
        Dialog.alert({
          title: "赠送失败",
          message: "您选择了取消支付"
        });
        this.show = false;
      }
    });
  });
上一篇下一篇

猜你喜欢

热点阅读