You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
155 lines
4.4 KiB
155 lines
4.4 KiB
// import { directive, Swiper, SwiperSlide } from 'vue-awesome-swiper'
|
|
// import 'swiper/css/swiper.css'
|
|
import {funMixin} from '../../config/mixin'
|
|
import api from '../../config/api'
|
|
|
|
export const commonMixin = {
|
|
name: 'productList',
|
|
mixins: [funMixin],
|
|
props: {
|
|
terminal: {
|
|
type: Number,
|
|
default: 4
|
|
},
|
|
typeId: {
|
|
type: Number,
|
|
default: 1
|
|
},
|
|
shopId: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
componentContent: {
|
|
type: Object
|
|
}
|
|
},
|
|
// components: {
|
|
// Swiper,
|
|
// SwiperSlide
|
|
// },
|
|
// directives: {
|
|
// swiper: directive
|
|
// },
|
|
data () {
|
|
return {
|
|
productData: [1,2,3,4],
|
|
loading:true,
|
|
isFirst:true
|
|
}
|
|
},
|
|
watch: {
|
|
'componentContent': {
|
|
handler(newVal, oldVal) {
|
|
this.getData()
|
|
},
|
|
deep: true
|
|
}
|
|
},
|
|
created() {
|
|
this.getData(true)
|
|
},
|
|
computed: {
|
|
swiper() {
|
|
if(this.$refs.mySwiper){
|
|
return this.$refs.mySwiper.$swiper
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
getData() {
|
|
|
|
const _ = this
|
|
// 纵向
|
|
_.loading=true
|
|
if (_.componentContent.productData.sourceType === '1') {
|
|
if(_.componentContent.productData.productIdList && _.componentContent.productData.productIdList.length>0){
|
|
_.sendReq({
|
|
url: `${api.getProductsV2}?page=1&pageSize=99&ids=${_.componentContent.productData.productIdList}`,
|
|
method: 'GET'
|
|
}, (proRes) => {
|
|
_.productData = proRes.data.list
|
|
if(_.isFirst){
|
|
_.componentContent.productData.imgTextData = _.productData
|
|
}
|
|
_.isFirst = false
|
|
_.loading = false
|
|
})
|
|
} else {
|
|
_.productData = []
|
|
_.isFirst = false
|
|
_.loading = false
|
|
}
|
|
} else if(_.componentContent.productData.sourceType === '2'){
|
|
if(_.componentContent.productData.categoryId) {
|
|
_.sendReq({
|
|
url: `${api.getProductsV2}?page=1&pageSize=99&classifyId=${_.componentContent.productData.categoryId}`,
|
|
method: 'GET'
|
|
}, (proRes) => {
|
|
_.productData = proRes.data.list
|
|
_.productData = _.productData.filter(item=>JSON.stringify(item) !== '{}')
|
|
if(_.isFirst){
|
|
_.componentContent.productData.imgTextData = _.productData
|
|
}
|
|
// _.swiper.update()
|
|
})
|
|
} else {
|
|
_.productData = {
|
|
products:[]
|
|
}
|
|
}
|
|
}else if(_.componentContent.productData.sourceType === '3'){
|
|
_.sendReq({
|
|
url: `${api.getProductsV2}?page=1&pageSize=20&type=4`,
|
|
method: 'GET'
|
|
}, (proRes) => {
|
|
_.productData = proRes.data.list
|
|
_.productData = _.productData.filter(item=>JSON.stringify(item) !== '{}')
|
|
if(_.isFirst){
|
|
_.componentContent.productData.imgTextData = _.productData
|
|
}
|
|
_.isFirst = false
|
|
_.loading = false
|
|
})
|
|
}else if(_.componentContent.productData.sourceType === '4'){
|
|
_.sendReq({
|
|
url: `${api.getProductsV2}?page=1&pageSize=20&type=5`,
|
|
method: 'GET'
|
|
}, (proRes) => {
|
|
_.productData = proRes.data.list
|
|
_.productData = _.productData.filter(item=>JSON.stringify(item) !== '{}')
|
|
if(_.isFirst){
|
|
_.componentContent.productData.imgTextData = _.productData
|
|
}
|
|
_.isFirst = false
|
|
_.loading = false
|
|
})
|
|
}else if(_.componentContent.productData.sourceType === '5'){
|
|
_.sendReq({
|
|
url: `${api.getProductsV2}?page=1&pageSize=20&type=6`,
|
|
method: 'GET'
|
|
}, (proRes) => {
|
|
_.productData = proRes.data.list
|
|
_.productData = _.productData.filter(item=>JSON.stringify(item) !== '{}')
|
|
if(_.isFirst){
|
|
_.componentContent.productData.imgTextData = _.productData
|
|
}
|
|
_.isFirst = false
|
|
_.loading = false
|
|
})
|
|
}else if(_.componentContent.productData.sourceType === '6'){
|
|
_.sendReq({
|
|
url: `${api.getProductsV2}?page=1&pageSize=6&type=7`,
|
|
method: 'GET'
|
|
}, (proRes) => {
|
|
_.productData = proRes.data.list
|
|
_.productData = _.productData.filter(item=>JSON.stringify(item) !== '{}')
|
|
if(_.isFirst){
|
|
_.componentContent.productData.imgTextData = _.productData
|
|
}
|
|
_.isFirst = false
|
|
_.loading = false
|
|
})
|
|
}
|
|
},
|
|
}
|
|
}
|