From d9d14eddee1de6c1d9b29b4afce7958115fc8541 Mon Sep 17 00:00:00 2001 From: yziiy <15979918+mayday-yziiy@user.noreply.gitee.com> Date: Wed, 7 Jan 2026 18:02:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=9F=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/BlindBox/turntable/hook.tsx | 94 +++++++------- .../roomList/Turntable/lotteryResults.vue | 119 +++++++++--------- vite.config.ts | 4 +- 3 files changed, 112 insertions(+), 105 deletions(-) diff --git a/src/views/BlindBox/turntable/hook.tsx b/src/views/BlindBox/turntable/hook.tsx index 2ce98eb..74ed850 100644 --- a/src/views/BlindBox/turntable/hook.tsx +++ b/src/views/BlindBox/turntable/hook.tsx @@ -9,9 +9,9 @@ import { getBlindBoxRule, settingBlindBoxRule } from "@/api/modules/blindBox"; -import TurntableView from './Turntable.vue'; +import TurntableView from "./Turntable.vue"; import editForm from "./form.vue"; -import settingRuleView from './settingRule.vue' +import settingRuleView from "./settingRule.vue"; import { addDialog } from "@/components/ReDialog"; import { message } from "@/utils/message"; export function useData() { @@ -28,22 +28,23 @@ export function useData() { }); const searchForm = ref({ gift_id: "", - gift_name: "", + gift_name: "" }); - const activeName = ref(0) - const typeList = ref([]) + const activeName = ref(0); + const typeList = ref([]); const statisticsList = ref([ { label: "每期总次数", prop: "total_count" }, { label: "每期总礼物价值(收入)", prop: "total_price" }, { - label: "每期总抽奖花费(支出)", prop: "total_cost" + label: "每期总抽奖花费(支出)", + prop: "total_cost" }, - { label: "每期统计(收入/支出)", prop: "profit_loss_ratio", tip: "%" }, + { label: "每期统计(收入/支出)", prop: "profit_loss_ratio", tip: "%" } // { label: "今日抽奖人数", prop: "today_count_user" }, // { label: "今日抽奖次数", prop: "today_total_count" }, // { label: "今日抽奖收入", prop: "today_total_price" }, - ]) - const statisticsData = ref({}) + ]); + const statisticsData = ref({}); const searchLabel = ref([ { label: "礼物ID", prop: "gift_id", type: "input" }, { label: "礼物名称", prop: "gift_name", type: "input" } @@ -90,14 +91,18 @@ export function useData() { label: "公屏", prop: "is_public_screen", cellRenderer: ({ row }) => ( - {row.is_public_screen === 1 ? '是' : '否'} + + {row.is_public_screen === 1 ? "是" : "否"} + ) }, { label: "全服播报", prop: "is_public_server", cellRenderer: ({ row }) => ( - {row.is_public_server === 1 ? '是' : '否'} + + {row.is_public_server === 1 ? "是" : "否"} + ) }, { @@ -111,23 +116,23 @@ export function useData() { slot: "operation" } ]); - const onSearch = async (formData) => { + const onSearch = async formData => { loading.value = true; - searchForm.value = { ...formData } + searchForm.value = { ...formData }; const { data, code } = await queryBlindBoxList({ ...formData, gift_bag_id: activeName.value, page: pagination.value.currentPage, - page_limit: pagination.value.pageSize, - + page_limit: pagination.value.pageSize }); if (code) { tableList.value = data.lists.map(ele => { return { - ...ele, ...data.total - } + ...ele, + ...data.total + }; }); - statisticsData.value = data.total_data + statisticsData.value = data.total_data; pagination.value.total = data.count; pagination.value.currentPage = data.page; } @@ -142,32 +147,33 @@ export function useData() { onSearch(searchForm.value); }; const getType = async () => { - const { code, data } = await queryBoxTypeList({ activities_id: 5 }) - typeList.value = code ? data.map(ele => { - return { - label: ele.name, - value: ele.id - } - }) : [] - if (code) handleClick(data[0].id) - } - const handleClick = (id) => { - activeName.value = id + const { code, data } = await queryBoxTypeList({ activities_id: 5 }); + typeList.value = code + ? data.map(ele => { + return { + label: ele.name, + value: ele.id + }; + }) + : []; + if (code) handleClick(data[0].id); + }; + const handleClick = id => { + activeName.value = id; onSearch(searchForm.value); - } - // + }; + // const resetSetting = async () => { const { data, code } = await resetBlindBoxRule({ gift_bag_id: activeName.value - }) + }); if (code) { message(`重置成功`, { type: "success" }); handleClick(activeName.value); } - - } + }; const handleDelete = async rowData => { const { code } = await removeBlindBoxData({ id: rowData.id }); if (code) { @@ -197,7 +203,7 @@ export function useData() { const saveData = async form => { const { code } = await addBlindBoxData({ ...form, - gift_bag_id: activeName.value, + gift_bag_id: activeName.value }); if (code) { message("新增成功", { type: "success" }); @@ -238,7 +244,9 @@ export function useData() { }); }; const setting = async () => { - const { data, code } = await getBlindBoxRule({ gift_bag_id: activeName.value }) + const { data, code } = await getBlindBoxRule({ + gift_bag_id: activeName.value + }); addDialog({ title: `设置盲盒规则`, props: { @@ -248,7 +256,8 @@ export function useData() { }, width: "40%", closeOnClickModal: false, - contentRenderer: () => h(settingRuleView, { ref: formRef, formInline: null }), + contentRenderer: () => + h(settingRuleView, { ref: formRef, formInline: null }), beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; @@ -265,12 +274,12 @@ export function useData() { FormRef.validate(valid => { if (valid) { // console.log("curData", curData); - saveData(curData) + saveData(curData); } }); } }); - } + }; // 开奖记录 const openLotteryRecord = () => { addDialog({ @@ -281,9 +290,10 @@ export function useData() { fullscreen: true, hideFooter: true, closeOnClickModal: false, - contentRenderer: () => h(TurntableView, { ref: formRef, formInline: null }) + contentRenderer: () => + h(TurntableView, { ref: formRef, formInline: null }) }); - } + }; return { searchForm, searchLabel, @@ -307,4 +317,4 @@ export function useData() { setting, openLotteryRecord }; -} \ No newline at end of file +} diff --git a/src/views/room/roomList/Turntable/lotteryResults.vue b/src/views/room/roomList/Turntable/lotteryResults.vue index abfd624..294a5bd 100644 --- a/src/views/room/roomList/Turntable/lotteryResults.vue +++ b/src/views/room/roomList/Turntable/lotteryResults.vue @@ -2,12 +2,8 @@ // 开奖记录 import { ref, onMounted, nextTick } from "vue"; import SearchForm from "@/components/SearchForm/index.vue"; -import { - queryBoxTypeList -} from "@/api/modules/blindBox"; -import { - queryTurntableRecord -} from "@/api/modules/room"; +import { queryBoxTypeList } from "@/api/modules/blindBox"; +import { queryTurntableRecord } from "@/api/modules/room"; const searchLabel = ref([ { label: "盲盒礼包", @@ -21,19 +17,19 @@ const searchLabel = ref([ { label: "开始时间", prop: "stime", type: "date" }, { label: "结束时间", prop: "etime", type: "date" } ]); -const props = defineProps(["roomId", 'BagId', 'giftBagId']); +const props = defineProps(["roomId", "BagId", "giftBagId"]); // console.log('传递过来的参数', ) -const typeList = ref([]) -const formatDate = (date) => { +const typeList = ref([]); +const formatDate = date => { // 获取年份 const year = date.getFullYear(); // 获取月份,并将其转为两位数格式 - const month = String(date.getMonth() + 1).padStart(2, '0'); + const month = String(date.getMonth() + 1).padStart(2, "0"); // 获取日期,并将其转为两位数格式 - const day = String(date.getDate()).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, "0"); // 返回格式化后的日期字符串 return `${year}-${month}-${day} 00:00:00`; -} +}; const getTodayAndWeekAgo = () => { const today = new Date(); // 获取今天的日期对象 const weekAgo = new Date(); // 获取当前日期对象 @@ -44,7 +40,7 @@ const getTodayAndWeekAgo = () => { today: formatDate(today), weekAgo: formatDate(weekAgo) }; -} +}; const searchForm = ref({ gift_bag_id: "", user_id: "", @@ -59,18 +55,19 @@ const pagination = ref({ currentPage: 1, background: true }); -const statisticsData = ref() -const tableList = ref([]) +const statisticsData = ref(); +const tableList = ref([]); const statisticsList = ref([ { label: "总抽奖次数", prop: "total" }, { label: "总抽奖金额(支出)", prop: "total_money" }, { - label: "总礼物价值(收入)", prop: "total_gift_money" + label: "总礼物价值(收入)", + prop: "total_gift_money" }, { label: "统计(收入/支出)", prop: "ratio", tip: "%" }, { label: "盈亏(收入-支出)", prop: "profit_loss" }, - { label: "盈亏比(盈亏/支出)", prop: "profit_loss_ratio", tip: "%" }, -]) + { label: "盈亏比(盈亏/支出)", prop: "profit_loss_ratio", tip: "%" } +]); const dynamicflowColumns = ref([ { label: "ID", @@ -80,10 +77,10 @@ const dynamicflowColumns = ref([ label: "盲盒转盘类型", prop: "gift_bag_type" }, - // { - // label: "期数", - // prop: "periods" - // }, + { + label: "期数", + prop: "periods" + }, { label: "开奖人ID", prop: "user_name" @@ -116,75 +113,77 @@ const dynamicflowColumns = ref([ label: "创建时间", prop: "createtime" } -]) +]); const getType = async () => { - const { code, data } = await queryBoxTypeList({ activities_id: 5 }) - typeList.value = code ? data.map(ele => { - return { - label: ele.name, - value: ele.id - } - }) : [] - if (code) { - searchLabel.value[0].optionList = typeList.value - searchForm.value.gift_bag_id = Number(props.giftBagId) || data[0].id - nextTick(() => { - getData(searchForm.value) + const { code, data } = await queryBoxTypeList({ activities_id: 5 }); + typeList.value = code + ? data.map(ele => { + return { + label: ele.name, + value: ele.id + }; }) + : []; + if (code) { + searchLabel.value[0].optionList = typeList.value; + searchForm.value.gift_bag_id = Number(props.giftBagId) || data[0].id; + nextTick(() => { + getData(searchForm.value); + }); } -} -const getData = async (formData) => { - searchForm.value = { ...formData } +}; +const getData = async formData => { + searchForm.value = { ...formData }; const { data, code } = await queryTurntableRecord({ ...formData, page: pagination.value.currentPage, page_limit: pagination.value.pageSize, room_id: props.roomId - }) + }); if (code) { tableList.value = data.lists.map(ele => { return { - ...ele, ...data.total_data, - is_public_screen: data.is_public_screen === 1 ? '显示' : '隐藏', - is_public_server: data.is_public_server === 1 ? '显示' : '隐藏', - is_world_show: data.is_world_show === 1 ? '显示' : '隐藏', - } + ...ele, + ...data.total_data, + is_public_screen: data.is_public_screen === 1 ? "显示" : "隐藏", + is_public_server: data.is_public_server === 1 ? "显示" : "隐藏", + is_world_show: data.is_world_show === 1 ? "显示" : "隐藏" + }; }); - statisticsData.value = data.total_data + statisticsData.value = data.total_data; pagination.value.total = data.count; pagination.value.currentPage = data.page; } -} +}; const handleSizeChange = (val: number) => { pagination.value.pageSize = val; - getData(searchForm.value) + getData(searchForm.value); }; const handleCurrentChange = (val: number) => { pagination.value.currentPage = val; - getData(searchForm.value) + getData(searchForm.value); }; onMounted(() => { - getType() -}) + getType(); +}); \ No newline at end of file + diff --git a/vite.config.ts b/vite.config.ts index d6abdda..f7f831a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -35,9 +35,7 @@ export default ({ mode }: ConfigEnv): UserConfigExport => { onProxyReq: (proxyReq, req, res) => { if (req.method === 'OPTIONS') { proxyReq.method = 'OPTIONS'; - // https://test.vespa.qxyushen.top - // 'http://yushenggliht.qxyushen.top' - res.setHeader('Access-Control-Allow-Origin', 'http://ysmanagementconsole.qxyushen.top'); + res.setHeader('Access-Control-Allow-Origin', 'http://yushenggliht.qxyushen.top'); // res.setHeader('Access-Control-Allow-Origin', 'https://test.vespa.qxyushen.top'); res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS'); res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');