浏览代码

Merge branch 'master' of http://47.98.226.240:3000/twt/txCar

* 'master' of http://47.98.226.240:3000/twt/txCar:
  商品替换添加
  计算价格NAN
guo 3 年之前
父节点
当前提交
398c1952b0
共有 1 个文件被更改,包括 85 次插入9 次删除
  1. 85 9
      pages/module/maintain.vue

+ 85 - 9
pages/module/maintain.vue

@@ -39,7 +39,9 @@
 						<view class="contTop">
 							<view class="contTopLeft">
 								<view class="listPackgeName"> {{item.name}} </view>
-								<view class="listPackgeMs">{{item.referenceDosage}}</view>
+								<view class="listPackgeMs">
+								    <span  v-if="item.referenceDosageQty">{{item.referenceDosage}}</span>
+								</view>
 							</view>
 							<view class="contTopRight" @click="listcheck(item)">
 								<image src="../../static/img/login_icon_checked.png" mode="" class="imgPrivacy" v-show="item.planItem"></image>
@@ -177,6 +179,7 @@ export default {
 			replaceIndex1:'',
 			replaceIndex2:'',
 			brand:'',
+			isNull:true,
 		}
 	},
 	onLoad(opt) {
@@ -319,6 +322,7 @@ export default {
 			
 		},
 		calculation(txt){
+			this.isNull=true
 			this.total=0;
 			this.totalhj=0;
 			this.goodsTotal=0;
@@ -352,9 +356,14 @@ export default {
 									}) */
 									//goods[0].salePrice=1;
 									this.goodsTotal=Number(this.goodsTotal)
-									this.goodsTotal+=goods[0].salePrice*goods[0].qty
-									this.goodsTotal=this.goodsTotal.toFixed(2)
-										obj.listGoodsAll.push(goods[0])
+									if(!isNaN(goods[0].salePrice)){
+										this.goodsTotal+=goods[0].salePrice*goods[0].qty
+										this.goodsTotal=this.goodsTotal.toFixed(2)
+										
+									}else{
+									   this.isNull=false
+							     	}
+									obj.listGoodsAll.push(goods[0])
 									
 								
 								})
@@ -369,10 +378,15 @@ export default {
 							
 							i.listItem.forEach(xm=>{
 								xm.qty=1;
+								if(!isNaN(xm.salePrice)){
+									this.salePriceTotal=Number(this.salePriceTotal)
+									this.salePriceTotal+=xm.salePrice
+									this.salePriceTotal=this.salePriceTotal.toFixed(2)
+								}else{
+									this.isNull=false
+								}
 								//xm.salePrice=1;
-								this.salePriceTotal=Number(this.salePriceTotal)
-								this.salePriceTotal+=xm.salePrice
-								this.salePriceTotal=this.salePriceTotal.toFixed(2)
+								
 							})
 							//this.totalhj
 						}
@@ -386,9 +400,13 @@ export default {
 			console.log(this.orderData)
 		},
 		reduce(v){
+			console.log(v)
 			if(v.qty>1){
 				v.qty--;
 				this.calculation()
+			}else if(v.del){
+				v.qty--;
+				this.calculation()
 			}
 		},
 		plus(v){
@@ -405,7 +423,57 @@ export default {
 			   guidePrice:this.maintainCarData.guidePrice,
 			 },'GET').then(res => {
 				uni.hideLoading();
+				res.data.forEach(item=>{
+					//console.log(item)
+					item.listPackage.forEach((list,i)=>{
+						if(list.listGoodsAll.length>0){
+							//console.log(list)
+							//if(true){
+								//if(list.listGoodsAll[i]!=list.listGoodsAll[i-1]){
+									list.listGoodsAll.forEach((goods,index)=>{
+										//console.log(goods[0])
+										
+										if(goods[0].capacity&&!goods[0].del){
+											//console.log(Number(list.referenceDosageQty)/goods[0].capacity)
+											if(Number(list.referenceDosageQty)/goods[0].capacity>1){
+												console.log("添加一条")
+												var addDta=list.listGoodsAll[index];
+												
+												addDta.forEach(add=>{
+													add.del=true;
+												})
+												//addDta.splice(1,0)
+												//console.log(addDta)
+												var add=JSON.parse(JSON.stringify(addDta))
+												list.listGoodsAll.splice(index+1, 0,add)
+												//list.listGoodsAll.splice(1,0)
+												//list.listGoodsAll.push(list.listGoodsAll[index])
+											}
+										}
+									})
+								//}
+							/* }else{
+								list.listGoodsAll.forEach((goods,index)=>{
+									//console.log(goods[0])
+									
+									if(goods[0].capacity){
+										console.log(Number(list.referenceDosageQty)/goods[0].capacity)
+										if(Number(list.referenceDosageQty)/goods[0].capacity>1){
+											console.log("添加一条")
+											list.listGoodsAll.splice(index+1, 0,list.listGoodsAll[index])
+											//list.listGoodsAll.push(list.listGoodsAll[index])
+										}
+									}
+								})
+							} */
+							
+							
+						}
+					})
+				})
 				this.mealData=res.data;
+				this.mealData.splice(1,0)
+				console.log(this.mealData)
 				this.calculation();
 			})
 		},
@@ -472,16 +540,20 @@ export default {
 <style scoped>
 	
 	.caidanTk{
-		height: calc(100vh - 120rpx);
+		height: calc(100vh );
 		width: 100vw;
 		background: rgba(0,0,0,0.6);
 		position:fixed;
 		left: 0;
 		top: 0;
+	
 	}
 	.tkCont{
 		height: 60vh;
-		margin-top: calc(40vh - 120rpx);
+		margin-top: calc(40vh );
+		padding-bottom: constant(safe-area-inset-bottom);
+		padding-bottom: env(safe-area-inset-bottom);
+		box-sizing: content-box; 
 	}
 	.caidanTkTop{
 		width: 750rpx;
@@ -625,6 +697,9 @@ export default {
 		height: 120rpx;
 		background: #FFFFFF;
 		box-shadow: 0px -2px 20px 0px rgba(153, 153, 153, 0.2);
+		padding-bottom: constant(safe-area-inset-bottom);
+			padding-bottom: env(safe-area-inset-bottom);
+			box-sizing: content-box;
 	}
 	.main{
 		display: flex;
@@ -710,6 +785,7 @@ export default {
 		font-weight: 400;
 		color: #999999;
 		padding-top: 5rpx;
+		line-height: 30rpx;
 	}
 	.contZk{
 		border-bottom: 1px solid #EEEEEE;