fix: pay noticy api
This commit is contained in:
@@ -7,3 +7,10 @@ export const createOrder = async (data) => {
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
export const getVipPlan = async () => {
|
||||
return request({
|
||||
url: "/api/blessing/vip/plan",
|
||||
method: "GET",
|
||||
});
|
||||
};
|
||||
|
||||
@@ -53,10 +53,10 @@
|
||||
<view v-if="plan.badge" class="plan-badge" :class="plan.badgeType">
|
||||
{{ plan.badge }}
|
||||
</view>
|
||||
<text class="plan-duration">{{ plan.duration }}</text>
|
||||
<text class="plan-duration">{{ plan.name }}</text>
|
||||
<view class="plan-price">
|
||||
<text class="currency">¥</text>
|
||||
<text class="amount">{{ plan.price }}</text>
|
||||
<text class="amount">{{ plan.price / 100 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -113,13 +113,14 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
import { ref, onMounted } from "vue";
|
||||
|
||||
import {
|
||||
getBavBarHeight,
|
||||
getStatusBarHeight as getStatus,
|
||||
} from "@/utils/system";
|
||||
import { useUserStore } from "@/stores/user";
|
||||
import { createOrder } from "@/api/pay.js";
|
||||
import { createOrder, getVipPlan } from "@/api/pay.js";
|
||||
|
||||
const navBarHeight = getBavBarHeight();
|
||||
const statusBarHeight = getStatus();
|
||||
@@ -128,24 +129,7 @@ const userInfo = userStore.userInfo;
|
||||
|
||||
const selectedPlanIndex = ref(1);
|
||||
|
||||
const plans = [
|
||||
{ duration: "一个月", price: "8.8", total: 880 },
|
||||
{
|
||||
duration: "一个季度",
|
||||
price: "18",
|
||||
badge: "热销",
|
||||
badgeType: "hot",
|
||||
total: 18000,
|
||||
},
|
||||
{ duration: "一年", price: "48", total: 48000 },
|
||||
{
|
||||
duration: "永久会员",
|
||||
price: "88",
|
||||
badge: "最划算",
|
||||
badgeType: "best",
|
||||
total: 88000,
|
||||
},
|
||||
];
|
||||
const plans = ref([]);
|
||||
|
||||
const benefits = [
|
||||
{ name: "高级模板", icon: "star-filled", color: "#ff3b30", bg: "#fff0f0" },
|
||||
@@ -168,6 +152,15 @@ const notes = [
|
||||
"最终解释权归 2026 新春助手团队所有。",
|
||||
];
|
||||
|
||||
onMounted(() => {
|
||||
getVipPlanList();
|
||||
});
|
||||
|
||||
const getVipPlanList = async () => {
|
||||
const planRes = await getVipPlan();
|
||||
plans.value = planRes;
|
||||
};
|
||||
|
||||
const goBack = () => {
|
||||
uni.navigateBack();
|
||||
};
|
||||
@@ -177,22 +170,18 @@ const selectPlan = (index) => {
|
||||
};
|
||||
|
||||
const handlePurchase = async () => {
|
||||
const plan = plans[selectedPlanIndex.value || 0];
|
||||
const plan = plans.value[selectedPlanIndex.value || 0];
|
||||
console.log("plan", plan);
|
||||
const orderRes = await createOrder({
|
||||
description: `新春会员购买 ${plan.duration} ${plan.price}`,
|
||||
total: plan.total,
|
||||
planId: plan.id,
|
||||
});
|
||||
if (orderRes.payParams) {
|
||||
if (orderRes?.payParams) {
|
||||
wx.requestPayment({
|
||||
...orderRes.payParams,
|
||||
success(res) {
|
||||
// 等后端回调,不要直接认为支付成功
|
||||
console.log(11111, res);
|
||||
},
|
||||
fail(res) {
|
||||
console.log(22222, res);
|
||||
},
|
||||
fail(res) {},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user