|
|
@ -7,7 +7,7 @@ |
|
|
<uni-icons type="left" size="28"></uni-icons> |
|
|
<uni-icons type="left" size="28"></uni-icons> |
|
|
</view> |
|
|
</view> |
|
|
<view class="title-name" :style="{'padding-top': menuButtonInfo.top +'px'}"> |
|
|
<view class="title-name" :style="{'padding-top': menuButtonInfo.top +'px'}"> |
|
|
商家详情 |
|
|
新增商品 |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
@ -30,8 +30,13 @@ |
|
|
<uni-forms-item label="排名" name="orderFiled"> |
|
|
<uni-forms-item label="排名" name="orderFiled"> |
|
|
<input type="digit" class="content-input" v-model="formData.orderFiled" placeholder="请输入排名"> |
|
|
<input type="digit" class="content-input" v-model="formData.orderFiled" placeholder="请输入排名"> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<uni-forms-item label="店铺分类" name="editTitle"> |
|
|
<uni-forms-item label="商品分类" name="editTitle"> |
|
|
<input type="digit" class="content-input" v-model="editTitle" disabled> |
|
|
<view style="border: 2px solid #eee;display: flex;flex: 1;border-radius: 5px;"> |
|
|
|
|
|
<input type="text" placeholder="请选择商品分类" disabled v-model="typeItem.categoryName" |
|
|
|
|
|
class="content-input" @tap="goGategoryLow" style="border: 0;"> |
|
|
|
|
|
<uni-icons type="right" size="16" |
|
|
|
|
|
style="margin-left: 40rpx;line-height: 70rpx;"></uni-icons> |
|
|
|
|
|
</view> |
|
|
</uni-forms-item> |
|
|
</uni-forms-item> |
|
|
<uni-forms-item label="商品规格" name="attributeListPrice"> |
|
|
<uni-forms-item label="商品规格" name="attributeListPrice"> |
|
|
<view> |
|
|
<view> |
|
|
@ -144,6 +149,8 @@ |
|
|
export default { |
|
|
export default { |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
|
|
|
dataList: {}, |
|
|
|
|
|
modalType:0, |
|
|
categoryData:[], |
|
|
categoryData:[], |
|
|
categoryIndex: 0, |
|
|
categoryIndex: 0, |
|
|
modalclassType:'', |
|
|
modalclassType:'', |
|
|
@ -151,6 +158,7 @@ |
|
|
specValueArr:[], |
|
|
specValueArr:[], |
|
|
attrValueArr:[], |
|
|
attrValueArr:[], |
|
|
editorIns: null, |
|
|
editorIns: null, |
|
|
|
|
|
typeItem: {}, |
|
|
menuButtonInfo: {}, |
|
|
menuButtonInfo: {}, |
|
|
formData: { |
|
|
formData: { |
|
|
id: '', |
|
|
id: '', |
|
|
@ -166,10 +174,11 @@ |
|
|
specPrice: "", |
|
|
specPrice: "", |
|
|
specNum: 9999 |
|
|
specNum: 9999 |
|
|
}], |
|
|
}], |
|
|
|
|
|
shopId:'', |
|
|
sellTime: 0, //可售时间 |
|
|
sellTime: 0, //可售时间 |
|
|
isMoreBuy: 0, |
|
|
isMoreBuy: 0, |
|
|
sellBeginTime: '00:00', //可售时段自定义---开始时间 |
|
|
sellBeginTime: '', //可售时段自定义---开始时间 |
|
|
sellEndTime: '00:00', //可售时段自定义---结束时间 |
|
|
sellEndTime: '', //可售时段自定义---结束时间 |
|
|
attributeList: '', |
|
|
attributeList: '', |
|
|
productGroupBuyPrices: [], |
|
|
productGroupBuyPrices: [], |
|
|
attributeList1: new Map(), //商品属性 |
|
|
attributeList1: new Map(), //商品属性 |
|
|
@ -181,7 +190,13 @@ |
|
|
required: true, |
|
|
required: true, |
|
|
errorMessage: '请输入名称', |
|
|
errorMessage: '请输入名称', |
|
|
}] |
|
|
}] |
|
|
} |
|
|
}, |
|
|
|
|
|
categoryId: { |
|
|
|
|
|
rules: [{ |
|
|
|
|
|
required: true, |
|
|
|
|
|
errorMessage: '请选择商品分类', |
|
|
|
|
|
}, ], |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
@ -190,9 +205,55 @@ |
|
|
}, |
|
|
}, |
|
|
onShow() { |
|
|
onShow() { |
|
|
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() |
|
|
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) { |
|
|
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: { |
|
|
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<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 { |
|
|
|
|
|
this.tui.toast(res.message) |
|
|
|
|
|
} |
|
|
|
|
|
}).catch((res) => {}) |
|
|
|
|
|
}, |
|
|
// 触发提交表单 |
|
|
// 触发提交表单 |
|
|
submit() { |
|
|
submit() { |
|
|
let that = this; |
|
|
let that = this; |
|
|
this.$refs.form.validate((valid) => { |
|
|
// this.$refs.form.validate((valid) => { |
|
|
if (valid) { |
|
|
// if (valid) { |
|
|
if (this.modalType == 0) { |
|
|
if (this.modalType == 0) { |
|
|
// 添加 避免编辑后传入id等数据 记得删除 |
|
|
// 添加 避免编辑后传入id等数据 记得删除 |
|
|
delete this.formData.id; |
|
|
delete this.formData.id; |
|
|
@ -299,6 +389,7 @@ |
|
|
this.tui.request("/app/product/save", "post", this.formData, false, false).then((res) => { |
|
|
this.tui.request("/app/product/save", "post", this.formData, false, false).then((res) => { |
|
|
if(res.code == 200){ |
|
|
if(res.code == 200){ |
|
|
that.tui.toast("操作成功"); |
|
|
that.tui.toast("操作成功"); |
|
|
|
|
|
uni.navigateBack() |
|
|
} |
|
|
} |
|
|
}).catch(() => {}); |
|
|
}).catch(() => {}); |
|
|
} else if (this.modalType == 1) { |
|
|
} else if (this.modalType == 1) { |
|
|
@ -310,11 +401,12 @@ |
|
|
this.tui.request("/app/product/edit", "post", this.formData, false, false).then((res) => { |
|
|
this.tui.request("/app/product/edit", "post", this.formData, false, false).then((res) => { |
|
|
if(res.code == 200){ |
|
|
if(res.code == 200){ |
|
|
that.tui.toast("操作成功"); |
|
|
that.tui.toast("操作成功"); |
|
|
|
|
|
uni.navigateBack() |
|
|
} |
|
|
} |
|
|
}).catch(() => {}); |
|
|
}).catch(() => {}); |
|
|
} |
|
|
} |
|
|
} |
|
|
// } |
|
|
}); |
|
|
// }); |
|
|
}, |
|
|
}, |
|
|
back() { |
|
|
back() { |
|
|
uni.navigateBack() |
|
|
uni.navigateBack() |
|
|
@ -430,9 +522,6 @@ |
|
|
this.formData.attributeList1 = new Map(Object.entries(this.formData.attributeList1)); |
|
|
this.formData.attributeList1 = new Map(Object.entries(this.formData.attributeList1)); |
|
|
this.formData.attributeListPrice = JSON.parse(this.formData.attributeListPrice) |
|
|
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) => { |
|
|
this.formData.attributeList1.forEach((value, key) => { |
|
|
for(let i = 0;i<value.title.length;i++){ |
|
|
for(let i = 0;i<value.title.length;i++){ |
|
|
this.attrValueArr.push({ |
|
|
this.attrValueArr.push({ |
|
|
|