多租户商城-商户小程序端
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.
 
 
 

70 lines
1.4 KiB

import api from '../../config/api'
import { funMixin } from '../../config/mixin'
export const commonMixin = {
name: 'classifyHeaderComponent',
mixins: [funMixin],
props: {
terminal: {
type: Number,
default: 4,
},
typeId: {
type: Number,
default: 1,
},
shopId: {
type: Number,
default: 0,
},
componentContent: {
type: Object,
},
},
data() {
return {
classifyData: [],
activeTab: 0,
beginIndex: 0,
productData:[]
}
},
mounted() {
this.beginIndex = (this.componentContent.firstClassify && this.componentContent.firstClassify.length ) ? 1 : 0
this.getData()
},
methods: {
getData() {
const _ = this
_.sendReq(
{
url: `${api.getClassify}?page=1&pageSize=20`,
method: 'GET',
},
(res) => {
_.classifyData = res.data
this.getProducts()
},
(err) => {}
)
},
tabChange (index, id) {
this.activeTab = index
this.getProducts()
this.$emit('tabChange', index, id)
},
getProducts(){
const _ = this
if(this.activeTab >= this.beginIndex) {
_.sendReq({
url: `${api.getProductsV2}?page=1&pageSize=20&classifyId=${_.classifyData[this.activeTab-this.beginIndex].id}`,
method: 'GET'
}, (proRes) => {
_.productData = proRes.data.list
})
} else {
_.productData = []
}
}
},
}