纸通宝SAAS仓库
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.
 

55 lines
1.5 KiB

Component({
options: {
addGlobalClass: true,
multipleSlots: true
},
properties: {
visible: { type: Boolean, value: false },
cIndex: { type: Number, value: -1 },
paperList: {
type: Array,
value: [],
observer: 'updateSubItems'
}
},
data: {
activeIndex: 0,
cIndex: -1,
singleList: []
},
methods: {
updateSubItems: function(){
var single = 0
var typeIndex = 0
for (let index = 0; index < this.data.paperList.length; index++) {
if(this.data.paperList[index].smallProductCategoryInfoList && this.data.paperList[index].smallProductCategoryInfoList.length){
single ++
typeIndex = index
}
}
if(single == 1){
this.data.singleList = this.data.paperList[typeIndex].smallProductCategoryInfoList
this.setData({ singleList: this.data.singleList })
}
},
onClickNav: function({detail}){
this.setData({ activeIndex: Number(detail), cIndex: -1 })
},
onConfirm: function(e){
this.data.cIndex = e.currentTarget.dataset.index
var item = null
if(this.data.singleList && this.data.singleList.length){
item = this.data.singleList[this.data.cIndex]
} else {
item = this.data.paperList[this.data.activeIndex].smallProductCategoryInfoList[this.data.cIndex]
}
wx.nextTick(() => {
this.setData({ visible: false, cIndex: this.data.cIndex })
this.triggerEvent('select', item)
})
},
onHide: function(){
this.setData({ visible: false })
}
}
})