|
|
@ -182,6 +182,7 @@ |
|
|
currentCanbuy:1, |
|
|
currentCanbuy:1, |
|
|
canbuyMap:{}, |
|
|
canbuyMap:{}, |
|
|
categoryData:[], |
|
|
categoryData:[], |
|
|
|
|
|
productCategoryList:[], |
|
|
categoryIndex: 0, |
|
|
categoryIndex: 0, |
|
|
modalclassType:'', |
|
|
modalclassType:'', |
|
|
categorySonData:[], |
|
|
categorySonData:[], |
|
|
@ -249,9 +250,11 @@ |
|
|
this.tui.toast("您未授权,图片上传功能可能会出现错误") |
|
|
this.tui.toast("您未授权,图片上传功能可能会出现错误") |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
this.typeItem = JSON.parse(JSON.stringify(this.typeItem)) || '' |
|
|
if (this.hasSelectedTypeItem(this.typeItem)) { |
|
|
if (this.typeItem) { |
|
|
this.typeItem = JSON.parse(JSON.stringify(this.typeItem)) |
|
|
this.formData.categoryId = this.typeItem.id |
|
|
this.formData.categoryId = this.typeItem.id |
|
|
|
|
|
this.formData.categoryName = this.typeItem.categoryName |
|
|
|
|
|
this.syncSelectedCategory() |
|
|
} |
|
|
} |
|
|
this.formData.shopId = uni.getStorageSync('shopId') |
|
|
this.formData.shopId = uni.getStorageSync('shopId') |
|
|
}, |
|
|
}, |
|
|
@ -284,6 +287,7 @@ |
|
|
this.formData.productIntro = res.result.productIntro |
|
|
this.formData.productIntro = res.result.productIntro |
|
|
this.formData.categoryId = res.result.categoryId |
|
|
this.formData.categoryId = res.result.categoryId |
|
|
this.edit(this.formData) |
|
|
this.edit(this.formData) |
|
|
|
|
|
this.syncSelectedCategory() |
|
|
} else { |
|
|
} else { |
|
|
this.tui.toast(res.message) |
|
|
this.tui.toast(res.message) |
|
|
} |
|
|
} |
|
|
@ -385,24 +389,47 @@ |
|
|
shopId:uni.getStorageSync('shopId') |
|
|
shopId:uni.getStorageSync('shopId') |
|
|
}, false, true).then((res) => { |
|
|
}, false, true).then((res) => { |
|
|
if (res.code == 200) { |
|
|
if (res.code == 200) { |
|
|
if (res.result.length > 0) { |
|
|
this.productCategoryList = Array.isArray(res.result) ? res.result : [] |
|
|
if(this.formData.categoryId != '' && this.formData.categoryId != undefined){ |
|
|
this.syncSelectedCategory() |
|
|
for(let i=0;i<res.result.length;i++){ |
|
|
|
|
|
if(res.result[i].id == this.formData.categoryId){ |
|
|
|
|
|
this.typeItem = res.result[i] |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
this.typeItem = res.result[0] |
|
|
|
|
|
this.formData.categoryId = this.typeItem.id |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
this.tui.toast(res.message) |
|
|
this.tui.toast(res.message) |
|
|
} |
|
|
} |
|
|
}).catch((res) => {}) |
|
|
}).catch((res) => {}) |
|
|
}, |
|
|
}, |
|
|
|
|
|
hasCategoryValue(value) { |
|
|
|
|
|
return value !== '' && value !== undefined && value !== null |
|
|
|
|
|
}, |
|
|
|
|
|
hasSelectedTypeItem(item) { |
|
|
|
|
|
return item && this.hasCategoryValue(item.id) |
|
|
|
|
|
}, |
|
|
|
|
|
syncSelectedCategory() { |
|
|
|
|
|
if (this.hasCategoryValue(this.formData.categoryId)) { |
|
|
|
|
|
const selected = this.productCategoryList.find(item => String(item.id) == String(this.formData.categoryId)) |
|
|
|
|
|
if (selected) { |
|
|
|
|
|
this.typeItem = selected |
|
|
|
|
|
this.formData.categoryId = selected.id |
|
|
|
|
|
this.formData.categoryName = selected.categoryName |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (this.formData.categoryName) { |
|
|
|
|
|
this.typeItem = { |
|
|
|
|
|
id: this.formData.categoryId, |
|
|
|
|
|
categoryName: this.formData.categoryName |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (this.hasSelectedTypeItem(this.typeItem)) { |
|
|
|
|
|
this.formData.categoryId = this.typeItem.id |
|
|
|
|
|
this.formData.categoryName = this.typeItem.categoryName |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
if (this.productCategoryList.length > 0) { |
|
|
|
|
|
this.typeItem = this.productCategoryList[0] |
|
|
|
|
|
this.formData.categoryId = this.typeItem.id |
|
|
|
|
|
this.formData.categoryName = this.typeItem.categoryName |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
// 触发提交表单 |
|
|
// 触发提交表单 |
|
|
submit() { |
|
|
submit() { |
|
|
let that = this; |
|
|
let that = this; |
|
|
|