upload project source code

This commit is contained in:
2026-04-30 18:49:43 +08:00
commit 9b394ba682
2277 changed files with 660945 additions and 0 deletions

View File

@@ -0,0 +1,295 @@
import { ao as vLoading, w as ElForm, x as ElFormItem, av as ElInputNumber, h as ElButton, E as ElMessage, T as ElCard } from "./element-plus.CkEW9frc.js";
import { Y as YifanMembershipAPI } from "./yifan_membership.CCYhkrJx.js";
import { J as defineComponent, t as onMounted, aP as resolveDirective, S as openBlock, _ as createElementBlock, a6 as withDirectives, T as createBlock, a0 as withCtx, $ as createVNode, a9 as createTextVNode, a1 as createBaseVNode, r as ref, ak as reactive } from "./.pnpm.BW3P1y8f.js";
import { _ as _export_sfc } from "./_plugin-vue_export-helper.1tPrXgE0.js";
import "./index.CMd5bD1r.js";
import "./codemirror.CvJAcn2d.js";
const _hoisted_1 = { class: "app-container" };
const _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "YifanMembershipDiscount",
inheritAttrs: false
},
__name: "index",
setup(__props) {
const loading = ref(false);
const saving = ref(false);
const serviceLoading = ref(false);
const serviceSaving = ref(false);
const formData = reactive({
junior_discount_rate: 1,
senior_discount_rate: 1
});
const serviceForm = reactive({
naming_price: 0,
renaming_price: 0,
daily_fortune_price: 0,
monthly_fortune_price: 0
});
function toRate(value, fallback = 0) {
const num = Number(value);
if (Number.isNaN(num)) return fallback;
return Math.min(1, Math.max(0, Number(num.toFixed(2))));
}
function normalizeForm() {
formData.junior_discount_rate = toRate(formData.junior_discount_rate, 1);
formData.senior_discount_rate = toRate(formData.senior_discount_rate, 1);
}
function toPrice(value, fallback = 0) {
const num = Number(value);
if (Number.isNaN(num)) return fallback;
return Math.max(0, Number(num.toFixed(2)));
}
function normalizeServiceForm() {
serviceForm.naming_price = toPrice(serviceForm.naming_price, 0);
serviceForm.renaming_price = toPrice(serviceForm.renaming_price, 0);
serviceForm.daily_fortune_price = toPrice(serviceForm.daily_fortune_price, 0);
serviceForm.monthly_fortune_price = toPrice(serviceForm.monthly_fortune_price, 0);
}
async function loadData() {
loading.value = true;
try {
const response = await YifanMembershipAPI.getDiscountConfig();
const data = response.data.data;
formData.junior_discount_rate = toRate(data == null ? void 0 : data.junior_discount_rate, 1);
formData.senior_discount_rate = toRate(data == null ? void 0 : data.senior_discount_rate, 1);
} catch (error) {
ElMessage.error((error == null ? void 0 : error.message) || "折扣配置加载失败");
} finally {
loading.value = false;
}
}
async function loadServiceConfig() {
serviceLoading.value = true;
try {
const response = await YifanMembershipAPI.getServicePriceConfig();
const data = response.data.data;
serviceForm.naming_price = toPrice(data == null ? void 0 : data.naming_price, 0);
serviceForm.renaming_price = toPrice(data == null ? void 0 : data.renaming_price, 0);
serviceForm.daily_fortune_price = toPrice(data == null ? void 0 : data.daily_fortune_price, 0);
serviceForm.monthly_fortune_price = toPrice(data == null ? void 0 : data.monthly_fortune_price, 0);
} catch (error) {
ElMessage.error((error == null ? void 0 : error.message) || "收费配置加载失败");
} finally {
serviceLoading.value = false;
}
}
async function saveData() {
if (saving.value) return;
saving.value = true;
normalizeForm();
try {
await YifanMembershipAPI.updateDiscountConfig({
junior_discount_rate: formData.junior_discount_rate,
senior_discount_rate: formData.senior_discount_rate
});
} catch (error) {
ElMessage.error((error == null ? void 0 : error.message) || "折扣配置保存失败");
} finally {
saving.value = false;
}
}
async function saveServiceConfig() {
if (serviceSaving.value) return;
serviceSaving.value = true;
normalizeServiceForm();
try {
await YifanMembershipAPI.updateServicePriceConfig({
naming_price: serviceForm.naming_price,
renaming_price: serviceForm.renaming_price,
daily_fortune_price: serviceForm.daily_fortune_price,
monthly_fortune_price: serviceForm.monthly_fortune_price
});
} catch (error) {
ElMessage.error((error == null ? void 0 : error.message) || "收费配置保存失败");
} finally {
serviceSaving.value = false;
}
}
onMounted(() => {
loadData();
loadServiceConfig();
});
return (_ctx, _cache) => {
const _component_el_input_number = ElInputNumber;
const _component_el_form_item = ElFormItem;
const _component_el_button = ElButton;
const _component_el_form = ElForm;
const _component_el_card = ElCard;
const _directive_hasPerm = resolveDirective("hasPerm");
const _directive_loading = vLoading;
return openBlock(), createElementBlock("div", _hoisted_1, [
withDirectives((openBlock(), createBlock(_component_el_card, null, {
header: withCtx(() => [..._cache[6] || (_cache[6] = [
createBaseVNode("div", { class: "card-header" }, "会员折扣设置", -1)
])]),
default: withCtx(() => [
createVNode(_component_el_form, {
"label-width": "180px",
"label-suffix": ":",
style: { "max-width": "560px" }
}, {
default: withCtx(() => [
createVNode(_component_el_form_item, { label: "初级会员折扣(0~1)" }, {
default: withCtx(() => [
withDirectives(createVNode(_component_el_input_number, {
modelValue: formData.junior_discount_rate,
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formData.junior_discount_rate = $event),
min: 0,
max: 1,
step: 0.01,
precision: 2,
"controls-position": "right"
}, null, 8, ["modelValue"]), [
[_directive_hasPerm, ["module_yifan:yifan_membership_discount:update"]]
])
]),
_: 1
}),
createVNode(_component_el_form_item, { label: "高级会员折扣(0~1)" }, {
default: withCtx(() => [
withDirectives(createVNode(_component_el_input_number, {
modelValue: formData.senior_discount_rate,
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => formData.senior_discount_rate = $event),
min: 0,
max: 1,
step: 0.01,
precision: 2,
"controls-position": "right"
}, null, 8, ["modelValue"]), [
[_directive_hasPerm, ["module_yifan:yifan_membership_discount:update"]]
])
]),
_: 1
}),
createVNode(_component_el_form_item, null, {
default: withCtx(() => [
withDirectives((openBlock(), createBlock(_component_el_button, {
type: "primary",
loading: saving.value,
onClick: saveData
}, {
default: withCtx(() => [..._cache[7] || (_cache[7] = [
createTextVNode(" 保存 ", -1)
])]),
_: 1
}, 8, ["loading"])), [
[_directive_hasPerm, ["module_yifan:yifan_membership_discount:update"]]
])
]),
_: 1
})
]),
_: 1
}),
_cache[8] || (_cache[8] = createBaseVNode("div", { class: "hint-text" }, " 修改后点击“保存”生效折扣展示将按百分比计算x100。 ", -1))
]),
_: 1
})), [
[_directive_loading, loading.value]
]),
withDirectives((openBlock(), createBlock(_component_el_card, { class: "mt-4" }, {
header: withCtx(() => [..._cache[9] || (_cache[9] = [
createBaseVNode("div", { class: "card-header" }, "收费设置", -1)
])]),
default: withCtx(() => [
createVNode(_component_el_form, {
"label-width": "180px",
"label-suffix": ":",
style: { "max-width": "560px" }
}, {
default: withCtx(() => [
createVNode(_component_el_form_item, { label: "起名费用" }, {
default: withCtx(() => [
withDirectives(createVNode(_component_el_input_number, {
modelValue: serviceForm.naming_price,
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => serviceForm.naming_price = $event),
min: 0,
step: 1,
precision: 2,
"controls-position": "right"
}, null, 8, ["modelValue"]), [
[_directive_hasPerm, ["module_yifan:yifan_membership_discount:update"]]
])
]),
_: 1
}),
createVNode(_component_el_form_item, { label: "改名费用" }, {
default: withCtx(() => [
withDirectives(createVNode(_component_el_input_number, {
modelValue: serviceForm.renaming_price,
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => serviceForm.renaming_price = $event),
min: 0,
step: 1,
precision: 2,
"controls-position": "right"
}, null, 8, ["modelValue"]), [
[_directive_hasPerm, ["module_yifan:yifan_membership_discount:update"]]
])
]),
_: 1
}),
createVNode(_component_el_form_item, { label: "每日运程费用" }, {
default: withCtx(() => [
withDirectives(createVNode(_component_el_input_number, {
modelValue: serviceForm.daily_fortune_price,
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => serviceForm.daily_fortune_price = $event),
min: 0,
step: 1,
precision: 2,
"controls-position": "right"
}, null, 8, ["modelValue"]), [
[_directive_hasPerm, ["module_yifan:yifan_membership_discount:update"]]
])
]),
_: 1
}),
createVNode(_component_el_form_item, { label: "每月运程费用" }, {
default: withCtx(() => [
withDirectives(createVNode(_component_el_input_number, {
modelValue: serviceForm.monthly_fortune_price,
"onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => serviceForm.monthly_fortune_price = $event),
min: 0,
step: 1,
precision: 2,
"controls-position": "right"
}, null, 8, ["modelValue"]), [
[_directive_hasPerm, ["module_yifan:yifan_membership_discount:update"]]
])
]),
_: 1
}),
createVNode(_component_el_form_item, null, {
default: withCtx(() => [
withDirectives((openBlock(), createBlock(_component_el_button, {
type: "primary",
loading: serviceSaving.value,
onClick: saveServiceConfig
}, {
default: withCtx(() => [..._cache[10] || (_cache[10] = [
createTextVNode(" 保存收费设置 ", -1)
])]),
_: 1
}, 8, ["loading"])), [
[_directive_hasPerm, ["module_yifan:yifan_membership_discount:update"]]
])
]),
_: 1
})
]),
_: 1
}),
_cache[11] || (_cache[11] = createBaseVNode("div", { class: "hint-text" }, " 修改后点击“保存收费设置”生效;金额字段统一按 number 处理。 ", -1))
]),
_: 1
})), [
[_directive_loading, serviceLoading.value]
])
]);
};
}
});
const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-a666ea81"]]);
export {
index as default
};