From 555fe5c4d72feadb0e07ad7e9d802114ab57e6aa Mon Sep 17 00:00:00 2001 From: yziiy <15979918+mayday-yziiy@user.noreply.gitee.com> Date: Wed, 14 Jan 2026 14:33:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=8C=E7=BA=A7=E5=AF=86?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/passwordDiaglog/index.vue | 36 +++ src/utils/passwordVerify.tsx | 54 ++++ src/views/BlindBox/boxList/hook.tsx | 231 ++++++++++-------- src/views/BlindBox/turntable/hook.tsx | 121 ++++----- src/views/BlindBox/turntable/index.vue | 22 +- src/views/Decorate/decorateList/hook.tsx | 151 ++++++------ src/views/Decorate/decorateList/priceList.vue | 109 +++++---- src/views/Statistical/giftRecord/hook.tsx | 4 + src/views/gift/giftClassif/hook.tsx | 88 ++++--- src/views/gift/giftList/hook.tsx | 45 ++-- src/views/room/roomList/detail.vue | 4 +- 11 files changed, 493 insertions(+), 372 deletions(-) create mode 100644 src/components/passwordDiaglog/index.vue create mode 100644 src/utils/passwordVerify.tsx diff --git a/src/components/passwordDiaglog/index.vue b/src/components/passwordDiaglog/index.vue new file mode 100644 index 0000000..110dc64 --- /dev/null +++ b/src/components/passwordDiaglog/index.vue @@ -0,0 +1,36 @@ + + + diff --git a/src/utils/passwordVerify.tsx b/src/utils/passwordVerify.tsx new file mode 100644 index 0000000..510ca0e --- /dev/null +++ b/src/utils/passwordVerify.tsx @@ -0,0 +1,54 @@ +import { h, ref } from "vue"; +import { addDialog } from "@/components/ReDialog"; +import passDialog from "@/components/passwordDiaglog/index.vue"; +import { checkPassWord } from "@/api/modules/system"; +import { message } from "@/utils/message"; + +/** + * 二级密码验证工具 + * @param onSuccess 验证成功后的回调函数 + * @param onError 验证失败后的回调函数(可选) + * @returns void + */ +export function verifyPassword( + onSuccess: () => void | Promise, + onError?: (msg: string) => void +) { + const formRef = ref(); + + addDialog({ + title: `输入二级密码`, + width: "40%", + props: { + formInline: { + password: "" + } + }, + closeOnClickModal: false, + contentRenderer: () => h(passDialog, { ref: formRef, formInline: null }), + beforeSure: (done, { options }) => { + const FormRef = formRef.value.getRef(); + const curData = options.props.formInline; + + const verify = async form => { + const { code, msg } = await checkPassWord(form); + if (code) { + await onSuccess(); + done(); + } else { + if (onError) { + onError(msg); + } else { + message(msg, { type: "error" }); + } + } + }; + + FormRef.validate(valid => { + if (valid) { + verify(curData); + } + }); + } + }); +} diff --git a/src/views/BlindBox/boxList/hook.tsx b/src/views/BlindBox/boxList/hook.tsx index fcd12a6..55a5926 100644 --- a/src/views/BlindBox/boxList/hook.tsx +++ b/src/views/BlindBox/boxList/hook.tsx @@ -10,9 +10,10 @@ import { settingBlindBoxRule } from "@/api/modules/blindBox"; 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"; +import { verifyPassword } from "@/utils/passwordVerify"; export function useData() { const formRef = ref(); const loading = ref(true); @@ -27,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: "today_count_user" }, { label: "今日抽奖次数", prop: "today_total_count" }, - { label: "今日抽奖收入", prop: "today_total_price" }, - ]) - const statisticsData = ref({}) + { label: "今日抽奖收入", prop: "today_total_price" } + ]); + const statisticsData = ref({}); const searchLabel = ref([ { label: "礼物ID", prop: "gift_id", type: "input" }, { label: "礼物名称", prop: "gift_name", type: "input" } @@ -85,14 +87,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 ? "是" : "否"} + ) }, { @@ -106,23 +112,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; } @@ -137,49 +143,57 @@ export function useData() { onSearch(searchForm.value); }; const getType = async () => { - const { code, data } = await queryBoxTypeList({ activities_id: 4 }) + const { code, data } = await queryBoxTypeList({ activities_id: 4 }); // console.log(code, data) - 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) { - message(`您删除了这条数据`, { - type: "success" - }); - onSearch(searchForm.value); - } + 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 () => { + // 重置规则需要二级密码验证 + verifyPassword(async () => { + const { code } = await resetBlindBoxRule({ + gift_bag_id: activeName.value + }); + if (code) { + message(`重置成功`, { + type: "success" + }); + handleClick(activeName.value); + } + }); + }; + const handleDelete = async rowData => { + // 删除需要二级密码验证 + verifyPassword(async () => { + const { code } = await removeBlindBoxData({ id: rowData.id }); + if (code) { + message(`您删除了这条数据`, { + type: "success" + }); + onSearch(searchForm.value); + } + }); + }; + // 新增/编辑盲盒礼物 const openDialog = async (title = "新增", rowData: any) => { addDialog({ title: `${title}盲盒礼物`, props: { formInline: { gift_id: rowData?.gift_id ?? "", - quantity: rowData?.quantity ?? "", + quantity: rowData?.quantity ?? "" } }, width: "40%", @@ -188,51 +202,51 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await addBlindBoxData({ - ...form, - gift_bag_id: activeName.value, - }); - if (code) { - message("新增成功", { type: "success" }); - onSearch(searchForm.value); - done(); + + FormRef.validate(async valid => { + if (!valid) return; + + if (title === "新增") { + // 新增操作 - 需要二级密码验证 + verifyPassword(async () => { + const { code } = await addBlindBoxData({ + ...curData, + gift_bag_id: activeName.value + }); + if (code) { + message("新增成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message("新增失败", { type: "error" }); + } + }); } else { - message("新增失败", { type: "error" }); - } - }; - const updateData = async form => { - const { code, msg } = await editBlindBoxData({ - ...form, - gift_bag_id: activeName.value, - id: rowData.id - }); - if (code) { - message("修改成功", { type: "success" }); - onSearch(searchForm.value); - done(); - } else { - message(msg, { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - console.log("curData", curData); - // 表单规则校验通过 - if (title === "新增") { - // 实际开发先调用新增接口,再进行下面操作 - saveData(curData); - } else { - // 实际开发先调用修改接口,再进行下面操作 - updateData(curData); - } + // 编辑操作 - 需要二级密码验证 + verifyPassword(async () => { + const { code, msg } = await editBlindBoxData({ + ...curData, + gift_bag_id: activeName.value, + id: rowData.id + }); + if (code) { + message("修改成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message(msg, { type: "error" }); + } + }); } }); } }); }; + // 设置盲盒规则 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: { @@ -242,29 +256,30 @@ 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; - const saveData = async form => { - const { code } = await settingBlindBoxRule({ ...form }); - if (code) { - message("设置成功", { type: "success" }); - onSearch(searchForm.value); - done(); - } else { - message("设置失败", { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - // console.log("curData", curData); - saveData(curData) - } + + FormRef.validate(async valid => { + if (!valid) return; + + // 设置规则需要二级密码验证 + verifyPassword(async () => { + const { code } = await settingBlindBoxRule({ ...curData }); + if (code) { + message("设置成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message("设置失败", { type: "error" }); + } + }); }); } }); - } + }; return { searchForm, searchLabel, @@ -287,4 +302,4 @@ export function useData() { handleDelete, setting }; -} \ No newline at end of file +} diff --git a/src/views/BlindBox/turntable/hook.tsx b/src/views/BlindBox/turntable/hook.tsx index 74ed850..020a213 100644 --- a/src/views/BlindBox/turntable/hook.tsx +++ b/src/views/BlindBox/turntable/hook.tsx @@ -14,6 +14,7 @@ import editForm from "./form.vue"; import settingRuleView from "./settingRule.vue"; import { addDialog } from "@/components/ReDialog"; import { message } from "@/utils/message"; +import { verifyPassword } from "@/utils/passwordVerify"; export function useData() { const formRef = ref(); const loading = ref(true); @@ -162,17 +163,20 @@ export function useData() { activeName.value = id; onSearch(searchForm.value); }; - // + // 重置数量 const resetSetting = async () => { - const { data, code } = await resetBlindBoxRule({ - gift_bag_id: activeName.value - }); - if (code) { - message(`重置成功`, { - type: "success" + // 重置数量需要二级密码验证 + verifyPassword(async () => { + const { code } = await resetBlindBoxRule({ + gift_bag_id: activeName.value }); - handleClick(activeName.value); - } + if (code) { + message(`重置成功`, { + type: "success" + }); + handleClick(activeName.value); + } + }); }; const handleDelete = async rowData => { const { code } = await removeBlindBoxData({ id: rowData.id }); @@ -183,6 +187,7 @@ export function useData() { onSearch(searchForm.value); } }; + // 编辑盲盒礼物 const openDialog = async (title = "新增", rowData: any) => { addDialog({ title: `${title}盲盒礼物`, @@ -200,49 +205,45 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await addBlindBoxData({ - ...form, - gift_bag_id: activeName.value - }); - if (code) { - message("新增成功", { type: "success" }); - onSearch(searchForm.value); - done(); - } else { - message("新增失败", { type: "error" }); - } - }; - const updateData = async form => { - const { code, msg } = await editBlindBoxData({ - ...form, - gift_bag_id: activeName.value, - id: rowData.id - }); - if (code) { - message("修改成功", { type: "success" }); - onSearch(searchForm.value); - done(); - } else { - message(msg, { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - console.log("curData", curData); - // 表单规则校验通过 - if (title === "新增") { - // 实际开发先调用新增接口,再进行下面操作 - saveData(curData); + + FormRef.validate(async valid => { + if (!valid) return; + + if (title === "新增") { + // 新增操作 + const { code } = await addBlindBoxData({ + ...curData, + gift_bag_id: activeName.value + }); + if (code) { + message("新增成功", { type: "success" }); + onSearch(searchForm.value); + done(); } else { - // 实际开发先调用修改接口,再进行下面操作 - updateData(curData); + message("新增失败", { type: "error" }); } + } else { + // 编辑操作 - 需要二级密码验证 + verifyPassword(async () => { + const { code, msg } = await editBlindBoxData({ + ...curData, + gift_bag_id: activeName.value, + id: rowData.id + }); + if (code) { + message("修改成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message(msg, { type: "error" }); + } + }); } }); } }); }; + // 设置盲盒规则 const setting = async () => { const { data, code } = await getBlindBoxRule({ gift_bag_id: activeName.value @@ -261,21 +262,21 @@ export function useData() { beforeSure: (done, { options }) => { const FormRef = formRef.value.getRef(); const curData = options.props.formInline; - const saveData = async form => { - const { code } = await settingBlindBoxRule({ ...form }); - if (code) { - message("设置成功", { type: "success" }); - onSearch(searchForm.value); - done(); - } else { - message("设置失败", { type: "error" }); - } - }; - FormRef.validate(valid => { - if (valid) { - // console.log("curData", curData); - saveData(curData); - } + + FormRef.validate(async valid => { + if (!valid) return; + + // 设置规则需要二级密码验证 + verifyPassword(async () => { + const { code } = await settingBlindBoxRule({ ...curData }); + if (code) { + message("设置成功", { type: "success" }); + onSearch(searchForm.value); + done(); + } else { + message("设置失败", { type: "error" }); + } + }); }); } }); diff --git a/src/views/BlindBox/turntable/index.vue b/src/views/BlindBox/turntable/index.vue index 1b6e941..8ba82d7 100644 --- a/src/views/BlindBox/turntable/index.vue +++ b/src/views/BlindBox/turntable/index.vue @@ -30,7 +30,7 @@ const { setting } = useData(); onMounted(() => { - getType() + getType(); }); defineOptions({ name: "boxList" @@ -46,11 +46,10 @@ defineOptions({
-
+
- - + :title="ele.label" /> +
@@ -60,16 +59,11 @@ defineOptions({ 开奖记录 - - 设置规则 - + 设置规则