This commit is contained in:
gyq
2025-09-29 09:02:47 +08:00
5 changed files with 253 additions and 113 deletions

View File

@@ -170,46 +170,46 @@ const AddDialogRef = ref(null);
const tabsValue = ref(1);
const formRef = ref(null);
const form = ref({
isEnable: 1,
id: "",
shopIdList: "",
useType: "all",
isCustom: 0,
isOrder: 0,
remark: "",
rechargeDetailList: [],
isEnable: 1,
id: "",
shopIdList: "",
useType: "all",
isCustom: 0,
isOrder: 0,
remark: "",
rechargeDetailList: [],
});
const rules = ref({
rechargeDetailList: [
{
validator: (rule, value, callback) => {
if (form.value.rechargeDetailList.length == 0) {
callback(new Error("请添加面额"));
} else {
callback();
}
},
trigger: "change",
},
],
remark: [{ required: true, message: "请输入充值说明", trigger: "blur" }],
rechargeDetailList: [
{
validator: (rule, value, callback) => {
if (form.value.rechargeDetailList.length == 0) {
callback(new Error("请添加面额"));
} else {
callback();
}
},
trigger: "change",
},
],
remark: [{ required: true, message: "请输入充值说明", trigger: "blur" }],
});
function submitHandle() {
formRef.value.validate(async (valid) => {
try {
if (valid) {
await shopRecharge(form.value);
ElNotification({
title: "注意",
message: "保存成功",
type: "success",
});
}
} catch (err) {
console.log(err);
}
});
formRef.value.validate(async (valid) => {
try {
if (valid) {
await shopRecharge(form.value);
ElNotification({
title: "注意",
message: "保存成功",
type: "success",
});
}
} catch (err) {
console.log(err);
}
});
}
// 点前登录店铺信息
@@ -218,82 +218,83 @@ const shopInfo = ref("");
// 获取分店列表
const branchList = ref([]);
async function getBranchPageAjax() {
try {
const res = await getBranchPage();
branchList.value = res.records;
} catch (err) {
console.log(err);
}
try {
const res = await getBranchPage();
branchList.value = res.records;
} catch (err) {
console.log(err);
}
}
function addSuccess(data) {
console.log("addSuccess===", data);
if (data.index == null) {
form.value.rechargeDetailList.push(data.data);
} else {
form.value.rechargeDetailList[data.index] = data.data;
}
console.log("addSuccess===", data);
if (data.index == null) {
form.value.rechargeDetailList.push(data.data);
} else {
form.value.rechargeDetailList[data.index] = data.data;
}
}
// 获取优惠券列表
const couponList = ref([]);
async function couponPageAjax() {
try {
const res = await couponPage({
page: 1,
size: 500,
});
couponList.value = res.records;
} catch (err) {
console.log(err);
}
try {
const res = await couponPage({
page: 1,
size: 500,
});
couponList.value = res.records;
} catch (err) {
console.log(err);
}
}
// 用id寻找优惠券名称
function couponListFilter(id) {
if (id) {
let obj = couponList.value.find((item) => item.id == id);
return obj.title;
} else {
return "";
}
if (id) {
let obj = couponList.value.find((item) => item.id == id);
return obj.title;
} else {
return "";
}
}
// 从本地获取商户信息
function getLocalShopInfo() {
shopInfo.value = JSON.parse(localStorage.getItem("userInfo"));
shopInfo.value = JSON.parse(localStorage.getItem("userInfo"));
}
function back() {
router.back();
router.back();
}
// 配置信息获取
async function shopRechargeGetAjax() {
try {
const res = await shopRechargeGet();
res.rechargeDetailList.map((item) => {
item.couponInfoList.map((val) => {
val.id = val.coupon.id;
});
});
form.value = res;
try {
const res = await shopRechargeGet();
res.rechargeDetailList.map((item) => {
item.couponInfoList.map((val) => {
val.id = val.coupon ? val.coupon.id : null;
});
});
form.value = res;
console.log(form.value);
} catch (err) {
console.log(err);
}
console.log(form.value);
} catch (err) {
console.log(err);
}
}
onMounted(async () => {
await couponPageAjax();
getLocalShopInfo();
getBranchPageAjax();
shopRechargeGetAjax();
await couponPageAjax();
getLocalShopInfo();
getBranchPageAjax();
shopRechargeGetAjax();
});
</script>
<style scoped lang="scss">
<<<<<<< HEAD
.gyq_container {
padding: 14px;
.gyq_content {
@@ -301,31 +302,40 @@ onMounted(async () => {
background-color: #fff;
border-radius: 8px;
}
=======
.container {
padding: 14px;
.content {
padding: 14px;
background-color: #fff;
border-radius: 8px;
}
>>>>>>> b5635f70ae9ce11a8b36341d218349454a0f5e88
}
.column {
flex: 1;
display: flex;
flex-direction: column;
gap: 8px;
.item {
flex: 1;
}
flex: 1;
display: flex;
flex-direction: column;
gap: 8px;
.item {
flex: 1;
}
}
.center {
display: flex;
align-items: center;
gap: 10px;
display: flex;
align-items: center;
gap: 10px;
}
.tips {
color: #666;
color: #666;
}
.footer {
display: flex;
justify-content: center;
display: flex;
justify-content: center;
}
.textarea-num {
color: #999;
display: flex;
justify-content: flex-end;
color: #999;
display: flex;
justify-content: flex-end;
}
</style>