|
@@ -22,9 +22,9 @@ |
|
|
//#region 导入 |
|
|
//#region 导入 |
|
|
import { ref, reactive } from "vue"; |
|
|
import { ref, reactive } from "vue"; |
|
|
import { getCoinList, createOrder, createPay } from "../../api/coin.js"; |
|
|
import { getCoinList, createOrder, createPay } from "../../api/coin.js"; |
|
|
//#endregion -------------- |
|
|
|
|
|
|
|
|
import { userInfoModules } from "@/store/modules/userInfo"; |
|
|
|
|
|
const userInfoModulesPinia = userInfoModules(); |
|
|
|
|
|
|
|
|
//#region 列表数据 |
|
|
|
|
|
const active = ref(""); |
|
|
const active = ref(""); |
|
|
const coinList = ref([]); |
|
|
const coinList = ref([]); |
|
|
function select(item) { |
|
|
function select(item) { |
|
@@ -36,6 +36,7 @@ const goPro = () => { |
|
|
}); |
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 获取金币价格列表 |
|
|
const getList = async () => { |
|
|
const getList = async () => { |
|
|
try { |
|
|
try { |
|
|
const res = await getCoinList(5, 1); |
|
|
const res = await getCoinList(5, 1); |
|
@@ -46,25 +47,56 @@ const getList = async () => { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 创建订单 |
|
|
const createProductOrder = async () => { |
|
|
const createProductOrder = async () => { |
|
|
try { |
|
|
try { |
|
|
const res = await createOrder(1); |
|
|
const res = await createOrder(1); |
|
|
console.log(res, "res"); |
|
|
|
|
|
// createProductPay() |
|
|
|
|
|
|
|
|
console.log(res.data, "res"); |
|
|
|
|
|
createProductPay(res.data); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.log(error, "error"); |
|
|
console.log(error, "error"); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const createProductPay = async () => { |
|
|
|
|
|
|
|
|
// 获取订单数据 |
|
|
|
|
|
const createProductPay = async (orderNumber) => { |
|
|
|
|
|
const openId = userInfoModulesPinia.openId; |
|
|
try { |
|
|
try { |
|
|
const res = await createPay(1); |
|
|
|
|
|
|
|
|
const data = { |
|
|
|
|
|
orderNumber, |
|
|
|
|
|
openId, |
|
|
|
|
|
payVendor: 1, //Number,1:微信;2:抖音 |
|
|
|
|
|
}; |
|
|
|
|
|
const res = await createPay(data); |
|
|
console.log(res, "res"); |
|
|
console.log(res, "res"); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
console.log(error, "error"); |
|
|
console.log(error, "error"); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 拉起收银台 |
|
|
|
|
|
const startPay = (data) => { |
|
|
|
|
|
var orderInfo = { |
|
|
|
|
|
appid: "wx499********7c70e", |
|
|
|
|
|
partnerid: "148*****52", |
|
|
|
|
|
prepayid: "wx202254********************fbe90000", |
|
|
|
|
|
package: "Sign=WXPay", |
|
|
|
|
|
noncestr: "c5sEwbaNPiXAF3iv", |
|
|
|
|
|
timestamp: 1597935292, |
|
|
|
|
|
sign: "A842B45937F6EFF60DEC7A2EAA52D5A0", |
|
|
|
|
|
}; |
|
|
|
|
|
uni.requestPayment({ |
|
|
|
|
|
provider: "wxpay", //固定值为"wxpay" |
|
|
|
|
|
orderInfo: orderInfo, |
|
|
|
|
|
success: function (res) { |
|
|
|
|
|
console.log(res, "res"); |
|
|
|
|
|
}, |
|
|
|
|
|
fail: function (err) { |
|
|
|
|
|
console.log("支付失败", err); |
|
|
|
|
|
}, |
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
getList(); |
|
|
getList(); |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|