|
|
|
@ -38,7 +38,7 @@ |
|
|
|
|
<input type="text" v-model="productDate.price" placeholder="请输入商品售价" /> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
<uni-forms-item label="商品上架:" name="productStatus"> |
|
|
|
|
<switch v-model="productDate.productStatus" color="#FE0606" checked style="transform:scale(0.7)" /> |
|
|
|
|
<switch v-model="productDate.productStatus" :checked="productDate.productStatus=='1'" color="#FE0606" @change="switchChange" style="transform:scale(0.7)" /> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
<uni-forms-item label="商品推荐:" name="age"> |
|
|
|
|
<view class='checkbox-con'> |
|
|
|
@ -68,7 +68,7 @@ |
|
|
|
|
></uni-data-select> |
|
|
|
|
</uni-forms-item> |
|
|
|
|
<view class="content" v-show="productDate.attributesTypeId"> |
|
|
|
|
<view>商品类型:</view> |
|
|
|
|
<view style="margin: 10rpx 0;">商品类型:</view> |
|
|
|
|
<view> |
|
|
|
|
<uni-section type="line"> |
|
|
|
|
<view class="uni-px-5" v-for="(item,index) in attributesList"> |
|
|
|
@ -83,36 +83,37 @@ |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view> |
|
|
|
|
<view>批量填充:<text style="color: #999999;">批量填充填入信息后,可以批量将内容填写到SKU 信息里</text></view> |
|
|
|
|
<view class="tagButton" :class="item.checked == true?'checkedTag':''" @tap="changeChecked(item)" v-for="item in bottonList">{{item.label}}</view> |
|
|
|
|
<view>批量填充:<text style="color: #999999;margin: 10rpx 0;">批量填充填入信息后,可以批量将内容填写到SKU 信息里</text></view> |
|
|
|
|
<view class="tagButton" @tap="changeChecked(item)" v-for="item in bottonList">{{item.label}}</view> |
|
|
|
|
<view class="redButton" @tap="addStockList">确定</view> |
|
|
|
|
</view> |
|
|
|
|
<view v-if="productDate.attributesTypeId&&checkboxAttributes.length>0" v-for="(items,index) in checkboxAttributes"> |
|
|
|
|
<view> |
|
|
|
|
<view v-for="(items,index) in stockList"> |
|
|
|
|
<view style="margin: 10rpx 0;"> |
|
|
|
|
<text style="color: red;">*</text> |
|
|
|
|
<text>规格:</text> |
|
|
|
|
<text>{{radioAttributes}}+{{items}}</text> |
|
|
|
|
<text v-if="index==0">{{radioAttributes}}</text> |
|
|
|
|
<text v-if="index!=0">{{radioAttributes}}+{{checkboxAttributes[index]}}</text> |
|
|
|
|
</view> |
|
|
|
|
<view class="tagButton" v-if="item.checked==true" v-for="item in stockList"> |
|
|
|
|
<input type="text" v-model="item.value" :placeholder="item.label" /> |
|
|
|
|
<view class="tagButton"> |
|
|
|
|
<input type="text" v-model="items.marketPrice" placeholder="市场价格" /> |
|
|
|
|
</view> |
|
|
|
|
<view style="display: inline-block;" @click="deleteCheckAll(index)">删除</view> |
|
|
|
|
</view> |
|
|
|
|
<view v-if="productDate.attributesTypeId&&radioAttributes" > |
|
|
|
|
<view> |
|
|
|
|
<text style="color: red;">*</text> |
|
|
|
|
<text>规格:</text> |
|
|
|
|
<text>{{radioAttributes}}</text> |
|
|
|
|
<view class="tagButton"> |
|
|
|
|
<input type="text" v-model="items.sellPrice" placeholder="销售价格" /> |
|
|
|
|
</view> |
|
|
|
|
<view class="tagButton"> |
|
|
|
|
<input type="text" v-model="items.stock" placeholder="库存数量" /> |
|
|
|
|
</view> |
|
|
|
|
<view class="tagButton" v-if="item.checked==true" v-for="item in bottonList"> |
|
|
|
|
<input type="text" v-model="item.value" :placeholder="item.label" /> |
|
|
|
|
<view class="tagButton"> |
|
|
|
|
<input type="text" v-model="items.integral" placeholder="积分价值" /> |
|
|
|
|
</view> |
|
|
|
|
<view style="display: inline-block;" @click="deleteRadio">删除</view> |
|
|
|
|
<view style="display: inline-block;vertical-align: top;margin-top: 10rpx;" @click="deleteCheckAll(index)">删除</view> |
|
|
|
|
</view> |
|
|
|
|
<view> |
|
|
|
|
<view> |
|
|
|
|
<view style="margin: 10rpx 0;"> |
|
|
|
|
<text style="color: red;">*</text> |
|
|
|
|
商品图片:<text style="color: #999999;">最多可上传10张图片</text></view> |
|
|
|
|
商品图片: |
|
|
|
|
<text style="color: #999999;">最多可上传10张图片</text> |
|
|
|
|
</view> |
|
|
|
|
<view class="imageList" v-for="(items,index) in productDate.images"> |
|
|
|
|
<view class="imageBlack" v-if="items.mainMark==1"> |
|
|
|
|
<image :src="items.url"></image> |
|
|
|
@ -121,12 +122,12 @@ |
|
|
|
|
</view> |
|
|
|
|
<view class="imageBlack" v-else-if="items.mainMark!=1"> |
|
|
|
|
<image :src="items.url"></image> |
|
|
|
|
<view class="cameraText">设为主图</view> |
|
|
|
|
<view class="cameraText" @click="setMainImage(index)">设为主图</view> |
|
|
|
|
<uni-icons class="cameraClear" type="clear" size="20" @tap="clearImage(index)"></uni-icons> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="imageBlack" @tap="takePhoto"> |
|
|
|
|
<view style="cameraImage"> |
|
|
|
|
<view class="imageBlack" style="background-color: #fafafa;" @tap="srcFileImage"> |
|
|
|
|
<view style="margin-top: 46rpx;"> |
|
|
|
|
<uni-icons type="camera-filled" size="30"></uni-icons> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
@ -159,7 +160,7 @@ |
|
|
|
|
}, |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
currentBoxId: 'instruction', //当前显示的view的id |
|
|
|
|
currentBoxId: 'chooseType', //当前显示的view的id |
|
|
|
|
isBoxShow: false, |
|
|
|
|
productDate:{ |
|
|
|
|
images:[] |
|
|
|
@ -194,7 +195,8 @@ |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
onLoad(options) { |
|
|
|
|
// this.get(options.orderId) |
|
|
|
|
console.log(options,'options') |
|
|
|
|
this.getEdit(options) |
|
|
|
|
this.classfication() |
|
|
|
|
this.getProductBrands() |
|
|
|
|
this.getAttributesType() |
|
|
|
@ -208,6 +210,56 @@ |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
getEdit(options){ |
|
|
|
|
serve.getEdit(options.id).then(res=>{ |
|
|
|
|
if(res.code === 20000&&res.data!=null){ |
|
|
|
|
this.productDate = res.data |
|
|
|
|
this.productDate.demandRegion = res.data.categoryOneId+','+res.data.categoryTwoId |
|
|
|
|
if(this.productDate.newMark == '1'){ |
|
|
|
|
this.radioItem[0].checked =true |
|
|
|
|
}else{ |
|
|
|
|
this.radioItem[0].checked =false |
|
|
|
|
} |
|
|
|
|
if(this.productDate.recommend == '1'){ |
|
|
|
|
this.radioItem[1].checked =true |
|
|
|
|
}else{ |
|
|
|
|
this.radioItem[1].checked =false |
|
|
|
|
} |
|
|
|
|
this.attributesTypeList.forEach(tab=>{ |
|
|
|
|
if(tab.id = this.productDate.attributesTypeId){ |
|
|
|
|
this.attributesList = tab.attributesList |
|
|
|
|
this.attributesList.forEach(tab=>{ |
|
|
|
|
tab.attributesList = [] |
|
|
|
|
tab.attributeContent.split(',').forEach(item=>{ |
|
|
|
|
tab.attributesList.push({value:item,text:item}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
if(this.productDate.checkedList.length==1){ |
|
|
|
|
this.radioAttributes = this.productDate.checkedList[0].checked |
|
|
|
|
}else{ |
|
|
|
|
this.checkboxAttributes = [] |
|
|
|
|
this.productDate.checkedList.forEach((tab,index)=>{ |
|
|
|
|
if(index!=0){ |
|
|
|
|
this.checkboxAttributes.push(tab.checked) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.stockList = this.productDate.stockList |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
console.log(res.data) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
switchChange(e){ |
|
|
|
|
if(e.detail.value == true){ |
|
|
|
|
this.productDate.productStatus = '1' |
|
|
|
|
}else if(e.detail.value == false){ |
|
|
|
|
this.productDate.productStatus = '2' |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
classfication(){ |
|
|
|
|
serve.classification().then(res=>{ |
|
|
|
|
this.productList = res.data |
|
|
|
@ -304,90 +356,43 @@ |
|
|
|
|
this.checkboxAttributes.splice(i,1) |
|
|
|
|
this.radioAttributes = '' |
|
|
|
|
} |
|
|
|
|
this.stockList.splice(i,1) |
|
|
|
|
}, |
|
|
|
|
deleteRadio(){ |
|
|
|
|
this.radioAttributes = '' |
|
|
|
|
}, |
|
|
|
|
changeChecked(item){ |
|
|
|
|
|
|
|
|
|
item.checked = !item.checked |
|
|
|
|
console.log(this.radioAttributes,this.checkboxAttributes) |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
addStockList(){ |
|
|
|
|
this.stockList = [] |
|
|
|
|
let obj = {} |
|
|
|
|
this.bottonList.forEach(tab=>{ |
|
|
|
|
if(tab.checked == true){ |
|
|
|
|
if(tab.value == 'marketPrice'){ |
|
|
|
|
obj.marketPrice = '' |
|
|
|
|
}else if(tab.value == 'sellPrice'){ |
|
|
|
|
obj.sellPrice = '' |
|
|
|
|
}else if(tab.value == 'stock'){ |
|
|
|
|
obj.stock = '' |
|
|
|
|
}else if(tab.value == 'integral'){ |
|
|
|
|
obj.integral = '' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
this.stockList.push(obj) |
|
|
|
|
let obj = { |
|
|
|
|
marketPrice:'', |
|
|
|
|
sellPrice:'', |
|
|
|
|
stock:'', |
|
|
|
|
integral:'' |
|
|
|
|
} |
|
|
|
|
if(this.attributesList.length ==1){ |
|
|
|
|
let data = {} |
|
|
|
|
let name = this.attributesList[0].attributeName |
|
|
|
|
let value = this.radioAttributes |
|
|
|
|
data[name] = value |
|
|
|
|
obj.attributeJson = JSON.stringify(data) |
|
|
|
|
this.stockList.push(obj) |
|
|
|
|
}else{ |
|
|
|
|
this.checkboxAttributes.forEach((tab,index)=>{ |
|
|
|
|
let name = this.attributesList[0].attributeName |
|
|
|
|
let value = this.radioAttributes |
|
|
|
|
let tabName = this.attributesList[index+1].attributeName |
|
|
|
|
let tabValue = tab |
|
|
|
|
data[name] = value |
|
|
|
|
data[tabName] = tabValue |
|
|
|
|
obj.attributeJson = JSON.stringify(data) |
|
|
|
|
this.stockList.push(obj) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 调用系统相机 |
|
|
|
|
takePhoto() { |
|
|
|
|
// 先检查权限 |
|
|
|
|
let _that = this |
|
|
|
|
uni.getSetting({ |
|
|
|
|
success(res) { |
|
|
|
|
if (!res.authSetting['scope.camera']) { |
|
|
|
|
// 请求权限 |
|
|
|
|
uni.authorize({ |
|
|
|
|
scope: 'scope.camera', |
|
|
|
|
success() { |
|
|
|
|
// 权限已经获取,可以调用相机 |
|
|
|
|
_that.srcFileImage() |
|
|
|
|
}, |
|
|
|
|
fail() { |
|
|
|
|
// 用户拒绝授权,需引导用户开启权限 |
|
|
|
|
uni.showModal({ |
|
|
|
|
title: '提示', |
|
|
|
|
content: '需要相机权限才能使用相机功能,请在设置中打开', |
|
|
|
|
success: (modalRes) => { |
|
|
|
|
if (modalRes.confirm) { |
|
|
|
|
// 引导用户去设置中打开权限 |
|
|
|
|
uni.openSetting({ |
|
|
|
|
success(res) { |
|
|
|
|
if (res.authSetting['scope.camera']) { |
|
|
|
|
re() |
|
|
|
|
// 授权成功 |
|
|
|
|
} else { |
|
|
|
|
// 没有允许相机权限 |
|
|
|
|
wx.showToast({ |
|
|
|
|
title: '您拒绝了相机权限,将无法使用相机功能', |
|
|
|
|
icon: 'none' |
|
|
|
|
}); |
|
|
|
|
rj('拒绝了相机权限') |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail() { |
|
|
|
|
rj('openSetting调用失败') |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
// 权限已经获取,可以直接调用相机 |
|
|
|
|
_that.srcFileImage() |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
fail(err) { |
|
|
|
|
// 获取设置失败 |
|
|
|
|
console.error(err); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
//调起上传图片 |
|
|
|
|
srcFileImage() { |
|
|
|
|
let _that = this |
|
|
|
@ -447,6 +452,15 @@ |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
setMainImage(index){ |
|
|
|
|
this.productDate.images.forEach((tab,i)=>{ |
|
|
|
|
if(i == index){ |
|
|
|
|
tab.mainMark = 1 |
|
|
|
|
}else{ |
|
|
|
|
tab.mainMark = '' |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
clearImage(index){ |
|
|
|
|
if(this.productDate.images[index].mainMark == 1){ |
|
|
|
|
this.productDate.images.splice(index,1) |
|
|
|
@ -455,17 +469,21 @@ |
|
|
|
|
this.productDate.images.splice(index,1) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
picker2(e){ |
|
|
|
|
console.log(e.detail.value) |
|
|
|
|
this.productDate.value = e.detail.value |
|
|
|
|
}, |
|
|
|
|
closed(){ |
|
|
|
|
uni.navigateTo({ |
|
|
|
|
url: '/pages/index/index' |
|
|
|
|
}) |
|
|
|
|
uni.navigateBack() |
|
|
|
|
}, |
|
|
|
|
addCompleted(){ |
|
|
|
|
|
|
|
|
|
if(this.radioItem[0].checked =true){ |
|
|
|
|
this.productDate.newMark == '1' |
|
|
|
|
}else{ |
|
|
|
|
this.productDate.newMark == '2' |
|
|
|
|
} |
|
|
|
|
if(this.radioItem[1].checked =true){ |
|
|
|
|
this.productDate.recommend == '1' |
|
|
|
|
}else{ |
|
|
|
|
this.productDate.recommend == '2' |
|
|
|
|
} |
|
|
|
|
this.productDate.stockList = this.stockList |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -549,7 +567,6 @@ |
|
|
|
|
.tagButton{ |
|
|
|
|
display: inline-block; |
|
|
|
|
width: 133rpx; |
|
|
|
|
height: 58rpx; |
|
|
|
|
background: #f5f5f5; |
|
|
|
|
color: #666666; |
|
|
|
|
border-radius: 8rpx; |
|
|
|
@ -584,6 +601,8 @@ |
|
|
|
|
display: inline-block; |
|
|
|
|
width: 140rpx; |
|
|
|
|
height: 140rpx; |
|
|
|
|
vertical-align: middle; |
|
|
|
|
text-align: center; |
|
|
|
|
position: relative; |
|
|
|
|
>image{ |
|
|
|
|
width: 100%; |
|
|
|
|