From 28e2bc7e92c1634eaf79fcc76d08b7012bdf6957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B1=AA?= <781521347@qq.com> Date: Thu, 4 Nov 2021 18:49:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A4=E8=AF=81=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9=EF=BC=8C=E4=B8=8A=E4=BC=A0=E5=95=86?= =?UTF-8?q?=E5=93=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 7 +- pages/life/addGoods/index.vue | 354 +++++++++++++++------- pages/life/index.vue | 7 +- pages/release/companyAuth/index.vue | 1 + pages/release/perfectPersonInfo/index.vue | 58 +--- pages/release/personAuth/index.vue | 19 -- pages/user/goodsManage/index.vue | 5 + static/images/batch-icon.png | Bin 0 -> 569 bytes 8 files changed, 253 insertions(+), 198 deletions(-) create mode 100644 static/images/batch-icon.png diff --git a/App.vue b/App.vue index 7eba616..3783774 100644 --- a/App.vue +++ b/App.vue @@ -27,9 +27,8 @@ export default { }, onShow(e) { - this.globalData.scene = e.scene - console.log(this.globalData.scene,'this.globalData.scene') + // console.log(this.globalData.scene,'this.globalData.scene') //隐藏系统tabbar uni.hideTabBar(); var query = {}; @@ -47,12 +46,12 @@ export default { query = JSON.parse("{" + urlSpread + "}"); } - console.log('query1', query); + // console.log('query1', query); this.globalData.inviterId = query.id; } } else { query = e.query; - console.log('query2', query); + // console.log('query2', query); this.globalData.inviterId = query.id; } }, diff --git a/pages/life/addGoods/index.vue b/pages/life/addGoods/index.vue index 66cc27d..303e18c 100644 --- a/pages/life/addGoods/index.vue +++ b/pages/life/addGoods/index.vue @@ -40,37 +40,6 @@ - - 规格设置 @@ -86,32 +55,29 @@ × - - - - - 价格* - - - - 库存* - - - - {{batchData.titleStr}} - 库存 - 价格 + + + 批量修改 + - - - {{i.sku.split(',').reverse().join('/')}} - - + + + + + {{i.sku.split(',').reverse().join('/')}} + + + + 售价¥{{i.price}} + 库存{{i.stock}} + + + @@ -128,10 +94,10 @@ @@ -139,6 +105,26 @@ 提交 + + + {{attrValTitle}} + + 售价(¥) + + + + 原价(¥) + + + + 库存 + + + + 取消 + 确定 + + @@ -182,21 +168,55 @@ { pic: '', //"规格图片 --可选", price: '', //"价格 元", - ot_orice: '', //"市场价格 --可选", + ot_price: '', //"市场价格 --可选", stock: '', //"库存", weight: '', //"重量 --可选", volume: '', //"体积 --可选" } ], + price: '', + ot_price: '', + stock:'', + isShow: 0, + spec_type: 0, items: [], - attrArr:[], + attrArr:[{ + value: '规格', + detail:['默认'] + }], attr:{}, state: 0, maskShow: false, addOptionsDialog: false, infinite: false, - batchData: {titleStr: '',priceArr: []}, + batchData: { + titleStr: '规格', + priceArr: [ + { + bar_code: "", + brokerage: 0, + brokerage_two: 0, + cost: 0, + integral: 0, + ot_price: 0, + pic: "", + pink_price: 0, + pink_stock: 0, + price: 0, + seckill_price: 0, + seckill_stock: 0, + sku: "默认", + stock: 0, + value1: "", + volume: 0, + weight: 0, + } + ], + }, editattr: false, + idx: null, + showAttrVal: false, + attrValTitle: '' } }, @@ -214,20 +234,16 @@ this.description = info.description this.store_name = info.store_name this.items = info.items - if(info.attrs){ - this.$set(this.batchData,'priceArr',info.attrs) - this.attrArr = info.items - let strArr = info.items.map(item=>{ - return item.value - }) - console.log(strArr) - this.$set(this.batchData,'titleStr',strArr.join('/')) - } else{ - this.attrs[0].price = info.price - this.attrs[0].stock = info.stock - } + this.attrArr = info.items + this.spec_type = 1 + this.isShow = info.is_show + let strArr = info.items.map(item=>{ + return item.value + }) + this.getFormatAttr() }) } else{ + this.spec_type = 0 console.log('新增') } }, @@ -236,8 +252,9 @@ var imgurls = [] chooseImages((imgs)=>{ imgurls.push(imgs) + this.slider_image = imgurls }) - this.slider_image = imgurls + }, uploadImg(idx){ chooseImage((img)=>{ @@ -248,11 +265,6 @@ } }) }, - uploadSkuImg(idx){ - chooseImage((img)=>{ - this.$set(this.attrs,idx,{pic: img}) - }) - }, toGoodsDetails(){ uni.navigateTo({ url: '/pages/life/goodsDetails/index?desc='+encodeURIComponent(this.description) @@ -265,10 +277,7 @@ }, //添加属性按钮 addAttr(){ - let j = { - value: '', - detail:[''] - } + let j = { value: '', detail:[''] } this.attr = j this.editattr = false; //添加新属性时是否编辑attr切换成FALSE this.maskShow = true; @@ -364,47 +373,69 @@ let allArr = cartesianProductOf(...tmp) return allArr }, - // 批量设置价格库存 - changePrice(e){ - const price = e.detail.value - if(this.batchData.priceArr && this.batchData.priceArr.length > 0){ - this.batchData.priceArr.forEach((item,i)=>{ - item.price = price - }) + + //上传规格图片 + uploadAttrImg(idx){ + chooseImage((img)=>{ + this.batchData.priceArr[idx].pic= img + }) + }, + //设置规格属性值 + setAttrVal(idx,type){ + if(type == 0){ + this.idx = idx + this.price= this.batchData.priceArr[idx].price + this.ot_price= this.batchData.priceArr[idx].ot_price + this.stock= this.batchData.priceArr[idx].stock + this.attrValTitle = this.batchData.priceArr[idx].sku.split(',').reverse().join('/') + } else{ + this.attrValTitle = '批量修改规格' } - this.attrs[0].price = price - // console.log(this.batchData.priceArr,'this.batchData.priceArr') + + this.showAttrVal= true }, - changeStock(e){ - const stock = e.detail.value - if(this.batchData.priceArr && this.batchData.priceArr.length > 0){ - this.batchData.priceArr.forEach((item,i)=>{ - item.stock = stock + cancelClick(){ + this.idx = null + this.showAttrVal= false + }, + submitClick(){ + const idx = this.idx + console.log(this.price,this.ot_price,this.stock) + if(this.stock == 0){ + return this.alertMessage('商品库存不能为0') + } + if(this.attrValTitle == '批量修改规格'){ + this.batchData.priceArr.forEach((item)=>{ + item.price = this.price + item.ot_price = this.ot_price + item.stock = this.stock }) - } - this.attrs[0].stock = stock + } else{ + this.$set(this.batchData.priceArr[idx],'price',this.price) + this.$set(this.batchData.priceArr[idx],'ot_price',this.ot_price) + this.$set(this.batchData.priceArr[idx],'stock',this.stock) + // this.batchData.priceArr[idx].price= this.price + // this.batchData.priceArr[idx].ot_price= this.ot_price + // this.batchData.priceArr[idx].stock= this.stock + } + this.showAttrVal= false + }, + radioChange(e){ + this.isShow= e.detail.value }, submit(){ // console.log(this.batchData) - var arrtsArr = [] - if(this.batchData.priceArr && this.batchData.priceArr[0].price != ''){ - arrtsArr = this.batchData.priceArr - } else{ - arrtsArr = this.attrs - } let form = { store_name: this.store_name, unit_name: this.unit_name, image: this.slider_image[0], //主图 slider_image: this.slider_image , // 轮播图 description: this.description, //商品详情富文本 - tempId: this.tempId, //运费方案 - attrs: arrtsArr, - state: this.state, - items: this.items, - spec_type: arrtsArr.length > 1 ? 1 : 0 //单规格,多规格 + temp_id: this.tempId, //运费方案 + attrs: this.batchData.priceArr, + isShow: this.isShow, + items: this.items } - console.log(form) if(form.store_name == ''){ this.alertMessage('请填写商品名称') return @@ -419,16 +450,18 @@ return } form.attrs.forEach((item,index)=>{ - if(item.price == ''){ + if(item.price == '' || item.price == 0){ this.alertMessage('请商品规格价格') return - } else if(item.stock == ''){ - this.alertMessage('请商品规格库存') + } else if(item.stock == '' || item.stock == 0){ + this.alertMessage('库存不能为0') return } }) if(this.id != ''){ form.id = this.id + form.spec_type = this.spec_type + console.log(form) editProduct(form).then((res)=>{ if(res.success){ uni.showToast({ @@ -448,6 +481,8 @@ } }) } else{ + form.spec_type = this.batchData.priceArr.length > 1 ? 1 : 0 + console.log(form) addProduct(form).then((res)=>{ if(res.success){ uni.showToast({ @@ -603,6 +638,7 @@ padding: 32rpx; font-size: 28rpx; font-weight: 500; + margin-bottom: 12rpx; image{ width: 24rpx; height: 24rpx; @@ -682,14 +718,46 @@ width: 19%; text-align: center; } + .batch{ + font-size: 24rpx; + color: #000; + image{ + width: 24rpx; + height: 26rpx; + margin-right: 10rpx; + } + } } .box-b{ - margin-top: 6rpx; - .name{ + width: 100%; + height: 100rpx; + background: #FFFFFF; + border: 2rpx solid #C0C0C0; + border-radius: 8rpx; + margin-top: 22rpx; + padding: 0 20rpx; + .box-b-l{ width: 60%; + .name{ + width: calc(100% - 90rpx); + } + .attrImg{ + width: 70rpx; + height: 70rpx; + border-radius: 8rpx; + margin-right: 16rpx; + } } - .w15{ - width: 19%; + .box-b-r{ + font-size: 24rpx; + color: #FF0000; + font-weight: 500; + margin-right: 14rpx; + } + .arrow{ + width: 24rpx; + height: 24rpx; + transform: rotate(90deg); } .inp-box{ text-align: center; @@ -703,6 +771,62 @@ } } } + .set-attr-val{ + width: 100%; + padding: 0 40rpx 90rpx; + border-radius: 60rpx 60rpx 0px 0px; + background:#fff; + box-shadow: 0px 6rpx 12rpx rgba(0, 0, 0, 0.2); + position: fixed; + left: 0; + bottom: -999rpx; + transition: bottom .2s ease ; + &.isShow{ + bottom: 0; + } + .title{ + font-size: 44rpx; + color: #343434; + text-align: center; + padding: 44rpx 0; + } + .inp-box{ + display: flex; + align-items: center; + width: 100%; + height: 72rpx; + background: #F1F1F1; + border-radius: 8rpx; + padding: 0 40rpx; + font-size: 32rpx; + color: #000; + margin-bottom: 28rpx; + text{ + width: 200rpx; + display: inline-block; + } + } + .btn-box{ + display: flex; + justify-content: space-around; + view{ + width: 230rpx; + height: 80rpx; + text-align: center; + line-height: 80rpx; + background: #E9E9E9; + border-radius: 40rpx; + font-size: 38rpx; + color: #fff; + } + .cancel-btn{ + bakcground:#E9E9E9 + } + .submit-btn{ + background: linear-gradient(134deg, #FFA782 0%, #FF6D31 100%); + } + } + } //弹出层 .mask-box{ width: 100%; @@ -730,7 +854,7 @@ } .a-name{ width: 560rpx; - height: 104rpx; + // height: 104rpx; background: #F7F7F7; border-radius: 12rpx; padding: 30rpx; @@ -745,7 +869,7 @@ width: 80%; } .o-item-box{ - height: 56rpx; + height: 74rpx; padding-bottom: 10rpx; margin-bottom: 10rpx; border-bottom: 2rpx solid #ececec; diff --git a/pages/life/index.vue b/pages/life/index.vue index 97028c2..8859db7 100644 --- a/pages/life/index.vue +++ b/pages/life/index.vue @@ -18,7 +18,7 @@ -