支付宝小程序
获取用户信息
// 微信授权登录
getAuthCode: function(e) {
var that = this
my.getAuthCode({
scopes: ['auth_user'],
// 主动授权:auth_user,静默授权:auth_base。或者其它scope。如需同时获取用户多项授权,可在 scopes 中传入多个 scope 值。
success: (res) => {
console.log(res, "authCode")
var code = res.authCode
my.getAuthUserInfo({
success: (res1) => {
console.log(res1, "user_info")
if (res.authCode) {
console.log(res1, "user_info")
that.$request.httpRequest({
method: "post",
url: `index/user/ali_login`, //请求地址
data: {
code: code,
user_info: JSON.stringify(res1)
} //参数
}).then(res3 => {
console.log(res3, "that")
if (res3.data.code == 0) {
console.log( res3.data.data.token, " res3.data.data.token")
uni.setStorageSync("token", res3.data.data.token)
}
})
}
}
});
},
});
}
支付
payScuss() {
var that = this
uni.showModal({
title: '',
content: '确认支付',
success(res) {
if (res.confirm) {
that.$request.httpRequest({
method: 'POST',
url: 'index/park/goPay',
data: {
pay_type: 2,
order_id: that.orderId
}
}).then(res1 => {
console.log(res1, "uuuuuuuu")
if (res1.data.code == 0) {
my.tradePay({
// 调用统一收单交易创建接口(alipay.trade.create),获得返回字段支付宝交易号trade_no
tradeNO: res1.data.data.tradeNo,
success: (res) => {
console.log(res, "11")
// my.alert({
// content: JSON.stringify(res),
// });
that.autoplay = false
console.log(1)
if (res.resultCode == 9000) {
that.autoplay = false
uni.showToast({
title: "支付成功",
icon: 'none',
})
setTimeout(() => {
uni.reLaunch({
url: "../payScuss/payScuss?orderid=" + that.orderId + '&price=' + that.price,
})
}, 1000);
}else{
uni.showToast({
title: "支付失败",
icon: 'none',
})
}
},
fail: (res) => {
console.log(res, "22")
// my.alert({
// content: JSON.stringify(res),
// });
}
});
}
});
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},