Browse Source

代码提交

twt 3 years ago
parent
commit
9c5f4ed9a8
4 changed files with 349 additions and 29 deletions
  1. 1 1
      main.js
  2. 3 2
      pages/homePage/homePage.vue
  3. 341 22
      pages/module/maintain.vue
  4. 4 4
      pages/module/replaceGoods.vue

+ 1 - 1
main.js

@@ -16,7 +16,7 @@ import share from '@/static/js/share.js'
 Vue.mixin(share)
 //https://blog.csdn.net/qq_35432904/article/details/106330079 分享
 //佳链天下养车小程序账号AppID(小程序ID)wx9ca21d7c8495757e   AppSecret(小程序密钥)   73a76c283f4c4a35a13ea8033527059b
-
+//车蓝图 wx693850514180f795
 // #ifndef VUE3
 import Vue from 'vue'
 Vue.config.productionTip = false

+ 3 - 2
pages/homePage/homePage.vue

@@ -83,7 +83,7 @@
 		</view>
 
 		<!-- 优惠券中心 -->
-		<image src="../../static/img/banner_hongb@2x.png" mode="aspectFit" class="quanImg" @click="goquan"></image>
+		<image :src="bannerImg" mode="aspectFit" class="quanImg" @click="goquan"></image>
 
 		<!-- 车主评价 -->
 		<view class="pingjia" v-if="itemData.length != 0">
@@ -180,7 +180,7 @@
 					lat: '',
 				},
 
-
+                bannerImg:'',
 				mileage: '',
 
 				brand: '',
@@ -321,6 +321,7 @@
 					this.cityRole = res.data.cityRole
 					this.imgData = res.data.banners
 					this.memberCar = res.data.memberCar
+					this.bannerImg=res.data.bannerImg
 					if (res.data.memberCar) {
 						this.mileage = res.data.memberCar.milage
 					} else {

+ 341 - 22
pages/module/maintain.vue

@@ -59,7 +59,7 @@
 											<view class="goodsContTop">
 												<view class="goodsItemName">{{v.showName}}</view>
 												<view class="replaceBox" @click.stop="replace(vf,index,findex,i)">
-													<view class="replace"  v-if="vf.goodsList.length>1">更换</view>
+													<view class="replace"  v-if="vf.goodsList.length>1&&!v.gh">更换</view>
 												</view>
 												
 											</view>
@@ -217,12 +217,12 @@ export default {
 			//console.log(this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll.goodsList[this.replaceIndex2])
 			
 			this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList=this.unique(this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList)
-			
+			this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList[0].del=false;
 			//this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2]=replaceData
 			//this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsName='666'
 			//console.log(this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2])
 			this.$forceUpdate()
-			this.calculation()
+			this.newData()
 		}
 		
 	},
