Files
city-store-transfer/components/ShowShopList/ShowShopList.vue
2023-11-19 22:27:47 +08:00

109 lines
2.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view>
<ShowShopListItem v-for="item in shopInfoList" :key="shopid" :shopInfo="item" :is-adshow="isADshow"
:adlinkPath="adlinkPath" :show-style="showStyle" :is-edit="isEdit" @delItem="handleDel"
@updateItem="hanldeUpdate"></ShowShopListItem>
</view>
</template>
<script>
/**
* @property {Array} shopInfoList 对象数组,(带图片)需要展示的商铺列表
* @property {Number} showStyle 展示商铺的样式类型(0为首页默认)
* @property {Boolean} isADshow 是否显示推广广告
* @property {Boolean} isEdit 是否显示编辑和删除
* @property {String} adlinkPath 推广广告跳转链接
* @property {Number} listType 获取列表类型传递参数部分
* @property {Object} customQuery 自定义查询参数
*/
export default {
name: "ShowShopList",
data() {
return {
pageSize: 5,
pageNum: 1,
};
},
props: {
showStyle: {
type: Number,
default () {
return 0
}
},
isADshow: {
type: Boolean,
default () {
return true
}
},
adlinkPath: {
type: String,
default () {
return ''
}
},
isEdit: {
type: Boolean,
default () {
return false
}
},
// //获取列表类型传递参数部分
listType: {
type: Number,
default () {
return 1
}
},
customQuery: {
type: Object,
default () {
return {}
}
},
shopInfoList: {
type: Array,
default () {
return []
}
}
},
methods: {
hanldeUpdate(shopid) {
this.$emit('updateItem', shopid)
},
handleDel(shopid) {
console.log("删除了商铺", shopid);
this.$emit('delItem', shopid)
// const delindex = this.shopInfoList.findIndex((item,index)=> item.shopid === shopid)
// TODO不能直接修改
// if(delindex !== -1) this.shopInfoList = this.shopInfoList.slice(delindex,1)
// console.log(this.shopInfoList);
},
getList() {
const query = this.$u.queryParams({
type: this.listType,
pageSize: this.pageSize,
pageNum: this.pageNum,
...this.customQuery
})
console.log("query", query);
this.$api.getShopList(query).then(res => {
this.shopInfoList = res.data.data
this.shopInfoList.forEach(item => {
item.pics = this.$api.imgUrl + item.pics
});
})
}
},
}
</script>
<style lang="scss">
</style>