【类 型】:test
【主 题】:测试支付接口 【描 述】: [原因]: [过程]:成功从 从后端拿去到 支付签名 并且测试调用 微信支付接口成功 [影响]: 【结 束】 # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
This commit is contained in:
parent
f99347e9d9
commit
5182f58fdb
@ -24,41 +24,37 @@
|
||||
'Token': this.$store.state.userInfo.token,
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
}
|
||||
}).then((res)=>{
|
||||
console.log(res)
|
||||
// if (res.data.status === 1) {
|
||||
// const payData = res.data.data
|
||||
// uni.requestPayment({
|
||||
// timeStamp: payData.timeStamp,
|
||||
// nonceStr: payData.nonceStr,
|
||||
// package: payData.package,
|
||||
// signType: payData.signType,
|
||||
// paySign: payData.paySign,
|
||||
// success: (paymentRes) => {
|
||||
// console.log('支付成功', paymentRes)
|
||||
// // 在这里处理支付成功后的逻辑
|
||||
// uni.showToast({
|
||||
// title: '支付成功',
|
||||
// icon: 'success'
|
||||
// })
|
||||
// },
|
||||
// fail: (paymentErr) => {
|
||||
// console.error('支付失败', paymentErr)
|
||||
// // 在这里处理支付失败后的逻辑
|
||||
// uni.showToast({
|
||||
// title: '支付失败',
|
||||
// icon: 'none'
|
||||
// })
|
||||
// }
|
||||
// })
|
||||
// } else {
|
||||
// uni.showToast({
|
||||
// title: res.data.msg || '支付请求失败',
|
||||
// icon: 'none'
|
||||
// })
|
||||
// }
|
||||
}).then((res) => {
|
||||
if (res.data.status === 1) {
|
||||
// 调用微信支付接口
|
||||
this.requestPayment(res.data.payMsg);
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
// 调用微信支付接口
|
||||
requestPayment(payMsg) {
|
||||
uni.requestPayment({
|
||||
timeStamp: payMsg.timeStamp,
|
||||
nonceStr: payMsg.nonceStr,
|
||||
package: payMsg.package,
|
||||
signType: payMsg.signType,
|
||||
paySign: payMsg.paySign,
|
||||
success: (res) => {
|
||||
uni.showToast({
|
||||
title: '支付成功',
|
||||
icon: 'success'
|
||||
});
|
||||
// 可以在这里处理支付成功后的逻辑
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.showToast({
|
||||
title: '支付失败',
|
||||
icon: 'none'
|
||||
});
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -151,8 +151,11 @@ export function checkUserInfo(store) {
|
||||
isTokenValid(store).then((isValid) => { //请求判断token是否有效
|
||||
if (isValid) { //如果token有效
|
||||
store.commit('setLoginState', true) //标记用户已成功登录
|
||||
initMqtt(store)//mqtt初始化 连接 并 订阅
|
||||
initMqtt(store) //mqtt初始化 连接 并 订阅
|
||||
console.log('hi')
|
||||
} else { //仍然无效 则最终跳转到 登陆页面
|
||||
store.commit('clearUserInfo') //清除内存中的token
|
||||
wxLogin(store)
|
||||
uni.redirectTo({
|
||||
url: '/pages/main/login'
|
||||
})
|
||||
@ -167,7 +170,7 @@ export function checkUserInfo(store) {
|
||||
* @return true有效 false无效
|
||||
*/
|
||||
async function isTokenValid(store) {
|
||||
const res = await uni.$u.http.post('/Api/Check', {}, {
|
||||
const res = await uni.$u.http.post('/Api/Check/index', {}, {
|
||||
header: {
|
||||
'Token': store.state.userInfo.token,
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
|
Loading…
Reference in New Issue
Block a user