修改好店支付的本页二维码逻辑
This commit is contained in:
parent
a0b51c8e9f
commit
71332e070a
@ -1,4 +1,5 @@
|
|||||||
export const apiPay = {
|
export const apiPay = {
|
||||||
pay: '/api/v1/lakala/preorder', //预下单
|
pay: '/api/v1/lakala/preorder', //预下单
|
||||||
queryPay: '/api/v1/lakala/trade-query' //查询交易结果
|
queryPay: '/api/v1/lakala/trade-query', //查询交易结果
|
||||||
|
qrcode: '/api/v2/wechat/quick-payment-record-crud/qrcode' //快捷支付二维码
|
||||||
}
|
}
|
||||||
@ -164,75 +164,37 @@ export default {
|
|||||||
this.Money = value;
|
this.Money = value;
|
||||||
},
|
},
|
||||||
|
|
||||||
createQrcode() {
|
|
||||||
uni.showLoading({
|
|
||||||
title: '加载中',
|
|
||||||
mask: true
|
|
||||||
});
|
|
||||||
uni.request({
|
|
||||||
url: 'https://api.weixin.qq.com/cgi-bin/token',
|
|
||||||
data: {
|
|
||||||
grant_type: 'client_credential',
|
|
||||||
appid: "wx1addb25675dd8e70",
|
|
||||||
secret: "1c153a91d0558b4c3834a4399ebc7496"
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
// 'custom-header': 'hello' //自定义请求头信息
|
|
||||||
},
|
|
||||||
success: (res) => {
|
|
||||||
// 检查是否成功获取到access_token
|
|
||||||
if (res.data && res.data.access_token) {
|
|
||||||
this.createQrcode2(res.data.access_token)
|
|
||||||
} else {
|
|
||||||
uni.hideLoading();
|
|
||||||
uni.showToast({
|
|
||||||
title: '获取二维码失败,请重试',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
console.error('获取微信access_token失败:', res);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: (err) => {
|
|
||||||
console.error('获取微信access_token失败:', err);
|
|
||||||
uni.hideLoading();
|
|
||||||
uni.showToast({
|
|
||||||
title: '获取二维码失败,请重试',
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
createQrcode2(e) {
|
|
||||||
let that = this
|
|
||||||
uni.request({
|
|
||||||
url: `https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=${e}`,
|
|
||||||
method: 'post',
|
|
||||||
data: {
|
|
||||||
path: '/packages/localLife/pay/index'
|
|
||||||
},
|
|
||||||
header: {
|
|
||||||
// 'custom-header': 'hello' //自定义请求头信息
|
|
||||||
'content-type': 'application/json'
|
|
||||||
},
|
|
||||||
responseType: 'arraybuffer',
|
|
||||||
success: (res) => {
|
|
||||||
uni.hideLoading();
|
|
||||||
// this.text = 'request success';
|
|
||||||
let data = uni.arrayBufferToBase64(res.data)
|
|
||||||
console.log(data);
|
|
||||||
that.myCode = 'data:image/png;base64,' + data
|
|
||||||
this.boxShow = !this.boxShow
|
|
||||||
},
|
|
||||||
fail: (res) => {
|
|
||||||
uni.hideLoading();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
changeBoxshadow2() {
|
changeBoxshadow2() {
|
||||||
this.boxShow = !this.boxShow
|
this.boxShow = !this.boxShow
|
||||||
},
|
},
|
||||||
changeBoxshadow() {
|
changeBoxshadow() {
|
||||||
this.createQrcode()
|
uni.showLoading({
|
||||||
|
title: '加载中',
|
||||||
|
mask: true
|
||||||
|
});
|
||||||
|
const params = {
|
||||||
|
merchant_id: this.info.id,
|
||||||
|
}
|
||||||
|
request(apiPay.qrcode, "POST", params).then(res => {
|
||||||
|
uni.hideLoading();
|
||||||
|
if (res && res.qrcode_image_url) {
|
||||||
|
this.myCode = picUrl + res.qrcode_image_url;
|
||||||
|
this.boxShow = !this.boxShow;
|
||||||
|
} else {
|
||||||
|
uni.showToast({
|
||||||
|
title: '获取二维码失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('获取二维码失败:', err);
|
||||||
|
uni.hideLoading();
|
||||||
|
uni.showToast({
|
||||||
|
title: '获取二维码失败,请重试',
|
||||||
|
icon: 'none'
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
confirm(e) {
|
confirm(e) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user