From 4b2b55a2fd8070be845c005008c1631be47c8e2b Mon Sep 17 00:00:00 2001
From: tianyi <13521030702@163.com>
Date: Thu, 26 Mar 2026 18:01:09 +0800
Subject: [PATCH] 11
---
package1/myCenter/addGoods.vue | 119 ++++++++++++++++++++++++++++-----
package1/myCenter/addType.vue | 11 ++-
2 files changed, 114 insertions(+), 16 deletions(-)
diff --git a/package1/myCenter/addGoods.vue b/package1/myCenter/addGoods.vue
index 1ee161d..0f64bc9 100644
--- a/package1/myCenter/addGoods.vue
+++ b/package1/myCenter/addGoods.vue
@@ -7,7 +7,7 @@
- 商家详情
+ 新增商品
@@ -30,8 +30,13 @@
-
-
+
+
+
+
+
@@ -144,6 +149,8 @@
export default {
data() {
return {
+ dataList: {},
+ modalType:0,
categoryData:[],
categoryIndex: 0,
modalclassType:'',
@@ -151,6 +158,7 @@
specValueArr:[],
attrValueArr:[],
editorIns: null,
+ typeItem: {},
menuButtonInfo: {},
formData: {
id: '',
@@ -166,10 +174,11 @@
specPrice: "",
specNum: 9999
}],
+ shopId:'',
sellTime: 0, //可售时间
isMoreBuy: 0,
- sellBeginTime: '00:00', //可售时段自定义---开始时间
- sellEndTime: '00:00', //可售时段自定义---结束时间
+ sellBeginTime: '', //可售时段自定义---开始时间
+ sellEndTime: '', //可售时段自定义---结束时间
attributeList: '',
productGroupBuyPrices: [],
attributeList1: new Map(), //商品属性
@@ -181,7 +190,13 @@
required: true,
errorMessage: '请输入名称',
}]
- }
+ },
+ categoryId: {
+ rules: [{
+ required: true,
+ errorMessage: '请选择商品分类',
+ }, ],
+ },
},
}
},
@@ -190,9 +205,55 @@
},
onShow() {
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
+ uni.authorize({
+ scope: 'scope.writePhotosAlbum',
+ success() {
+
+ },
+ fail() {
+ this.tui.toast("您未授权,图片上传功能可能会出现错误")
+ }
+ })
+ this.typeItem = JSON.parse(JSON.stringify(this.typeItem)) || ''
+ if (this.typeItem) {
+ this.formData.categoryId = this.typeItem.id
+ }
+ this.formData.shopId = uni.getStorageSync('shopId')
},
onLoad(option) {
-
+ this.getGategoryList()
+ if (option.dataList) {
+ this.dataList = JSON.parse(option.dataList)
+ this.tui.request("/app/product/getById/" + this.dataList.id, "POST", {
+
+ }, false, true).then((res) => {
+ if (res.code == 200) {
+ this.modalType = 1
+ this.formData.id = res.result.id
+ this.formData.shopId = res.result.shopId
+ this.formData.categoryName = res.result.categoryName
+ this.formData.orderFiled = res.result.orderFiled
+ this.formData.lunchBox = res.result.lunchBox
+ this.formData.startPayNum = res.result.startPayNum
+ this.formData.attributeListPrice = JSON.parse(res.result.attributeListPrice)
+ this.formData.shopId = res.result.shopId
+ this.formData.sellTime = res.result.sellBeginTime !=''?1:0
+ this.formData.isMoreBuy = res.result.isMoreBuy
+ this.formData.sellBeginTime = res.result.sellBeginTime
+ this.formData.sellEndTime = res.result.sellEndTime
+ this.formData.attributeList = res.result.attributeList
+ this.formData.productGroupBuyPrices = res.result.productGroupBuyPrices
+ this.formData.attributeList1 = new Map()
+ this.formData.productName = res.result.productName
+ this.formData.productPicture = res.result.productPicture
+ this.formData.productIntro = res.result.productIntro
+ this.formData.categoryId = res.result.categoryId
+ this.edit(this.formData)
+ } else {
+ this.tui.toast(res.message)
+ }
+ }).catch((res) => {})
+ }
},
methods: {
/**
@@ -279,12 +340,41 @@
// })
// })
},
-
+ //跳转分类页
+ goGategoryLow() {
+ uni.navigateTo({
+ url: '/package1/myCenter/addType'
+ })
+ },
+ //初始化获取分类列表
+ getGategoryList() {
+ this.tui.request("/app/productCategory/list", "get", {
+ shopId:uni.getStorageSync('shopId')
+ }, false, true).then((res) => {
+ if (res.code == 200) {
+ if (res.result.length > 0) {
+ if(this.formData.categoryId != '' && this.formData.categoryId != undefined){
+ for(let i=0;i {})
+ },
// 触发提交表单
submit() {
let that = this;
- this.$refs.form.validate((valid) => {
- if (valid) {
+ // this.$refs.form.validate((valid) => {
+ // if (valid) {
if (this.modalType == 0) {
// 添加 避免编辑后传入id等数据 记得删除
delete this.formData.id;
@@ -299,6 +389,7 @@
this.tui.request("/app/product/save", "post", this.formData, false, false).then((res) => {
if(res.code == 200){
that.tui.toast("操作成功");
+ uni.navigateBack()
}
}).catch(() => {});
} else if (this.modalType == 1) {
@@ -310,11 +401,12 @@
this.tui.request("/app/product/edit", "post", this.formData, false, false).then((res) => {
if(res.code == 200){
that.tui.toast("操作成功");
+ uni.navigateBack()
}
}).catch(() => {});
}
- }
- });
+ // }
+ // });
},
back() {
uni.navigateBack()
@@ -430,9 +522,6 @@
this.formData.attributeList1 = new Map(Object.entries(this.formData.attributeList1));
this.formData.attributeListPrice = JSON.parse(this.formData.attributeListPrice)
- console.log("this.formData.attributeList1",this.formData.attributeList1)
- console.log("this.formData.attributeListPrice",this.formData.attributeListPrice)
-
this.formData.attributeList1.forEach((value, key) => {
for(let i = 0;i
- -
+
-
{{item.categoryName}}
@@ -219,6 +219,15 @@
}
},
+ //点击选择列表,带参数 返回上一页
+ clickList(item) {
+ let pages = getCurrentPages();
+ let prevPage = pages[pages.length - 2];
+ prevPage.$vm.typeItem = item
+ uni.navigateBack({
+ delta: 1
+ })
+ },
back() {
uni.navigateBack()
},