mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
feat(lottery):草创抽奖详情
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* @file plugins Mys index.ts
|
* @file plugins Mys index.ts
|
||||||
* @description Mys plugin index
|
* @description Mys plugin index
|
||||||
* @author BTMuli<bt-muli@outlook.com>
|
* @author BTMuli<bt-muli@outlook.com>
|
||||||
* @since Alpha
|
* @since Alpha v0.1.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Post
|
// Post
|
||||||
@@ -14,6 +14,8 @@ import { getGachaCard } from "./utils/gacha";
|
|||||||
// News
|
// News
|
||||||
import { getNoticeList, getActivityList, getNewsList } from "./request/news";
|
import { getNoticeList, getActivityList, getNewsList } from "./request/news";
|
||||||
import { getNoticeCard, getActivityCard, getNewsCard } from "./utils/news";
|
import { getNoticeCard, getActivityCard, getNewsCard } from "./utils/news";
|
||||||
|
// Lottery
|
||||||
|
import { getLotteryData } from "./request/lottery";
|
||||||
|
|
||||||
const MysOper = {
|
const MysOper = {
|
||||||
Post: {
|
Post: {
|
||||||
@@ -36,6 +38,9 @@ const MysOper = {
|
|||||||
news: getNewsCard,
|
news: getNewsCard,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Lottery: {
|
||||||
|
get: getLotteryData,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MysOper;
|
export default MysOper;
|
||||||
|
|||||||
83
src/plugins/Mys/interface/lottery.ts
Normal file
83
src/plugins/Mys/interface/lottery.ts
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
* @file plugins Mys interface lottery.ts
|
||||||
|
* @description Mys 插件抽奖接口
|
||||||
|
* @author BTMuli<bt-muli@outlook.com>
|
||||||
|
* @since Alpha v0.1.1
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { MysResponse } from "./base";
|
||||||
|
import { User } from "./user";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 抽奖返回数据
|
||||||
|
* @since Alpha v0.1.1
|
||||||
|
* @interface LotteryResponse
|
||||||
|
* @extends {MysResponse}
|
||||||
|
* @property {LotteryData} data.show_lottery 抽奖数据
|
||||||
|
* @return {LotteryResponse}
|
||||||
|
*/
|
||||||
|
export interface LotteryResponse extends MysResponse {
|
||||||
|
data: {
|
||||||
|
show_lottery: LotteryData;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 抽奖数据
|
||||||
|
* @since Alpha v0.1.1
|
||||||
|
* @interface LotteryData
|
||||||
|
* @property {string} id 抽奖 ID
|
||||||
|
* @property {User} creator 创建者
|
||||||
|
* @property {string} draw_time 抽奖时间
|
||||||
|
* @property {string} participant_way 参与方式 // Forward: 转发
|
||||||
|
* @property {boolean} is_expect_unfocus_user 是否限制未关注用户
|
||||||
|
* @property {boolean} is_expect_non_real_name_user 是否限制未实名用户
|
||||||
|
* @property {LotteryReward[]} user_rewards 用户奖励
|
||||||
|
* @property {string} status 状态 // Settled: 已结算
|
||||||
|
* @property {boolean} is_blocked 是否被屏蔽
|
||||||
|
* @property {string} user_status 用户状态 // NotParticipant: 未参与
|
||||||
|
* @property {boolean} is_upload_address 是否上传地址
|
||||||
|
* @property {string} lottery_entity_summary 抽奖实体摘要
|
||||||
|
* @property {string} entity_id 实体 ID // 若为帖子,则为帖子 ID
|
||||||
|
* @property {string} entity_type 实体类型 // Post: 帖子
|
||||||
|
* @property {string} now_time 当前时间
|
||||||
|
* @return {LotteryData}
|
||||||
|
*/
|
||||||
|
export interface LotteryData {
|
||||||
|
id: string;
|
||||||
|
creator: User;
|
||||||
|
draw_time: string;
|
||||||
|
participant_way: string;
|
||||||
|
is_expect_unfocus_user: boolean;
|
||||||
|
is_expect_non_real_name_user: boolean;
|
||||||
|
user_rewards: LotteryReward[];
|
||||||
|
status: string;
|
||||||
|
is_blocked: boolean;
|
||||||
|
user_status: string;
|
||||||
|
is_upload_address: boolean;
|
||||||
|
lottery_entity_summary: string;
|
||||||
|
entity_id: string;
|
||||||
|
entity_type: string;
|
||||||
|
now_time: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 抽奖奖励
|
||||||
|
* @since Alpha v0.1.1
|
||||||
|
* @interface LotteryReward
|
||||||
|
* @property {string} reward_name 奖励名称
|
||||||
|
* @property {number} winner_number 获奖人数
|
||||||
|
* @property {number} scheduled_winner_number 预计获奖人数
|
||||||
|
* @property {boolean} is_send_by_post 是否通过帖子发放
|
||||||
|
* @property {User[]} users 用户列表
|
||||||
|
* @property {string} id 奖励 ID
|
||||||
|
* @return {LotteryReward}
|
||||||
|
*/
|
||||||
|
export interface LotteryReward {
|
||||||
|
reward_name: string;
|
||||||
|
winner_number: number;
|
||||||
|
scheduled_winner_number: number;
|
||||||
|
is_send_by_post: boolean;
|
||||||
|
users: User[];
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
32
src/plugins/Mys/request/lottery.ts
Normal file
32
src/plugins/Mys/request/lottery.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* @file plugins Mys interface lottery.ts
|
||||||
|
* @description Mys 插件抽奖接口
|
||||||
|
* @author BTMuli<bt-muli@outlook.com>
|
||||||
|
* @since Alpha v0.1.1
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { http } from "@tauri-apps/api";
|
||||||
|
import { LotteryResponse, LotteryData } from "../interface/lottery";
|
||||||
|
|
||||||
|
// 抽奖 API
|
||||||
|
const LOTTERY_API =
|
||||||
|
"https://bbs-api.miyoushe.com/painter/wapi/lottery/user/show?gids=2&id={lottery_id}";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description 获取抽奖信息
|
||||||
|
* @since Alpha v0.1.1
|
||||||
|
* @param {string} lottery_id 抽奖 ID
|
||||||
|
* @return {Promise<LotteryData>}
|
||||||
|
*/
|
||||||
|
export async function getLotteryData(lottery_id: string): Promise<LotteryData> {
|
||||||
|
return await http
|
||||||
|
.fetch<LotteryResponse>(LOTTERY_API.replace("{lottery_id}", lottery_id), {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
return res.data.data.show_lottery;
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -7,6 +7,8 @@
|
|||||||
// 帖子相关
|
// 帖子相关
|
||||||
import TPost from "../../views/t-post.vue";
|
import TPost from "../../views/t-post.vue";
|
||||||
import TPostJson from "../../views/t-post-json.vue";
|
import TPostJson from "../../views/t-post-json.vue";
|
||||||
|
// 抽奖
|
||||||
|
import TLottery from "../../views/t-lottery.vue";
|
||||||
|
|
||||||
const subRoutes = [
|
const subRoutes = [
|
||||||
{
|
{
|
||||||
@@ -19,6 +21,11 @@ const subRoutes = [
|
|||||||
name: "帖子详情(JSON)",
|
name: "帖子详情(JSON)",
|
||||||
component: TPostJson,
|
component: TPostJson,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/lottery/:lottery_id",
|
||||||
|
name: "抽奖详情",
|
||||||
|
component: TLottery,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export default subRoutes;
|
export default subRoutes;
|
||||||
|
|||||||
42
src/views/t-lottery.vue
Normal file
42
src/views/t-lottery.vue
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<template>
|
||||||
|
<div v-if="loading">
|
||||||
|
<t-loading :empty="loadingEmpty" :title="loadingTitle" />
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<h1>{{ lottery_id }}</h1>
|
||||||
|
{{ lottery }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
// vue
|
||||||
|
import { ref, onMounted } from "vue";
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
|
import TLoading from "../components/t-loading.vue";
|
||||||
|
// plugins
|
||||||
|
import MysOper from "../plugins/Mys";
|
||||||
|
|
||||||
|
// loading
|
||||||
|
const loading = ref(true as boolean);
|
||||||
|
const loadingTitle = ref("正在加载");
|
||||||
|
const loadingEmpty = ref(false as boolean);
|
||||||
|
|
||||||
|
// 数据
|
||||||
|
const lottery_id = useRoute().params.lottery_id as string;
|
||||||
|
const lottery = ref({} as any);
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
// 检查数据
|
||||||
|
if (!lottery_id) {
|
||||||
|
loadingEmpty.value = true;
|
||||||
|
loadingTitle.value = "未找到数据";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 获取数据
|
||||||
|
loadingTitle.value = "正在获取数据...";
|
||||||
|
lottery.value = await MysOper.Lottery.get(lottery_id);
|
||||||
|
setInterval(() => {
|
||||||
|
loading.value = false;
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<style></style>
|
||||||
Reference in New Issue
Block a user