上架问题修复

This commit is contained in:
donqi 2022-08-25 00:13:48 +08:00
parent 99b0390f89
commit 501c905abb
1 changed files with 83 additions and 55 deletions

View File

@ -12,7 +12,7 @@
<input name="servName" v-model="formData.servName" placeholder="请编辑上架标题(供客户搜索)"></input> <input name="servName" v-model="formData.servName" placeholder="请编辑上架标题(供客户搜索)"></input>
</view> </view>
<view class="cu-form-group"> <view class="cu-form-group">
<view class="title">服务描述</view> <view class="title">服务描述<text class="text-red">*</text></view>
<input name="servDesc" v-model="formData.servDesc" placeholder="让客户更清晰的上架内容描述"></input> <input name="servDesc" v-model="formData.servDesc" placeholder="让客户更清晰的上架内容描述"></input>
</view> </view>
<view class="solid-top"> <view class="solid-top">
@ -132,7 +132,7 @@
</view> </view>
</view> </view>
<view class="cu-bar bg-white"> <view class="cu-bar bg-white">
<view class="action text-black">区域描述</view> <view class="action text-black">区域描述<text class="text-red">*</text></view>
</view> </view>
<view class="padding-lr-sm padding-bottom-sm bg-white"> <view class="padding-lr-sm padding-bottom-sm bg-white">
<textarea name="areaDesc" style="width: 100%; height: 150rpx;" class="solid radius text-left padding-sm" <textarea name="areaDesc" style="width: 100%; height: 150rpx;" class="solid radius text-left padding-sm"
@ -179,7 +179,7 @@
<text class='cuIcon-close'></text> <text class='cuIcon-close'></text>
</view> </view>
</view> </view>
<view class="solids" @tap="chooseImgList($event, 'descImgList')" <view class="solids" @tap="chooseImgNoCrop($event, 'descImgList')"
v-if="formData.descImgList.length<9"> v-if="formData.descImgList.length<9">
<text class='cuIcon-cameraadd'></text> <text class='cuIcon-cameraadd'></text>
</view> </view>
@ -204,8 +204,8 @@
</view> </view>
</view> </view>
</view> </view>
<ksp-cropper mode="fixed" :width="cropWidth" :height="cropHeight" :maxWidth="cropWidth" :maxHeight="cropHeight" :url="url2Crop" <ksp-cropper mode="fixed" :width="cropWidth" :height="cropHeight" :maxWidth="cropWidth"
@cancel="oncancel" @ok="onok"></ksp-cropper> :maxHeight="cropHeight" :url="url2Crop" @cancel="oncancel" @ok="onok"></ksp-cropper>
<view class="cu-bar bg-white solid-top"> <view class="cu-bar bg-white solid-top">
<view class="action text-black"> <view class="action text-black">
视频上传 视频上传
@ -501,7 +501,7 @@
}, },
chooseImgList(e, imgListField, cropWidth, cropHeight) { chooseImgList(e, imgListField, cropWidth, cropHeight) {
this.cropWidth = cropWidth && cropWidth > 0 ? cropWidth : this.sysInfo.windowWidth * 2; this.cropWidth = cropWidth && cropWidth > 0 ? cropWidth : this.sysInfo.windowWidth * 2;
this.cropHeight = cropHeight && cropHeight > 0 ? cropHeight : this.sysInfo.windowWidth * 2 * 1.5; this.cropHeight = cropHeight && cropHeight > 0 ? cropHeight : this.sysInfo.windowWidth * 2 * 1.3;
uni.chooseImage({ uni.chooseImage({
count: 1, //9 count: 1, //9
sizeType: ['original', 'compressed'], // sizeType: ['original', 'compressed'], //
@ -530,6 +530,27 @@
// url // url
this.url2Crop = ""; this.url2Crop = "";
}, },
chooseImgNoCrop(e, imgListField) {
uni.chooseImage({
count: 9, //9
sizeType: ['original', 'compressed'], //
sourceType: ['album'], //
success: (res) => {
uni.showLoading({
title: '上传中',
mask: true
});
res.tempFilePaths.forEach((tmpUrl, index) => {
this.$request.uploadFile(tmpUrl).then((url) => {
this.formData[imgListField].push(url);
if (index === res.tempFilePaths.length - 1) {
uni.hideLoading();
}
});
});
}
});
},
viewImage(e, imgList) { viewImage(e, imgList) {
uni.previewImage({ uni.previewImage({
urls: imgList, urls: imgList,
@ -577,25 +598,32 @@
let errMsg = ""; let errMsg = "";
if (!data.servName) { if (!data.servName) {
errMsg = '服务名称不能为空'; errMsg = '服务名称不能为空';
} else if (!data.servDesc) {
errMsg = '服务描述不能为空';
} else if (!data.category || !data.category.length) {
errMsg = '请选择类目';
} else if (!data.goodsStandardList || !data.goodsStandardList.length) { } else if (!data.goodsStandardList || !data.goodsStandardList.length) {
errMsg = '至少选择一个规格'; errMsg = '至少选一个规格';
} else if (!this.validSpecData(data.goodsStandardList)) { } else if (!this.validSpecData(data.goodsStandardList)) {
return false; return false;
} else if (!data.goodsUnit) { } else if (!data.goodsUnit) {
errMsg = '商品单位不能为空'; errMsg = '商品单位不能为空';
} else if (!data.goodsAreaList || !data.goodsAreaList.length) { } else if (!data.goodsAreaList || !data.goodsAreaList.length) {
errMsg = '至少选择一个上架区域'; errMsg = '至少选择一个上架区域';
} else if (!data.areaDesc) {
errMsg = '区域描述不能为空';
} else if (!data.coverImgList || !data.coverImgList.length) { } else if (!data.coverImgList || !data.coverImgList.length) {
errMsg = '封面图不能为空' errMsg = '封面图不能为空';
} else if (!data.descImgList || !data.descImgList.length) { } else if (!data.descImgList || !data.descImgList.length) {
errMsg = '详情图不能为空' errMsg = '详情图不能为空';
} else if (!data.imgList || !data.imgList.length) { } else if (!data.imgList || !data.imgList.length) {
errMsg = '轮播图不能为空' errMsg = '轮播图不能为空';
} }
if (errMsg) { if (errMsg) {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: errMsg title: errMsg,
duration: 2500
}) })
return false; return false;
} }
@ -605,19 +633,16 @@
let errMsg = ""; let errMsg = "";
for (let i = 0; i < goodsStandardList.length; i++) { for (let i = 0; i < goodsStandardList.length; i++) {
let spec = goodsStandardList[i]; let spec = goodsStandardList[i];
if (!spec.goodsStandardName) { if (!spec.goodsPrice) {
errMsg = '勾选规格的自编辑购买标题不能为空'; errMsg = '已勾选规格的价格不能为空';
} else if (!spec.goodsPrice) {
errMsg = '勾选规格的价格不能为空';
} else if (!spec.groupPrice) {
errMsg = '勾选规格的团购价不能为空';
} else if (!spec.goodsNum) { } else if (!spec.goodsNum) {
errMsg = '勾选规格的库存不能为空'; errMsg = '已勾选规格的库存不能为空';
} }
if (errMsg) { if (errMsg) {
uni.showToast({ uni.showToast({
icon: 'none', icon: 'none',
title: errMsg title: errMsg,
duration: 2500
}) })
break; break;
} }
@ -630,6 +655,9 @@
async submit() { async submit() {
let goodsStandardList = this.formData.specsList.filter((item) => { let goodsStandardList = this.formData.specsList.filter((item) => {
if (item.checked) { if (item.checked) {
if (!item.goodsStandardName) {
item.goodsStandardName = item.goodsCategoryName;
}
return { return {
...item ...item
} }