小程序登录 微信支付测试 获取手机号
<button class="login-btn" type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">获取手机号</button>
<button class="login-btn" type="primary" @click="getUserInfo()">
微信用户一键登录
</button>
<button class="login-btn" type="primary" @click="wxPay()">
支付测试
</button>
const getUserInfo = ()=> {
wx.login({
success (res) {
if (res.code) {
console.log('登录成功!' , res)
} else {
console.log('登录失败!' + res.errMsg)
}
}
})
}
const wxPay = ()=>{
console.log('微信支付测试')
uni.requestPayment({
provider: 'wxpay',
orderInfo: '',
appId: "**********",
timeStamp:"1683628366",
nonceStr: "002a411f1c91410ba7c2bda5b714b4a4",
package: "prepay_id=wx09183246845132d6c4d8697be10b170000",
signType: "RSA",
paySign: "Js3Z4W93hF0AysOl/FSTgsfLXW7vBdkkIXOyZlIe3B+M1YAeljhlqFdzU8MVWHLjz5HhcA1lsuAJ/J5B1ZijK5aCC1ZIEQMXkALxxPQBu5tqsNMQtaKb9PoIg38ZE3FYx7wf9ztHjB+/nCGV+xGfRY18JkM3f7UuTFXKVYRJ0l81XcHD2rx7/TJhHxz80oUxNFfo78AY09f48e9r27qWHiQrKuOVSMpRulvrHTHtePQ3uAy0U4m+r/jK9ddbM3QGhmyNYah10CreztmBIxYmvT5Z1r9+kaIhAZwF9AAACiytjkhrgNXMsOZ8Wr0KvFOzz1dSxQzC4jrloETZbsDT/g==",
success: function (res) {
console.log(res,'111')
uni.showToast({
title: '支付成功!',
icon: 'success'
})
},
fail: function (err) {
console.log(err);
}
});
}
const getPhoneNumber =(e)=> {
console.log(e.detail.code)
}