@@ -462,8 +462,16 @@ export default {
 					item.listPackage.forEach((list,i)=>{
 						if(list.listGoodsAll.length>0){
 									list.listGoodsAll.forEach((goods,index)=>{
-										//console.log(goods.goodsGroupDetail)
-										
+										var brandName=goods.goodsList[0].brandName
+										var newtp=[];
+										goods.goodsGroupDetail.forEach(tgoods=>{
+											if(brandName==tgoods.brandName){
+												newtp.push(tgoods)
+											}
+										})
+										goods.goodsGroupDetail=newtp
+										/* console.log("同品组")
+										console.log(goods.goodsGroupDetail) */
 										
 										if(goods.goodsGroupDetail.length==0){
 											//同组品为空的情况
@@ -476,7 +484,8 @@ export default {
 													goods.goodsList.splice(300);
 													var addArrnt=JSON.parse(JSON.stringify(goods.goodsList))
 													//console.log(addArrnt[0])
-													addArrnt[0].qty=qtynum2
+													addArrnt[0].qty=qtynum2;
+													addArrnt[0].gh=true
 													var addDta={
 														goodsGroupDetail:[],
 														goodsList:addArrnt
@@ -506,26 +515,49 @@ export default {
 											
 											goods.goodsGroupDetail.forEach((tgoods,tindex)=>{
 											    var addArr=JSON.parse(JSON.stringify(goods.goodsList))
+												
 												if(tindex==0){
+													console.log(tgoods.brandName)
 													if(tgoods.capacity){
 														if(referenceDosageQty>tgoods.capacity){
-															//console.log("referenceDosageQty>tgoods.capacity")
-															var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
-															//console.log("parseIntNum--"+parseIntNum)
-															tgoods.qty=parseIntNum
-															addArr.unshift(tgoods)
-															var reduce= tgoods.capacity*parseIntNum
-															referenceDosageQty=referenceDosageQty - reduce
-															var addDta={
-																goodsGroupDetail:[],
-																goodsList:addArr,
-																del:true,
+															if(goods.goodsGroupDetail.length==1){
+																//console.log("referenceDosageQty>tgoods.capacity")
+																var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
+																//console.log("parseIntNum--"+parseIntNum)
+																tgoods.qty=parseIntNum+1
+																addArr.unshift(tgoods)
+																var reduce= tgoods.capacity*parseIntNum
+																referenceDosageQty=referenceDosageQty - reduce
+																var addDta={
+																	goodsGroupDetail:[],
+																	goodsList:addArr,
+																	del:true,
+																}
+																addDta.goodsList.forEach(add=>{
+																	add.del=true;
+																}) 
+																												
+																list.listGoodsAll.splice(index, 1,addDta)
+															}else{
+																//console.log("referenceDosageQty>tgoods.capacity")
+																var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
+																//console.log("parseIntNum--"+parseIntNum)
+																tgoods.qty=parseIntNum
+																addArr.unshift(tgoods)
+																var reduce= tgoods.capacity*parseIntNum
+																referenceDosageQty=referenceDosageQty - reduce
+																var addDta={
+																	goodsGroupDetail:[],
+																	goodsList:addArr,
+																	del:true,
+																}
+																addDta.goodsList.forEach(add=>{
+																	add.del=true;
+																}) 
+																												
+																list.listGoodsAll.splice(index, 1,addDta)
 															}
-															addDta.goodsList.forEach(add=>{
-																add.del=true;
-															}) 
-																											
-															list.listGoodsAll.splice(index, 1,addDta)
+															
 														}else{
 															console.log("推荐大于容量")
 															if(goods.goodsGroupDetail.length==1){
@@ -661,6 +693,293 @@ export default {
 				this.calculation();
 			})
 		},
+		
+		newData(){
+			
+			var replaceData=uni.getStorageSync("replaceData");
+			var location = uni.getStorageSync("locationCity");
+			var selectCity = uni.getStorageSync("selectCity");
+			var cityCode=''
+			if(selectCity){
+				cityCode=selectCity.code
+			}else{
+				cityCode=location.cityCode
+			}
+			var params={
+				mileage:this.maintainCarData.milage,
+				liyangId:this.maintainCarData.nLevelID,
+				cityCode:cityCode,
+				guidePrice:this.maintainCarData.guidePrice?this.maintainCarData.guidePrice:0,
+				goodsID:replaceData.goodsID,
+				itemID:replaceData.itemID,
+				packageID:replaceData.packageID,
+				packageGoodsGroupID:replaceData.packageGoodsGroupID,
+			}
+			uni.showLoading({ });
+			var arr=[]
+			this.$http('miniApp/tPackageMiniAppController/queryTGoodsGroupDetailForApp', params,'GET').then(res => {
+			  uni.hideLoading();
+	 			res.data.forEach(item=>{
+					if(item.brandName==replaceData.brandName){
+						arr.push(item)
+					}
+				})
+				arr.forEach((item,index)=>{
+					if(item.goodsID==replaceData.goodsID){
+						arr.splice(index, 1)
+					}
+				})
+				
+				arr.unshift(replaceData)
+				this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsGroupDetail=arr
+				this.chulidata()
+				 console.log(arr)
+			})
+		
+			
+			
+		},
+		chulidata(){
+			this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList.forEach((item,index)=>{
+				if(item.gh){
+					this.mealData[this.leftIndex].listPackage[this.replaceIndex1].listGoodsAll[this.replaceIndex2].goodsList.splice(index, 1)
+				}
+			}) 
+			this.mealData.forEach(item=>{
+				//console.log(item)
+				item.listPackage.forEach((list,i)=>{
+					if(list.listGoodsAll.length>0){
+								list.listGoodsAll.forEach((goods,index)=>{
+									var brandName=goods.goodsList[0].brandName
+									var newtp=[];
+									goods.goodsGroupDetail.forEach(tgoods=>{
+										if(brandName==tgoods.brandName){
+											newtp.push(tgoods)
+										}
+									})
+									goods.goodsGroupDetail=newtp
+									/* console.log("同品组")
+									console.log(goods.goodsGroupDetail) */
+									
+									if(goods.goodsGroupDetail.length==0){
+										//同组品为空的情况
+										if(goods.goodsList[0].capacity&&!goods.goodsList[0].del){
+											//console.log(Number(list.referenceDosageQty)/goods[0].capacity)
+											if(Number(list.referenceDosageQty)/goods.goodsList[0].capacity>1){
+												var qtynum1=Number(list.referenceDosageQty)-goods.goodsList[0].capacity
+												var qtynum2=Math.ceil(qtynum1/goods.goodsList[0].capacity)
+			                                    
+												goods.goodsList.splice(300);
+												var addArrnt=JSON.parse(JSON.stringify(goods.goodsList))
+												//console.log(addArrnt[0])
+												addArrnt[0].qty=qtynum2;
+												addArrnt[0].gh=true
+												var addDta={
+													goodsGroupDetail:[],
+													goodsList:addArrnt
+												}
+												
+												addDta.goodsList.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)
+												
+											}
+										} 
+									}else{
+										//同组品不为空的情况 
+										//console.log("同组品不为空的情况 ")
+										var remainder=0;
+										var addNum=index
+										console.log("list.referenceDosageQty - "+list.referenceDosageQty+list.name)
+									    var referenceDosageQty=Number(list.referenceDosageQty)
+										//var addArr= goods.goodsList
+										goods.goodsList.splice(300);
+										
+										if(list.referenceDosageQty&&!goods.goodsList[0].del){
+										
+										goods.goodsGroupDetail.forEach((tgoods,tindex)=>{
+										    var addArr=JSON.parse(JSON.stringify(goods.goodsList))
+											
+											if(tindex==0){
+												console.log(tgoods.brandName)
+												if(tgoods.capacity){
+													if(referenceDosageQty>tgoods.capacity){
+														if(goods.goodsGroupDetail.length==1){
+															//console.log("referenceDosageQty>tgoods.capacity")
+															var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
+															//console.log("parseIntNum--"+parseIntNum)
+															tgoods.qty=parseIntNum+1
+															addArr.unshift(tgoods)
+															var reduce= tgoods.capacity*parseIntNum
+															referenceDosageQty=referenceDosageQty - reduce
+															var addDta={
+																goodsGroupDetail:[],
+																goodsList:addArr,
+																del:true,
+															}
+															addDta.goodsList.forEach(add=>{
+																add.del=true;
+															}) 
+																											
+															list.listGoodsAll.splice(index, 1,addDta)
+														}else{
+															//console.log("referenceDosageQty>tgoods.capacity")
+															var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
+															//console.log("parseIntNum--"+parseIntNum)
+															tgoods.qty=parseIntNum
+															addArr.unshift(tgoods)
+															var reduce= tgoods.capacity*parseIntNum
+															referenceDosageQty=referenceDosageQty - reduce
+															var addDta={
+																goodsGroupDetail:[],
+																goodsList:addArr,
+																del:true,
+															}
+															addDta.goodsList.forEach(add=>{
+																add.del=true;
+															}) 
+																											
+															list.listGoodsAll.splice(index, 1,addDta)
+														}
+														
+													}else{
+														console.log("推荐大于容量")
+														if(goods.goodsGroupDetail.length==1){
+															console.log("同组品 一个")
+															addArr.unshift(tgoods)
+															referenceDosageQty=referenceDosageQty-tgoods.capacity
+															var addDta={
+																goodsGroupDetail:[],
+																goodsList:addArr,
+																del:true,
+															}
+															addDta.goodsList.forEach(add=>{
+																add.del=true;
+															}) 
+																											
+															list.listGoodsAll.splice(index, 1,addDta)
+														}else{
+															list.listGoodsAll.splice(index, 1)
+														}
+														
+													}
+												}else{
+													addArr.unshift(tgoods)
+													var addDta={
+														goodsGroupDetail:[],
+														goodsList:addArr,
+														del:true,
+													}
+													addDta.goodsList.forEach(add=>{
+														add.del=true;
+													}) 
+																									
+													list.listGoodsAll.splice(index, 1,addDta)
+												}
+												
+												
+												
+												
+											}else{
+												if(goods.goodsGroupDetail[0].capacity){
+												
+												if(referenceDosageQty>0){
+													console.log('referenceDosageQty'+referenceDosageQty)
+													console.log(tgoods)
+													/* remainder=Number(referenceDosageQty)%tgoods.capacity
+													
+													if(remainder>1){
+														addArr.unshift(tgoods)
+													}
+													referenceDosageQty=referenceDosageQty-tgoods.capacity */
+												    if(referenceDosageQty>tgoods.capacity){
+														var parseIntNum=parseInt(referenceDosageQty/tgoods.capacity)
+														
+														var reduce= tgoods.capacity*parseIntNum
+														if(goods.goodsGroupDetail.length==tindex+1){
+															var a=referenceDosageQty - reduce
+															if(a>0){
+																parseIntNum++
+															}
+														}
+														tgoods.qty=parseIntNum
+														addArr.unshift(tgoods)
+														referenceDosageQty=referenceDosageQty - reduce
+														var addDta={
+															goodsGroupDetail:[],
+															goodsList:addArr,
+															del:true
+														}
+														addDta.goodsList.forEach(add=>{
+															add.del=true;
+														}) 
+														//console.log(addArr)
+														 if(tindex==0){
+															// console.log(addDta.goodsList[0])
+															//list.listGoodsAll.splice(index, 1,addDta)
+															//console.log(list.listGoodsAll[index])
+														}else{
+															addNum++
+															console.log('addNum=='+addNum)
+															//console.log(addDta.goodsList[0])
+															list.listGoodsAll.splice(addNum, 0,addDta)
+														} 
+													}else{
+														if(goods.goodsGroupDetail.length==tindex+1){
+															addArr.unshift(tgoods)
+															referenceDosageQty=referenceDosageQty-tgoods.capacity
+														  var addDta={
+														  	goodsGroupDetail:[],
+														  	goodsList:addArr,
+														  	del:true
+														  }
+														  addDta.goodsList.forEach(add=>{
+														  	add.del=true;
+														  }) 
+														  //console.log(addArr)
+														   if(tindex==0){
+														  	// console.log(addDta.goodsList[0])
+														  	//list.listGoodsAll.splice(index, 1,addDta)
+														  	//console.log(list.listGoodsAll[index])
+														  }else{
+														  	addNum++
+														  	console.log('addNum=='+addNum)
+														  	//console.log(addDta.goodsList[0])
+														  	list.listGoodsAll.splice(addNum, 0,addDta)
+														  } 
+														}
+														
+													} 
+													
+													
+												}
+												
+												
+												}
+												
+												
+											}
+											
+										
+										} ) 
+										
+										}
+									}
+								
+								})
+							
+					}
+				})
+			}) 
+					
+			this.mealData.splice(1,0)
+			console.log(this.mealData)
+			this.calculation();
+		},
         handbook(){
 			uni.navigateTo({
 				url:'handbook?mileage'+this.maintainCarData.milage+'&liyangId='+this.maintainCarData.nLevelID

+ 4 - 4
pages/module/replaceGoods.vue

@@ -77,18 +77,18 @@ export default {
 			}); 
 		},
 		goGoods(item){
-			uni.setStorage({
+			/* uni.setStorage({
 				key: 'goodsreplaceData',
 				data: item,
 				success: function () {
-					/* uni.navigateBack({
+					 uni.navigateBack({
 						delta:1
-					}) */
+					}) 
 					uni.navigateTo({
 						url:'../module/goodsDetail?goodsId='+item.goodsID+'&type=1'+'&typeIndex=2&maintain=2'
 					})
 				}
-			}); 
+			}); */
 			
 		},
         login(){