|
@@ -23,22 +23,18 @@
|
|
<script setup>
|
|
<script setup>
|
|
defineOptions({ name: 'mall-home-hotGoods'})
|
|
defineOptions({ name: 'mall-home-hotGoods'})
|
|
import { ref, computed } from 'vue'
|
|
import { ref, computed } from 'vue'
|
|
-import { useMallStore } from '@/store/mall'
|
|
|
|
import { getProductByIds } from '@/api/mall/index'
|
|
import { getProductByIds } from '@/api/mall/index'
|
|
import { formatSales, fen2yuan } from '@/hooks/web/useGoods'
|
|
import { formatSales, fen2yuan } from '@/hooks/web/useGoods'
|
|
import { isArray } from 'lodash-es'
|
|
import { isArray } from 'lodash-es'
|
|
import { useRouter } from 'vue-router'
|
|
import { useRouter } from 'vue-router'
|
|
|
|
|
|
|
|
+const props = defineProps({ templateData: Object })
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
-let template = ref(JSON.parse(localStorage.getItem('mallTemplate')) || {})
|
|
|
|
-useMallStore().$subscribe((mutation, state) => {
|
|
|
|
- if (state.template && Object.keys(state.template).length) template.value = state?.template
|
|
|
|
-})
|
|
|
|
|
|
|
|
// 根据id获取商品列表
|
|
// 根据id获取商品列表
|
|
const goodList = ref([])
|
|
const goodList = ref([])
|
|
const getGoodsList = async () => {
|
|
const getGoodsList = async () => {
|
|
- const productCard = template.value?.home?.components.find(item => item.id === 'ProductCard')
|
|
|
|
|
|
+ const productCard = props.templateData?.home?.components.find(item => item.id === 'ProductCard')
|
|
const ids = productCard.property.spuIds
|
|
const ids = productCard.property.spuIds
|
|
if (!ids.length) return
|
|
if (!ids.length) return
|
|
const data = await getProductByIds(ids)
|
|
const data = await getProductByIds(ids)
|