微信小程序实现微信支付

    <view class="pushBtn">
      <u-button
        @click="submitPay"
        shape="circle"
        :custom-style="customStyle"
        :ripple="true"
        ripple-bg-color="#909399"
        >确定缴费</u-button
      >
    </view>
    submitPay() {
      if (this.checked == false) {
        this.$u.toast("请选择支付方式");
        return;
      }
      let that = this;
      that.form.tradeType = "JSAPI";
      that.form.body = "物业缴费";
      that.form.outTradeNo = that.paymentDetailsList.outTradeNo; // 微信交易编号
      that.form.totalFee = that.paymentDetailsList.waitPayAmount * 100; // 金额
      that.$u.api.updateCreateOrder(that.form).then((res) => {
        uni.requestPayment({
          provider: "wxpay", // 服务提供商
          appid: res.data.appid,
          timeStamp: res.data.timeStamp, // 时间戳
          nonceStr: res.data.nonceStr, // 随机字符串
          package: res.data.packageValue, // 返回prepay_id 参数值
          signType: res.data.signType, // 签名算法
          paySign: res.data.paySign, // 签名
          success: function (res) {
            console.log("success:" + JSON.stringify(res));
            uni.showToast({
              title: "支付成功",
              icon: "none",
              mask: true,
              duration: 1000,
            });
            that.goBack();
          },
          fail: function (err) {
            console.log("fail:" + JSON.stringify(err));
            uni.showToast({
              title: "支付失败",
              icon: "none",
              mask: true,
              duration: 1000,
            });
            return;
          },
        });
      });

    },

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值