From cf9315ba5368f4b30f8d5fd08772c3e171e90f7f Mon Sep 17 00:00:00 2001
From: wangfukang <15630117759@163.com>
Date: Mon, 4 May 2026 10:46:22 +0800
Subject: [PATCH] 1
---
package1/myCenter/addGoods.vue | 90 ++++----
package1/myCenter/attributeList.vue | 324 ++++++++++++++++------------
2 files changed, 233 insertions(+), 181 deletions(-)
diff --git a/package1/myCenter/addGoods.vue b/package1/myCenter/addGoods.vue
index def224b..d41d4ac 100644
--- a/package1/myCenter/addGoods.vue
+++ b/package1/myCenter/addGoods.vue
@@ -171,6 +171,7 @@
formData: {
id: '',
shopId: '',
+ attrId:'',
categoryId: '', //商品分类id
categoryName: '', //商品分类名称
productPicture: '', //商品图标
@@ -212,6 +213,7 @@
},
onShow() {
+ this.attrId = uni.getStorageSync('attrId');
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
uni.authorize({
scope: 'scope.writePhotosAlbum',
@@ -230,7 +232,7 @@
},
onLoad(option) {
this.getGategoryList()
- if (option.dataList) {
+ if (option.dataList != undefined && option.dataList != null && option.dataList != 'undefined') {
this.dataList = JSON.parse(option.dataList)
this.tui.request("/app/product/getById/" + this.dataList.id, "POST", {
@@ -640,73 +642,69 @@
})
},
checkSpec(type){
+ let that = this
this.$refs.addTypeDialog.open()
this.modalclassType = type
- this.tui.request("/dictData/getByCondition", "GET", {
- name: "",
- status: "",
- pageNumber: 1,
- pageSize: 100000,
- sort: 'sortOrder',
- order: 'asc',
- dictId: '2026945661353725952'
- }, false, true).then((res) => {
- if(res.code == 200){
- this.categoryData = res.result.content
- for (var i = 0; i < this.categoryData.length; i++) {
- if (i == this.categoryIndex) {
- this.categoryData[i].parentId = true
+ that.tui.request("/app/productAttribute/selectByCategoryId", "post", {categoryId:that.attrId}, false, true).then((res) => {
+ if (res.code == 200) {
+ that.categoryData = res.result
+ for (var i = 0; i < that.categoryData.length; i++) {
+ that.categoryData[i].title = that.categoryData[i].attributeName
+ if (i == that.categoryIndex) {
+ that.categoryData[i].parentId = true
} else {
- this.categoryData[i].parentId = false
+ that.categoryData[i].parentId = false
}
}
//如果是选择属性,需要拿一个分类名,保存成parent
- this.typeToAttrName = res.result.content[this.categoryIndex].title
+ that.typeToAttrName = res.result[that.categoryIndex].title
// 恢复该分类之前设置的canbuy值
- this.currentCanbuy = this.canbuyMap[this.typeToAttrName] || 1
- this.getCateGorySon(res.result.content[this.categoryIndex].id)
+ that.currentCanbuy = that.canbuyMap[that.typeToAttrName] || 1
+ that.getCateGorySon(res.result[that.categoryIndex].id)
+ } else {
+ this.tui.toast(res.message)
}
- }).catch(() => {});
+ }).catch((res) => {})
},
getCateGorySon(id){
- this.tui.request("/dictData/getByCondition", "GET", {
- name: "",
- status: "",
- pageNumber: 1,
- pageSize: 100000,
- sort: 'sortOrder',
- order: 'asc',
- dictId: id
+ let that = this
+ that.tui.request("/app/productAttributeValue/selectByAttributeId", "get", {
+ id: id,
}, false, true).then((res) => {
- if(res.code == 200){
- this.categorySonData = res.result.content
- // 先给所有子项初始化checked为false,确保Vue响应性
- console.log("111111",this.specValueArr)
- console.log("22222",this.attrValueArr)
- for (var i = 0; i < this.categorySonData.length; i++) {
- this.$set(this.categorySonData[i], 'checked', false)
+ if (res.code == 200) {
+ that.categorySonData = res.result
+ for (var i = 0; i < that.categorySonData.length; i++) {
+ that.categorySonData[i].title = that.categorySonData[i].value
+ that.$set(that.categorySonData[i], 'checked', false)
}
- if(this.modalclassType == 'shuxing'){
- for (var i = 0; i < this.categorySonData.length; i++) {
- for (var m = 0; m < this.attrValueArr.length; m++) {
- if(this.attrValueArr[m].title == this.categorySonData[i].title && this.attrValueArr[m].parentName == this.typeToAttrName){
- this.$set(this.categorySonData[i], 'checked', true)
+ if(that.modalclassType == 'shuxing'){
+ for (var i = 0; i < that.categorySonData.length; i++) {
+ for (var m = 0; m < that.attrValueArr.length; m++) {
+ if(that.attrValueArr[m].title == that.categorySonData[i].title && that.attrValueArr[m].parentName == that.typeToAttrName){
+ that.$set(that.categorySonData[i], 'checked', true)
}
}
}
}else{
//guige
- for (var i = 0; i < this.categorySonData.length; i++) {
- for (var m = 0; m < this.specValueArr.length; m++) {
- if(this.specValueArr[m].id == this.categorySonData[i].id){
- this.$set(this.categorySonData[i], 'checked', true)
+ for (var i = 0; i < that.categorySonData.length; i++) {
+ for (var m = 0; m < that.specValueArr.length; m++) {
+ if(that.specValueArr[m].id == that.categorySonData[i].id){
+ that.$set(that.categorySonData[i], 'checked', true)
}
}
}
}
- this.$forceUpdate()
+ console.log()
+ that.$forceUpdate(that.categorySonData)
+ that.$forceUpdate(that.categoryData)
+ } else {
+ uni.showToast({
+ title: "删除失败",
+ icon: 'none'
+ })
}
- }).catch(() => {});
+ }).catch((res) => {})
},
deldantiaoguige(index){
for (var m = 0; m < this.specValueArr.length; m++) {
diff --git a/package1/myCenter/attributeList.vue b/package1/myCenter/attributeList.vue
index 3566024..9190021 100644
--- a/package1/myCenter/attributeList.vue
+++ b/package1/myCenter/attributeList.vue
@@ -6,69 +6,79 @@
- 代买饭
+ 规格管理
-
+
-
- {{item.categoryName}}
-
+ {{item.attributeName}}
+
-
+
-
-
-