183 lines
5.1 KiB
Vue
183 lines
5.1 KiB
Vue
<template>
|
||
<div class="app-container" v-loading="loading">
|
||
<el-card shadow="never" class="mb-3">
|
||
<div class="flex h-full items-center">
|
||
<div v-html="headerTitle" />
|
||
<img class="w-10 h-10 ml-3 rounded-full" :src="suffImg()" />
|
||
</div>
|
||
</el-card>
|
||
|
||
<div class="flex flex-wrap">
|
||
<div class="cont-card">
|
||
<el-card shadow="never">
|
||
<template #header>
|
||
<span class="text-[var(--el-text-color-secondary)]">成为VIP</span>
|
||
</template>
|
||
|
||
<el-form class="ml-2">
|
||
<el-text>选择会员期限:</el-text>
|
||
<div class="ml-18 mt-4">
|
||
<el-radio-group v-model.number="selectType" size="large">
|
||
<el-radio v-for="t in vipType" :value="t.value">{{ `${t.period}:${t.cost} 音符` }}</el-radio>
|
||
</el-radio-group>
|
||
</div>
|
||
</el-form>
|
||
|
||
<template #footer>
|
||
<div class="text-align-center h-7">
|
||
<el-button class="-mt-1" type="primary" @click="handleSubmit">确定兑换</el-button>
|
||
</div>
|
||
</template>
|
||
</el-card>
|
||
</div>
|
||
<div class="cont-card">
|
||
<el-card shadow="never">
|
||
<template #header>
|
||
<div class="flex-x-between">
|
||
<span class="text-[var(--el-text-color-secondary)]">会员特权</span>
|
||
</div>
|
||
</template>
|
||
|
||
<div class="ml-2 h-[200px]">
|
||
<el-text>作为VIP会员,您将拥有以下特权:</el-text>
|
||
<div class="ml-10 mt-6">
|
||
<el-text style="padding: 4px 0 4px 0" type="warning">
|
||
<el-icon><SuccessFilled /></el-icon>
|
||
唱作魔方所有版本免收功能费
|
||
</el-text>
|
||
<el-text style="padding: 4px 0 4px 0" type="warning">
|
||
<el-icon><SuccessFilled /></el-icon>
|
||
唱作魔方所有版本可使用离线保存功能
|
||
</el-text>
|
||
<el-text style="padding: 4px 0 4px 0" type="warning">
|
||
<el-icon><SuccessFilled /></el-icon>
|
||
使用唱作魔方所有版本收费风格享有8折优惠
|
||
</el-text>
|
||
</div>
|
||
</div>
|
||
<template #footer>
|
||
<div class="text-align-center h-7">
|
||
<span>更多VIP会员特权敬请期待!</span>
|
||
</div>
|
||
</template>
|
||
</el-card>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<script setup lang="ts">
|
||
import UserAPI from "@/api/user";
|
||
import { useUserStore } from "@/store";
|
||
import { formatDateCN } from "@/utils/format";
|
||
|
||
const userStore = useUserStore();
|
||
|
||
const headerTitle = computed(() => {
|
||
switch (userStore.account.vipTime) {
|
||
case -1:
|
||
return `尊敬的VIP<strong style="font-size:20px;color: red" > 终身 </strong>会员!您已拥有永久的VIP会员特权`;
|
||
case 0:
|
||
return "您还没有成为唱作网VIP会员哦";
|
||
case -2:
|
||
return `很抱歉!您的VIP会员身份已<strong style="font-size:20px;color: red" > 过期 </strong>`;
|
||
default:
|
||
return (
|
||
`尊敬的VIP会员!您的VIP会员将于 <strong style="font-size:20px;color: red" >` +
|
||
formatDateCN(userStore.account.vipTime) + //1733292197) + //
|
||
`</strong> 到期`
|
||
);
|
||
}
|
||
});
|
||
|
||
function suffImg() {
|
||
switch (userStore.account.vipTime) {
|
||
case 0:
|
||
case -2:
|
||
return new URL(`@/assets/images/sad.png`, import.meta.url).href;
|
||
default:
|
||
return new URL(`@/assets/images/flower.png`, import.meta.url).href;
|
||
}
|
||
}
|
||
|
||
const vipType = [
|
||
{
|
||
value: 0,
|
||
period: "一月",
|
||
cost: "1000",
|
||
},
|
||
{
|
||
value: 1,
|
||
period: "半年",
|
||
cost: "5500",
|
||
},
|
||
{
|
||
value: 2,
|
||
period: "一年",
|
||
cost: "10000",
|
||
},
|
||
{
|
||
value: 3,
|
||
period: "两年",
|
||
cost: "20000",
|
||
},
|
||
];
|
||
|
||
const loading = ref(false);
|
||
const selectType = ref(0);
|
||
|
||
function handleSubmit() {
|
||
if (userStore.account.vipTime == -1) {
|
||
ElMessage.success("您已是终身VIP,无需再兑换");
|
||
return;
|
||
}
|
||
|
||
ElMessageBox.confirm(
|
||
"确认使用 " + vipType[selectType.value].cost + " 音符兑换 " + vipType[selectType.value].period + " VIP会员?",
|
||
"",
|
||
{
|
||
confirmButtonText: "确定",
|
||
cancelButtonText: "取消",
|
||
type: "warning",
|
||
}
|
||
).then(
|
||
function () {
|
||
loading.value = true;
|
||
UserAPI.beingVIP(selectType.value)
|
||
.then((data) => {
|
||
// console.log(data);
|
||
if (data == 0) {
|
||
ElMessage.success("您已是终身VIP,无需再兑换");
|
||
} else {
|
||
userStore.account.vipTime = data;
|
||
userStore.account.integral! -= parseInt(vipType[selectType.value].cost);
|
||
ElMessage.success("VIP兑换成功");
|
||
}
|
||
})
|
||
.finally(() => (loading.value = false));
|
||
},
|
||
function () {
|
||
ElMessage.info("已取消兑换");
|
||
}
|
||
);
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
:deep(.el-text) {
|
||
display: block;
|
||
margin-bottom: 14px;
|
||
font-size: 16px;
|
||
}
|
||
:deep(.el-radio) {
|
||
.el-radio__label {
|
||
font-size: 16px;
|
||
}
|
||
width: 100%;
|
||
}
|
||
.cont-card {
|
||
margin: 0 10px 10px 0;
|
||
width: 450px;
|
||
}
|
||
</style>
|