|
|
|
@ -11,7 +11,7 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="formBox"> |
|
|
|
<scroll-view scroll-y class="formBox" :scroll-into-view="scrollTarget" scroll-with-animation> |
|
|
|
<uni-forms ref="form" :modelValue="formData" :rules="rules" labelWidth="170rpx"> |
|
|
|
<uni-forms-item label="商品名称" name="productName" required> |
|
|
|
<uni-easyinput type="text" v-model="formData.productName" placeholder="请输入商品名称" trim="all" /> |
|
|
|
@ -38,12 +38,12 @@ |
|
|
|
style="margin-left: 40rpx;line-height: 70rpx;"></uni-icons> |
|
|
|
</view> |
|
|
|
</uni-forms-item> |
|
|
|
<uni-forms-item label="商品规格" name="attributeListPrice"> |
|
|
|
<uni-forms-item label="商品价格" name="attributeListPrice"> |
|
|
|
<view> |
|
|
|
<view v-for="(item,index) in formData.attributeListPrice" :key="index" style="display: flex;margin-top:10rpx;"> |
|
|
|
<input class="content-input" v-model="item.specName" v-if="item.specName != ''&& formData.attributeListPrice.length != 1" style="padding-right: 20rpx;" disabled /> |
|
|
|
<input class="content-input" v-model="item.specPrice" style="padding-right: 20rpx;margin-right: 20rpx;" @click="changePrice(index)" placeholder="商品价格" /> |
|
|
|
<input class="content-input" v-model="item.specNum" style="padding-right: 20rpx;" @click="changecount(index)" placeholder="商品库存"/> |
|
|
|
<input type="digit" min="0.01" class="content-input" v-model="item.specPrice" style="padding-right: 20rpx;margin-right: 20rpx;" @click="changePrice(index)" placeholder="商品价格" /> |
|
|
|
<input type="number" class="content-input" v-model="item.specNum" style="padding-right: 20rpx;" @input="changeSpecNum($event,index)" placeholder="商品库存"/> |
|
|
|
<button @click="deldantiaoguige(index)" v-if="formData.attributeListPrice.length>1" style="width: 240rpx;height: 60rpx;line-height: 60rpx;color: red;border:none;background: #fff;">删除</button> |
|
|
|
</view> |
|
|
|
<!-- <view @click="checkSpec('guige')" style="margin-top: 5px;width: 80px;height: 30px;text-align: center;line-height: 30px;background: rgba(0, 35, 28, 1);border-radius: 30px;color: rgba(166, 255, 234, 1);"> |
|
|
|
@ -54,8 +54,8 @@ |
|
|
|
<uni-forms-item label="拼团信息" name="productGroupBuyPrices"> |
|
|
|
<view> |
|
|
|
<view v-for="(item,index) in formData.productGroupBuyPrices" :key="index" style="display: flex;margin-top:10rpx;"> |
|
|
|
<input class="content-input" v-model="item.groupCount" style="padding-right: 20rpx;margin-right: 20rpx;width: 100px;" placeholder="成团人数" /> |
|
|
|
<input class="content-input" v-model="item.groupPrice" style="padding-right: 20rpx;width: 100px;" placeholder="成团价格"/> |
|
|
|
<input type="number" min="2" class="content-input" v-model="item.groupCount" style="padding-right: 20rpx;margin-right: 20rpx;width: 100px;" placeholder="成团人数" /> |
|
|
|
<input type="digit" class="content-input" v-model="item.groupPrice" style="padding-right: 20rpx;width: 100px;" placeholder="拼团价格"/> |
|
|
|
<view @click="delGroup(index)" v-if="formData.productGroupBuyPrices.length>1" style="width: 240rpx;height: 60rpx;line-height: 60rpx;color: red;border:none;background: #fff;">删除</view> |
|
|
|
</view> |
|
|
|
<view @click="addGroup()" style="margin-top: 10rpx;width: 160rpx;height: 60rpx;text-align: center;line-height: 60rpx;background: rgba(0, 35, 28, 1);border-radius: 60rpx;color: rgba(166, 255, 234, 1);"> |
|
|
|
@ -102,12 +102,18 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-forms-item> |
|
|
|
<uni-forms-item label="餐盒费" name="lunchBox"> |
|
|
|
<input type="digit" class="content-input" v-model="formData.lunchBox" placeholder="请输入餐盒费"> |
|
|
|
</uni-forms-item> |
|
|
|
<uni-forms-item label="起售数量" name="startPayNum"> |
|
|
|
<input type="digit" class="content-input" v-model="formData.startPayNum" placeholder="请输入起售数量"> |
|
|
|
</uni-forms-item> |
|
|
|
<view id="lunchBoxField" v-if="shop.merchantType == 1"> |
|
|
|
<uni-forms-item label="餐盒费" name="lunchBox"> |
|
|
|
<input type="digit" class="content-input" v-model="formData.lunchBox" placeholder="请输入餐盒费" |
|
|
|
:adjust-position="false" :cursor-spacing="160" @focus="focusFormField('lunchBoxField')" @blur="blurFormField"> |
|
|
|
</uni-forms-item> |
|
|
|
</view> |
|
|
|
<view id="startPayNumField"> |
|
|
|
<uni-forms-item label="起售数量" name="startPayNum"> |
|
|
|
<input type="number" class="content-input" v-model="formData.startPayNum" @input="changeStartPayNum" placeholder="请输入起售数量" |
|
|
|
:adjust-position="false" :cursor-spacing="160" @focus="focusFormField('startPayNumField')" @blur="blurFormField"> |
|
|
|
</uni-forms-item> |
|
|
|
</view> |
|
|
|
<uni-forms-item label="详细图文" name="startPayNum"> |
|
|
|
<view class="xiangxi-box"> |
|
|
|
<sp-editor |
|
|
|
@ -123,33 +129,37 @@ |
|
|
|
<view> |
|
|
|
<button @tap.stop="submit()">保存</button> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="keyboard-safe-bottom"></view> |
|
|
|
</scroll-view> |
|
|
|
<!-- 添加分类弹出层 --> |
|
|
|
<uni-popup ref="addTypeDialog" background-color="#fff"> |
|
|
|
<view class="add-popup-content"> |
|
|
|
<view style="height:900rpx;display: flex;"> |
|
|
|
<view class="content-left"> |
|
|
|
<view class="attr-popup-body"> |
|
|
|
<scroll-view scroll-y class="content-left"> |
|
|
|
<view class="left-box" v-for="(item,index) in categoryData" :key="index" |
|
|
|
:class="item.parentId ? 'left-box-hover':''" @tap="clickLeftBtn(index)"> |
|
|
|
<text style="width: 100%;height: 100rpx;line-height: 100rpx;display: inline-block;overflow: hidden;" |
|
|
|
:class="item.parentId ? 'red' :''">{{item.title}}</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view style="flex: 1;position: relative;padding: 20rpx;"> |
|
|
|
<view v-for="(item,index) in categorySonData" :key="index" @tap="checkSpecValue(index)" class="content-low" :class="item.checked?'checked':''"> |
|
|
|
{{item.title}} |
|
|
|
</view> |
|
|
|
<view style="position: absolute;bottom: 0;"> |
|
|
|
<view style="font-size: 28rpx;line-height: 60rpx;font-weight: 700;"> |
|
|
|
</scroll-view> |
|
|
|
<view class="attr-popup-right"> |
|
|
|
<scroll-view scroll-y class="attr-value-scroll"> |
|
|
|
<view v-for="(item,index) in categorySonData" :key="index" @tap="checkSpecValue(index)" class="content-low" :class="item.checked?'checked':''"> |
|
|
|
{{item.title}} |
|
|
|
</view> |
|
|
|
</scroll-view> |
|
|
|
<view class="canbuy-box" v-if="modalclassType == 'shuxing'"> |
|
|
|
<view class="canbuy-label"> |
|
|
|
该分类可选数量 |
|
|
|
</view> |
|
|
|
<input type="digit" class="content-input" v-model="currentCanbuy" placeholder="该分类可选几个(默认1)"> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view slot="footer" style="display: flex;padding-left: 40rpx;margin-top: 20rpx;"> |
|
|
|
<button type="text" @tap="$refs.addTypeDialog.close()" style="margin-right: 20rpx;">取消</button> |
|
|
|
<button type="text" @tap="guigeSubmit">提交</button> |
|
|
|
<view class="attr-popup-footer"> |
|
|
|
<view class="attr-popup-btn plain" @tap="$refs.addTypeDialog.close()">取消</view> |
|
|
|
<view class="attr-popup-btn primary" @tap="guigeSubmit">提交</view> |
|
|
|
<view class="attr-manage-entry" v-if="modalclassType == 'shuxing'" @tap="goAttributeList">维护属性</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-popup> |
|
|
|
@ -172,9 +182,11 @@ |
|
|
|
categorySonData:[], |
|
|
|
specValueArr:[], |
|
|
|
attrValueArr:[], |
|
|
|
scrollTarget:'', |
|
|
|
editorIns: null, |
|
|
|
typeItem: {}, |
|
|
|
menuButtonInfo: {}, |
|
|
|
shop:{}, |
|
|
|
formData: { |
|
|
|
id: '', |
|
|
|
shopId: '', |
|
|
|
@ -221,6 +233,7 @@ |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
this.attrId = uni.getStorageSync('attrId'); |
|
|
|
this.shop = uni.getStorageSync('shop'); |
|
|
|
this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() |
|
|
|
uni.authorize({ |
|
|
|
scope: 'scope.writePhotosAlbum', |
|
|
|
@ -388,6 +401,15 @@ |
|
|
|
// 触发提交表单 |
|
|
|
submit() { |
|
|
|
let that = this; |
|
|
|
if (!this.validateProductSpecs()) { |
|
|
|
return |
|
|
|
} |
|
|
|
if (!this.validateProductNumbers()) { |
|
|
|
return |
|
|
|
} |
|
|
|
if (!this.validateGroupBuyPrices()) { |
|
|
|
return |
|
|
|
} |
|
|
|
// this.$refs.form.validate((valid) => { |
|
|
|
// if (valid) { |
|
|
|
if (this.modalType == 0) { |
|
|
|
@ -426,6 +448,81 @@ |
|
|
|
back() { |
|
|
|
uni.navigateBack() |
|
|
|
}, |
|
|
|
validateProductSpecs() { |
|
|
|
for (let i = 0; i < this.formData.attributeListPrice.length; i++) { |
|
|
|
const specPrice = String(this.formData.attributeListPrice[i].specPrice).trim() |
|
|
|
if (!this.isValidPrice(specPrice)) { |
|
|
|
this.tui.toast('商品价格必须大于0且最多2位小数') |
|
|
|
return false |
|
|
|
} |
|
|
|
const specNum = String(this.formData.attributeListPrice[i].specNum).trim() |
|
|
|
if (!this.isValidInteger(specNum)) { |
|
|
|
this.tui.toast('商品库存只能输入整数') |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
return true |
|
|
|
}, |
|
|
|
validateProductNumbers() { |
|
|
|
const lunchBox = String(this.formData.lunchBox).trim() |
|
|
|
if (!this.isValidAmount(lunchBox)) { |
|
|
|
this.tui.toast('餐盒费最多2位小数') |
|
|
|
return false |
|
|
|
} |
|
|
|
const startPayNum = String(this.formData.startPayNum).trim() |
|
|
|
if (startPayNum !== '' && !this.isValidInteger(startPayNum)) { |
|
|
|
this.tui.toast('起售数量只能输入整数') |
|
|
|
return false |
|
|
|
} |
|
|
|
return true |
|
|
|
}, |
|
|
|
validateGroupBuyPrices() { |
|
|
|
const minSpecPrice = Math.min(...this.formData.attributeListPrice.map((item) => Number(item.specPrice))) |
|
|
|
for (let i = 0; i < this.formData.productGroupBuyPrices.length; i++) { |
|
|
|
const groupCount = Number(this.formData.productGroupBuyPrices[i].groupCount) |
|
|
|
if (!groupCount || groupCount < 2) { |
|
|
|
this.tui.toast('拼团人数不能小于2') |
|
|
|
return false |
|
|
|
} |
|
|
|
const groupPrice = String(this.formData.productGroupBuyPrices[i].groupPrice).trim() |
|
|
|
if (!this.isValidPrice(groupPrice)) { |
|
|
|
this.tui.toast('拼团价必须大于0且最多2位小数') |
|
|
|
return false |
|
|
|
} |
|
|
|
if (Number(groupPrice) >= minSpecPrice) { |
|
|
|
this.tui.toast('拼团价必须低于商品价格') |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
return true |
|
|
|
}, |
|
|
|
isValidPrice(value) { |
|
|
|
return /^\d+(\.\d{1,2})?$/.test(value) && Number(value) > 0 |
|
|
|
}, |
|
|
|
isValidAmount(value) { |
|
|
|
return /^\d+(\.\d{1,2})?$/.test(value) && Number(value) >= 0 |
|
|
|
}, |
|
|
|
isValidInteger(value) { |
|
|
|
return /^\d+$/.test(value) |
|
|
|
}, |
|
|
|
changeSpecNum(e,index){ |
|
|
|
this.formData.attributeListPrice[index].specNum = String(e.detail.value).replace(/\D/g, '') |
|
|
|
if (this.specValueArr[index]) { |
|
|
|
this.specValueArr[index].specNum = this.formData.attributeListPrice[index].specNum |
|
|
|
} |
|
|
|
}, |
|
|
|
changeStartPayNum(e){ |
|
|
|
this.formData.startPayNum = String(e.detail.value).replace(/\D/g, '') |
|
|
|
}, |
|
|
|
focusFormField(fieldId){ |
|
|
|
this.scrollTarget = '' |
|
|
|
this.$nextTick(() => { |
|
|
|
this.scrollTarget = fieldId |
|
|
|
}) |
|
|
|
}, |
|
|
|
blurFormField(){ |
|
|
|
this.scrollTarget = '' |
|
|
|
}, |
|
|
|
checkisMoreBuy(type){ |
|
|
|
this.formData.isMoreBuy = type; |
|
|
|
}, |
|
|
|
@ -652,6 +749,10 @@ |
|
|
|
that.tui.request("/app/productAttribute/selectByCategoryId", "post", {categoryId:that.attrId}, false, true).then((res) => { |
|
|
|
if (res.code == 200) { |
|
|
|
that.categoryData = res.result |
|
|
|
if (that.categoryData.length == 0) { |
|
|
|
that.categorySonData = [] |
|
|
|
return |
|
|
|
} |
|
|
|
for (var i = 0; i < that.categoryData.length; i++) { |
|
|
|
that.categoryData[i].title = that.categoryData[i].attributeName |
|
|
|
if (i == that.categoryIndex) { |
|
|
|
@ -740,10 +841,16 @@ |
|
|
|
addGroup(){ |
|
|
|
let data = { |
|
|
|
groupCount:'', |
|
|
|
groupPrice:0 |
|
|
|
groupPrice:'' |
|
|
|
} |
|
|
|
this.formData.productGroupBuyPrices.push(data) |
|
|
|
}, |
|
|
|
goAttributeList(){ |
|
|
|
this.$refs.addTypeDialog.close() |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/package2/myCenter/attributeList' |
|
|
|
}) |
|
|
|
}, |
|
|
|
async upLoadFile(path) { |
|
|
|
let that = this; |
|
|
|
let hiver_token = uni.getStorageSync("hiver_token") |
|
|
|
@ -784,19 +891,24 @@ |
|
|
|
font-size: 24rpx; |
|
|
|
background: #F5F8F5; |
|
|
|
color: #00231C; |
|
|
|
overflow: hidden; |
|
|
|
} |
|
|
|
|
|
|
|
.page1 { |
|
|
|
width: 100%; |
|
|
|
height: 100%; |
|
|
|
height: 100vh; |
|
|
|
font-size: 24rpx; |
|
|
|
position: relative; |
|
|
|
overflow: hidden; |
|
|
|
} |
|
|
|
|
|
|
|
.title { |
|
|
|
background: url('https://jewel-shop.oss-cn-beijing.aliyuncs.com/8bc15960c2dc40268e295d6dd23aecce.png') no-repeat; |
|
|
|
width: 100%; |
|
|
|
height: 54%; |
|
|
|
position: fixed; |
|
|
|
top: 0; |
|
|
|
left: 0; |
|
|
|
} |
|
|
|
|
|
|
|
.title-sreach { |
|
|
|
@ -829,8 +941,9 @@ |
|
|
|
top: 200rpx; |
|
|
|
left: 2.5%; |
|
|
|
width: 95%; |
|
|
|
overflow: scroll; |
|
|
|
height: 85%; |
|
|
|
bottom: 30rpx; |
|
|
|
box-sizing: border-box; |
|
|
|
overflow-y: scroll; |
|
|
|
} |
|
|
|
|
|
|
|
.upload-img { |
|
|
|
@ -853,23 +966,99 @@ |
|
|
|
position: relative; |
|
|
|
overflow: hidden; |
|
|
|
flex: 1; |
|
|
|
line-height: 1; |
|
|
|
line-height: 70rpx; |
|
|
|
font-size: 28rpx; |
|
|
|
height: 70rpx; |
|
|
|
border: 4rpx solid #eee; |
|
|
|
padding-left: 20rpx; |
|
|
|
border-radius: 10rpx; |
|
|
|
box-sizing: border-box; |
|
|
|
min-width: 0; |
|
|
|
} |
|
|
|
.keyboard-safe-bottom { |
|
|
|
height: 260rpx; |
|
|
|
} |
|
|
|
|
|
|
|
.add-popup-content { |
|
|
|
align-items: center; |
|
|
|
justify-content: center; |
|
|
|
padding: 30rpx 30rpx 30rpx 0; |
|
|
|
width: 600rpx; |
|
|
|
height: 1050rpx; |
|
|
|
width: 660rpx; |
|
|
|
max-width: 92vw; |
|
|
|
height: 78vh; |
|
|
|
background-color: #fff; |
|
|
|
overflow: scroll; |
|
|
|
border-radius: 20rpx; |
|
|
|
overflow: hidden; |
|
|
|
border-radius: 24rpx; |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
box-sizing: border-box; |
|
|
|
} |
|
|
|
.attr-popup-body { |
|
|
|
flex: 1; |
|
|
|
min-height: 0; |
|
|
|
display: flex; |
|
|
|
} |
|
|
|
.attr-popup-right { |
|
|
|
flex: 1; |
|
|
|
min-width: 0; |
|
|
|
display: flex; |
|
|
|
flex-direction: column; |
|
|
|
padding: 20rpx; |
|
|
|
box-sizing: border-box; |
|
|
|
} |
|
|
|
.attr-value-scroll { |
|
|
|
flex: 1; |
|
|
|
min-height: 0; |
|
|
|
} |
|
|
|
.canbuy-box { |
|
|
|
flex-shrink: 0; |
|
|
|
padding-top: 18rpx; |
|
|
|
background: #fff; |
|
|
|
} |
|
|
|
.canbuy-label { |
|
|
|
font-size: 28rpx; |
|
|
|
line-height: 56rpx; |
|
|
|
font-weight: 700; |
|
|
|
color: #00231C; |
|
|
|
} |
|
|
|
.attr-popup-footer { |
|
|
|
flex-shrink: 0; |
|
|
|
display: flex; |
|
|
|
flex-wrap: wrap; |
|
|
|
gap: 18rpx; |
|
|
|
padding: 18rpx 28rpx 26rpx; |
|
|
|
box-sizing: border-box; |
|
|
|
background: #fff; |
|
|
|
box-shadow: 0 -8rpx 24rpx rgba(0, 0, 0, 0.04); |
|
|
|
} |
|
|
|
.attr-popup-btn { |
|
|
|
flex: 1; |
|
|
|
height: 82rpx; |
|
|
|
line-height: 82rpx; |
|
|
|
text-align: center; |
|
|
|
border-radius: 82rpx; |
|
|
|
font-size: 30rpx; |
|
|
|
font-weight: 700; |
|
|
|
box-sizing: border-box; |
|
|
|
} |
|
|
|
.attr-popup-btn.plain { |
|
|
|
background: #F7F8F8; |
|
|
|
color: #00231C; |
|
|
|
} |
|
|
|
.attr-popup-btn.primary { |
|
|
|
background: linear-gradient(90deg, rgba(227, 255, 150, 1), rgba(166, 255, 234, 1)); |
|
|
|
color: #00231C; |
|
|
|
} |
|
|
|
.attr-manage-entry { |
|
|
|
width: 100%; |
|
|
|
height: 78rpx; |
|
|
|
line-height: 78rpx; |
|
|
|
margin: 0; |
|
|
|
text-align: center; |
|
|
|
border-radius: 78rpx; |
|
|
|
border: 2rpx solid rgba(0, 35, 28, 0.18); |
|
|
|
color: #00231C; |
|
|
|
font-size: 28rpx; |
|
|
|
font-weight: 700; |
|
|
|
background: rgba(166, 255, 234, 0.2); |
|
|
|
box-sizing: border-box; |
|
|
|
} |
|
|
|
.xiangxi-box{ |
|
|
|
flex: 1; |
|
|
|
@ -897,8 +1086,7 @@ |
|
|
|
.content-left { |
|
|
|
width: 160rpx; |
|
|
|
background: rgba(247, 248, 248, 0.6); |
|
|
|
height: 900rpx; |
|
|
|
overflow: scroll; |
|
|
|
height: 100%; |
|
|
|
scrollbar-width: none; |
|
|
|
} |
|
|
|
.content-low{ |
|
|
|
|