chore: 支付开发
This commit is contained in:
parent
93f5a8afab
commit
4b4e5a73bd
@ -30,7 +30,8 @@
|
||||
"vant": "^4.9.21",
|
||||
"vconsole": "^3.15.1",
|
||||
"vue": "^3.5.18",
|
||||
"vue-router": "^4.5.1"
|
||||
"vue-router": "^4.5.1",
|
||||
"weixin-js-sdk": "^1.6.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/node22": "^22.0.2",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import api from '@/api'
|
||||
import wx from 'weixin-js-sdk'
|
||||
/**
|
||||
* 小程序内H5打开小程序页面
|
||||
* @param {string} type 小程序页面:index首页,mine我的
|
||||
@ -45,11 +46,28 @@ export const h5OpenMinProgram = (type = 'index', h5Url = '') => {
|
||||
* @param {string} paymentParams.paySign - 签名
|
||||
*/
|
||||
export const requestPayment = (paymentParams) => {
|
||||
wx.miniProgram.getEnv((res) => console.log(2222, res.miniprogram))
|
||||
// 向小程序发送支付请求
|
||||
console.warn('----- my data is window.wx111: ', window.wx)
|
||||
if (window.wx && window.wx.miniProgram) {
|
||||
if (wx && wx.miniProgram) {
|
||||
wx.chooseWXPay({
|
||||
// timestamp: paymentData.timestamp, // 支付签名时间戳
|
||||
// nonceStr: paymentData.nonceStr, // 支付签名随机串
|
||||
// package: paymentData.package, // 订单详情扩展字符串
|
||||
// signType: paymentData.signType, // 签名方式
|
||||
// paySign: paymentData.paySign, // 支付签名
|
||||
...paymentParams,
|
||||
success: function (res) {
|
||||
// 支付成功后的回调
|
||||
alert('支付成功')
|
||||
},
|
||||
fail: function (res) {
|
||||
console.warn('----- my data is res11: ', res)
|
||||
// 支付失败后的回调
|
||||
alert('支付失败')
|
||||
},
|
||||
})
|
||||
// 微信环境
|
||||
window.wx.miniProgram.postMessage({
|
||||
wx.miniProgram.postMessage({
|
||||
data: {
|
||||
type: 'pay',
|
||||
data: paymentParams,
|
||||
|
||||
@ -3406,6 +3406,11 @@ webpack-virtual-modules@^0.6.2:
|
||||
resolved "https://registry.npmmirror.com/webpack-virtual-modules/-/webpack-virtual-modules-0.6.2.tgz#057faa9065c8acf48f24cb57ac0e77739ab9a7e8"
|
||||
integrity sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==
|
||||
|
||||
weixin-js-sdk@^1.6.5:
|
||||
version "1.6.5"
|
||||
resolved "https://registry.npmmirror.com/weixin-js-sdk/-/weixin-js-sdk-1.6.5.tgz#01fe5220b91dbfe089fc0730d061be0e68271e6a"
|
||||
integrity sha512-Gph1WAWB2YN/lMOFB/ymb+hbU/wYazzJgu6PMMktCy9cSCeW5wA6Zwt0dpahJbJ+RJEwtTv2x9iIu0U4enuVSQ==
|
||||
|
||||
which@^2.0.1:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.npmmirror.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user