微信小程序中微信支付

一:微信小程序中的微信支付
1:你要先在微信公众平台里微信支付那里去关联你的商户号,然后去申请接入微信支付,需要提交所需的资料,需要管理员操作。
2:前提准备好后开发中

postMoney() { // 点击确认充值
    console.log("点击了");
    let that = this
    console.log(that.payChannelid);
    if(that.payChannelid == 0){
        uni.showToast({
            title: '请选择支付方式',
            icon: 'none'
        });
    }else if(that.payChannelid == 4){
        wx.showLoading({
            title: '加载中',
        })
        // 获取订单
        requestApi(prefix + "/order/createRechargeOrder", {
            amount: that.chargcount,  充值金额
            tenantId: that.tenantId,	租客id
            resourceId: that.resourceId	房间id
        }, "post").then(res => {
            if (res.success == true) {
                that.order = res.data 
                //保存订单
                requestApi(prefix + "/pay/findPrepaymentOrder", {
                    rechargeOrderId: that.order,  订单id
                    resourceId: that.resourceId  房间id
                }, "post").then(res => {
                    if (res.success == true) {
                        requestApi(prefix + "/pay/rechargeWxPay",{
                            rechargeOrderId: that.order,
                            resourceId: that.resourceId
                        },"post").then(res=>{
                            if(res.success == true){
                                wx.hideLoading(); //关闭loading
                                console.log(res.data.body);
                                res.data.body = JSON.parse(res.data.body)
                                console.log(res.data.body);
                                wx.requestPayment({ // 这一步是调起微信支付
                                    "appId": res.data.body.appId,  
                                    "timeStamp": res.data.body.timeStamp,
                                    "nonceStr": res.data.body.nonceStr,
                                    "package": res.data.body.package,
                                    "signType": res.data.body.signType,
                                    "paySign": res.data.body.paySign,
                                    "success": function(res) {
                                        wx.hideLoading(); //关闭loading
                                        uni.showToast({
                                            title: '充值成功',
                                            icon: 'none'
                                        });
                                    },
                                    "fail": function(res) {
                                        wx.hideLoading(); //关闭loading
                                        uni.showToast({
                                            title: '支付失败',
                                            icon: 'none'
                                        });
                                    },
                                    // "complete": function(res) {
                                    // 	wx.hideLoading(); //关闭loading
                                    // 	uni.showToast({
                                    // 		title: '取消支付',
                                    // 		icon: 'none'
                                    // 	});
                                    // }
                                })
                            }
                        })
                    }
                })
            }
        }) 
    }else if(that.payChannelid == 3){ //支付宝充值
        uni.showToast({
            title: '目前只支持微信支付',
            icon: 'none'
        });
    }
},

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值