对接支付优惠

This commit is contained in:
gyq
2025-03-11 09:10:49 +08:00
parent 5cf2355d28
commit 3df0cce9ec
31 changed files with 1527 additions and 846 deletions

View File

@@ -5,8 +5,8 @@
<div class="list_title">{{ item.name }}</div>
<div class="item_wrap">
<el-button :type="item.active ? 'primary' : ''" @click="selectHandle(item)">全部</el-button>
<el-button :type="val.active ? 'primary' : ''" v-for="val in item.childrenList" :key="val.id"
@click="selectHandle(val, index)">{{ val.name }}</el-button>
<!-- <el-button :type="val.active ? 'primary' : ''" v-for="val in item.childrenList" :key="val.id"
@click="selectHandle(val, index)">{{ val.name }}</el-button> -->
</div>
</div>
</div>
@@ -18,9 +18,11 @@
</template>
<script setup>
import { tbShopCategoryGet } from "@/api/device";
import { onMounted, ref } from "vue";
import { useUser } from "@/store/user.js";
import { useGoods } from '@/store/goods.js'
const goodsStore = useGoods()
const store = useUser();
const emit = defineEmits(["success"]);
@@ -29,6 +31,7 @@ const dialogVisible = ref(false);
const loading = ref(false);
const categorys = ref([]);
// 确定
function onSubmitHandle() {
let categorysArr = [];
for (let item of categorys.value) {
@@ -38,16 +41,16 @@ function onSubmitHandle() {
id: item.id,
});
}
if (item.childrenList.length) {
for (let val of item.childrenList) {
if (val.active) {
categorysArr.push({
name: `${val.name}`,
id: val.id,
});
}
}
}
// if (item.childrenList.length) {
// for (let val of item.childrenList) {
// if (val.active) {
// categorysArr.push({
// name: `${val.name}`,
// id: val.id,
// });
// }
// }
// }
}
emit("success", categorysArr);
dialogVisible.value = false;
@@ -55,38 +58,34 @@ function onSubmitHandle() {
// 选择分类
function selectHandle(item, index = -1) {
if (index != -1) {
categorys.value[index].active = false;
} else {
item.childrenList.map((item) => {
item.active = false;
});
}
// if (index != -1) {
// categorys.value[index].active = false;
// } else {
// item.childrenList.map((item) => {
// item.active = false;
// });
// }
item.active = !item.active;
}
// 获取分类
async function tbShopCategoryGetAjax() {
try {
loading.value = true;
const res = await tbShopCategoryGet({
shopId: store.userInfo.shopId,
sort: "sort,desc",
page: 0,
pageSize: 200,
// loading.value = true;
// const res = await categoryList();
// res.list.map((item) => {
// item.active = false;
// item.childrenList.map((item) => {
// item.active = false;
// });
// });
categorys.value = goodsStore.originCategoryList.map(item => {
item.active = false
return item
});
// console.log(res);
res.list.map((item) => {
item.active = false;
item.childrenList.map((item) => {
item.active = false;
});
});
categorys.value = res.list;
setTimeout(() => {
loading.value = false;
}, 300);
// setTimeout(() => {
// loading.value = false;
// }, 300);
} catch (error) {
console.log(error);
loading.value = false;