您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页uni-app 支付

uni-app 支付

来源:二三四教育网

目前只解决了支付宝支付

判断用户是否登录

刚开始使用的undefined...一直没有走入代码块.....应该是null


                   if (this.uid === '' || this.uid === null) {
                        uni.hideLoading()
                        uni.showToast({
                            title: '您还没有登录',
                            icon: 'none'
                        });
                        return false;
                        console.log("udi", this.uid)
                    }

接着生成订单,进入三方支付

uni.request({
                    url: this.baseUrl + '/order/saveHotelOrder',
                    data: {
                        uid: uni.getStorageSync('userInfo').id,
                        cid: this.id,
                        num: this.num,
                        total: this.money,
                        name: this.realName,
                        phone: this.phone,
                        remark: this.real,
                        type: 1 //生成订单
                    },
                    header: {
                        'content-type': 
                    },
                    success: (res) => {
                        console.log(res)
                        if (res.data.meta.code == 200) {
                            //获得订单数据orderList
                            this.order = res.data.data
                            console.log("订单号", this.order)
                            this.pay()
                        }
                    },
                    fail: (e) => {
                        uni.hideLoading()
                        uni.showToast({
                            title: '请进行验证',
                            icon: 'none'
                        })
                    }
                })
            },
            pay() {
                uni.showToast({
                    title: '正在检测支付环境...',
                    icon: 'none',
                    success: (res) => {
                        if (this.type == 'alipay') {
                            uni.request({
                                url: this.baseUrl + '/payAlis',
                                method: 'POST',
                                data: {
                                    id: this.order,
                                    mo: this.money
                                },
                                header: {
                                    "content-type": 
                                },
                                success: res => {
                                    console.log(res.statusCode)
                                    if (res.statusCode == 200) {
                                        console.log(res.data)
                                        var data=res.data
                                        uni.getProvider({
                                            service: 'payment',
                                            success: function(res) {
                                                uni.requestPayment({
                                                    provider: 'alipay',
                                                    orderInfo: data, //微信、支付宝订单数据
                                                    success: function(res) {
                                                        console.log('success:' + JSON.stringify(res));
                                                    },
                                                    fail: function(err) {
                                                        console.log('fail:' + JSON.stringify(err));
                                                        uni.showModal({
                                                            title: '您已取消操作',
                                                            showCancel: true
                                                        })
                                                    }
                                                });
                                            }
                                        });

                                    }
                                },
                                fail: (e) => {
                                    uni.hideLoading()
                                    uni.showToast({
                                        title: JSON.stringify(e),
                                        icon: 'none'
                                    })
                                },
                                complete: () => {}
                            });
                        } else if (this.type == 'wechat') {
                            uni.request({
                                url: this.baseUrl + '/weixin/pay/wx',
                                method: 'POST',
                                data: {
                                    id: this.order,
                                    money: this.money
                                },
                                header: {
                                    "content-type": 
                                },
                                success: res => {
                                    console.log(res)

                                    var data = {
                                        appid: res.data.appId,
                                        noncestr: res.data.nonceStr,
                                        package: res.data.packages,
                                        partnerid: res.data.partnerId,
                                        prepayid: res.data.prepayId,
                                        timestamp: res.data.timeStamp,
                                        sign: res.data.sign
                                    }

                                    if (res.statusCode == 200) {

微信传参格式

                                        var data = {
                                            appid: res.data.appId,
                                            noncestr: res.data.nonceStr,
                                            package: res.data.packages,
                                            partnerid: res.data.partnerId,
                                            prepayid: res.data.prepayId,
                                            timestamp: res.data.timeStamp,
                                            sign: res.data.sign
                                        }
                                        uni.getProvider({
                                            service: 'payment',
                                            success: function(res) {
                                                // uni.showModal({
                                                //  title: data,
                                                //  showCancel: true
                                                // })
                                                uni.requestPayment({
                                                    provider: 'wxpay',
                                                    orderInfo: data, //微信、支付宝订单数据
                                                    success: function(res) {
                                                        console.log('success:' + JSON.stringify(res));
                                                    },
                                                    fail: function(err) {
                                                        uni.showToast({
                                                            title: JSON.stringify(err),
                                                            icon: 'none'
                                                        })
                                                        console.log('fail:' + JSON.stringify(err));
                                                    }
                                                });
                                            }
                                        });
                                    }
                                },
                                fail: (e) => {
                                    uni.hideLoading()
                                    uni.showToast({
                                        title: JSON.stringify(e),
                                        icon: 'none'
                                    })
                                },
                                complete: () => {}
                            });
                        }
                    },
                    fail: (e) => {
                        setTimeout(function() {
                            uni.showToast({
                                icon: "none",
                                title: "请检查网络"
                            })
                        }, 10000);
                    }
                });
            }

第一天没有调用成功返回


微信图片_20191129142345.jpg

微信只有第一次成功另外都是返回-1

查看官方文档 AD9B883F-758B-46ae-979E-ABE2792FB3E5.png

到现在还没有能够支付
=-=

----------------------------------------------------------------------------------------------*-

续版

image.png
有时候需要获取安卓应用的签名,直接通过keytool

keytool -list -v -keystore signfile.jks.keystore -storepass password

然后获取到签名文件内部的信息,MD5, SHA1,SHA256, 看需要,一般是填MD5,是要小写还是大写需要看要求选择了

生成签名文件 keytool -genkeypair -alias myappKey -keyalg RSA -validity 20000 -keystore shy_debug.jks

keytool -genkey -alias myappKey -keyalg RSA -validity 20000 -keystore myappSignKey.keystore



# 百度键入”微信开放平台”

# 



       生成安卓证书签名认证之后
1.使用自带包名打包
2.安装包中的应用信息,将其包名放到生成安卓签名的软件中   
    
3.将签名放到微信开发平台中

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务