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