|
|
@@ -196,10 +196,22 @@
|
|
|
<span class="app-color-3"></span>
|
|
|
</view>
|
|
|
<view class="module-det">
|
|
|
- <htz-image-upload :max="1" :compress="true" v-model="currentImgData" :headers="headers"
|
|
|
+ <htz-image-upload :max="5" :compress="true" v-model="currentImgData" :headers="headers"
|
|
|
@uploadSuccess="imgUploadSuccess" @imgDelete="imgDeleteFn" :action="getLoginInfo.imgUploadApi">
|
|
|
</htz-image-upload>
|
|
|
</view>
|
|
|
+ <tui-list-cell class="line-cell category-wrap" :hover="false">
|
|
|
+ <view class="tui-title">封面</view>
|
|
|
+ <view class="tui-input">
|
|
|
+ <block v-if="coverImgData.length > 0">
|
|
|
+ <button class="admin-button-com" :class="[(form.cover == item) ? '' : 'default']"
|
|
|
+ v-for="(item, index) in coverImgData" :key="index"
|
|
|
+ @click="selCoverFn(index)" >第{{ index + 1 }}张</button>
|
|
|
+ </block>
|
|
|
+ <view v-else class="no-img-tip">请先上传图片</view>
|
|
|
+ <view v-if="coverImgData.length > 0" class="use-img">选择上面的图片作为封面</view>
|
|
|
+ </view>
|
|
|
+ </tui-list-cell>
|
|
|
</view>
|
|
|
|
|
|
<view class="module-com input-line-wrap">
|
|
|
@@ -478,7 +490,8 @@ export default {
|
|
|
cost:0,
|
|
|
skMore:3,
|
|
|
weight:'',
|
|
|
- cover:[],
|
|
|
+ cover: "",
|
|
|
+ images: [],
|
|
|
limitBuy:0,
|
|
|
stockWarning:5,
|
|
|
status:2,
|
|
|
@@ -523,7 +536,10 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
computed:{
|
|
|
- ...mapGetters(["getLoginInfo","getDictionariesInfo"])
|
|
|
+ ...mapGetters(["getLoginInfo","getDictionariesInfo"]),
|
|
|
+ coverImgData() {
|
|
|
+ return this.form.images || [];
|
|
|
+ }
|
|
|
},
|
|
|
onLoad(option) {
|
|
|
if(option.id){
|
|
|
@@ -571,6 +587,9 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ selCoverFn(index) {
|
|
|
+ this.form.cover = this.form.images[index];
|
|
|
+ },
|
|
|
showWeightPopup(){
|
|
|
this.$refs.weightRef.open('center')
|
|
|
},
|
|
|
@@ -1052,7 +1071,7 @@ export default {
|
|
|
});
|
|
|
|
|
|
this.currentImgData.push(res.data.bigCover)
|
|
|
- this.form.cover = [res.data.shortCover]
|
|
|
+ this.form.images = [res.data.shortCover]
|
|
|
|
|
|
this.form.stock = 0
|
|
|
this.form.itemId = ptItemId
|
|
|
@@ -1083,17 +1102,25 @@ export default {
|
|
|
this.form[i] = res.data[i]
|
|
|
});
|
|
|
|
|
|
- this.currentImgData = []
|
|
|
- this.form.cover = []
|
|
|
- this.currentImgData.push(res.data.bigCover)
|
|
|
- this.form.cover = [res.data.shortCover]
|
|
|
+ const imageUrls = (res.data.images || '').split(',').filter(i => i);
|
|
|
+ this.form.images = imageUrls;
|
|
|
+ this.currentImgData = imageUrls.map(url => {
|
|
|
+ return this.constant.imgUrl + '/' + url + '?x-oss-process=image/resize,m_fill,h_700,w_700'
|
|
|
+ });
|
|
|
+
|
|
|
+ this.form.cover = res.data.shortCover || '';
|
|
|
+ if (!this.form.cover && this.form.images.length > 0) {
|
|
|
+ this.form.cover = this.form.images[0];
|
|
|
+ }
|
|
|
|
|
|
this.form.price = res.data.prePrice
|
|
|
|
|
|
let currentClass = this.itemClassData.filter(
|
|
|
e => this.form.classId == e.id
|
|
|
)[0];
|
|
|
- this.form.className = currentClass.name ? currentClass.name : ''
|
|
|
+ if(currentClass){
|
|
|
+ this.form.className = currentClass.name ? currentClass.name : ''
|
|
|
+ }
|
|
|
|
|
|
this.smallUnitSelectedData = this.unitData.filter(
|
|
|
e => this.form.smallUnitId == e.id
|
|
|
@@ -1104,18 +1131,26 @@ export default {
|
|
|
this.productData = res.data
|
|
|
this.cost = res.data.cost ? res.data.cost : 0
|
|
|
this.belongCost = res.data.belongCost ? res.data.belongCost : 0
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
imgUploadSuccess(res) {
|
|
|
var _res = JSON.parse(res.data)
|
|
|
if(_res.code == 1){
|
|
|
this.currentImgData.push(_res.data.bigUrl)
|
|
|
- this.form.cover.push(_res.data.shortUrl)
|
|
|
+ this.form.images.push(_res.data.shortUrl)
|
|
|
+ if (!this.form.cover) {
|
|
|
+ this.form.cover = _res.data.shortUrl;
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
imgDeleteFn(res){
|
|
|
- const index = res.index
|
|
|
- this.form.cover.splice(index,1)
|
|
|
+ const index = res.index;
|
|
|
+ const deletedUrl = this.form.images[index];
|
|
|
+ this.form.images.splice(index, 1);
|
|
|
+
|
|
|
+ if (this.form.cover === deletedUrl) {
|
|
|
+ this.form.cover = this.form.images[0] || '';
|
|
|
+ }
|
|
|
},
|
|
|
init() {
|
|
|
//从平台选择花材
|
|
|
@@ -1160,10 +1195,13 @@ export default {
|
|
|
},
|
|
|
// 确认
|
|
|
confirmFn() {
|
|
|
- if (this.$util.isEmpty(this.form.cover)) {
|
|
|
+ if (this.$util.isEmpty(this.form.images)) {
|
|
|
this.$msg("请上传图片")
|
|
|
return false
|
|
|
}
|
|
|
+ if (!this.form.cover && this.form.images.length > 0) {
|
|
|
+ this.form.cover = this.form.images[0];
|
|
|
+ }
|
|
|
let requestHost = addProduct
|
|
|
if(this.form.id && this.form.id != 0){
|
|
|
requestHost = updateProduct;
|
|
|
@@ -1198,8 +1236,9 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
let form = JSON.parse(JSON.stringify(this.form))
|
|
|
+ form.images = form.images.join(',')
|
|
|
uni.showLoading({mask:true,title:'提交中'})
|
|
|
- requestHost({...form,cover:this.form.cover[0],appVersion:1}).then(res => {
|
|
|
+ requestHost({...form,appVersion:1}).then(res => {
|
|
|
uni.hideLoading()
|
|
|
if(res.code == 1){
|
|
|
this.$msg("操作成功");
|
|
|
@@ -1436,4 +1475,15 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+.use-img{
|
|
|
+ font-size: 22rpx;
|
|
|
+ color: #999999;
|
|
|
+ padding: 4rpx 8rpx;
|
|
|
+ line-height: 1.5;
|
|
|
+}
|
|
|
+.no-img-tip {
|
|
|
+ font-size: 26rpx;
|
|
|
+ color: #cccccc;
|
|
|
+ padding: 12rpx 0;
|
|
|
+}
|
|
|
</style>
|