This commit is contained in:
gyq 2024-02-26 16:12:20 +08:00
parent a662ae5c01
commit eeac3e3541
2 changed files with 42 additions and 27 deletions

View File

@ -1,25 +1,11 @@
<template>
<el-dialog title="选择规格" width="800" v-model="dialogVisible">
<el-dialog :title="goods.name" width="800" v-model="dialogVisible">
<div class="header">选择规格</div>
<div class="row">
<div class="title">规格</div>
<div class="row" v-for="(item, index) in goods.tbProductSpec.specList" :key="index">
<div class="title">{{ item.name }}</div>
<div class="sku_wrap">
<div class="item">默认1人份</div>
</div>
</div>
<div class="row">
<div class="title">温度</div>
<div class="sku_wrap">
<div class="item"></div>
<div class="item"></div>
</div>
</div>
<div class="row">
<div class="title">糖度</div>
<div class="sku_wrap">
<div class="item">不另外加糖</div>
<div class="item">半糖</div>
<div class="item">标准糖</div>
<div class="item" :class="{ active: val.selected }" v-for="(val, i) in item.value" :key="i"
@click="selectedSku(index, i)">{{ val }}</div>
</div>
</div>
<div class="footer">
@ -36,9 +22,25 @@
<script setup>
import { ref, defineExpose } from 'vue'
const dialogVisible = ref(false)
const goods = ref({})
function show() {
//
function selectedSku(index, i) {
goods.value.tbProductSpec.specList[index].value[i].selected = true
console.log(goods.value.tbProductSpec.specList[index].val[i])
}
//
function show(item) {
dialogVisible.value = true
goods.value = item
goods.value.tbProductSpec.specList = JSON.parse(goods.value.tbProductSpec.specList)
goods.value.tbProductSpec.specList.map(item => {
item.selected = false
})
console.log(goods.value)
}
defineExpose({

View File

@ -3,7 +3,7 @@
<div class="header">
<div class="menus">
<div class="item" :class="{ active: categorysActive == index }" v-for="(item, index) in categorys"
:key="item.id" @click="categorysActive = index">
:key="item.id" @click="changeCategory(item, index)">
<el-text>{{ item.name }}</el-text>
</div>
</div>
@ -20,7 +20,7 @@
<el-button :icon="shopListType == 'text' ? 'PictureRounded' : 'PriceTag'" @click="changeShopListType"></el-button>
</div>
<div class="shop_list" :class="{ img: shopListType == 'img' }">
<div class="item_wrap" v-for="item in shopList" :key="item.id" @click="showSkuHandle">
<div class="item_wrap" v-for="item in goodsList" :key="item.id" @click="showSkuHandle(item)">
<div class="item">
<div class="dot">2</div>
<div class="cover" v-if="shopListType == 'img'">
@ -48,18 +48,23 @@ const store = useUser();
const skuModalRef = ref(null)
const shopListType = ref('text')
const shopListType = ref('img')
const categorys = ref([])
const categorysActive = ref(0)
const commdityName = ref('')
const shopList = ref([])
const originalGoods = ref([])
const goodsList = ref([])
// sku
function showSkuHandle() {
skuModalRef.value.show()
function showSkuHandle(item) {
if (item.typeEnum == 'sku') {
skuModalRef.value.show(item)
} else {
}
}
//
@ -71,6 +76,13 @@ function changeShopListType() {
}
}
//
function changeCategory(item, index) {
categorysActive.value = index
// goodsList.value = originalGoods.value.find(val => val.id == item.categoryId)
console.log(originalGoods.value.find(val => val.id == item.categoryId))
}
//
async function queryCategoryAjax() {
try {
@ -99,7 +111,8 @@ async function productqueryCommodityInfoAjax() {
page: 1,
pageSize: 1000
})
shopList.value = res
originalGoods.value = res
goodsList.value = res
} catch (error) {
console.log(error)
}