xuzhiheng 5 年之前
父节点
当前提交
3e0ba788e4
共有 2 个文件被更改,包括 47 次插入36 次删除
  1. 23 22
      src/web/staticres/vipsubscribe/js/common.js
  2. 24 14
      src/web/templates/weixin/vipsubscribe/vip_upgrade.html

+ 23 - 22
src/web/staticres/vipsubscribe/js/common.js

@@ -139,44 +139,45 @@ function getsubVipOrderPriceBybuyset(buyset, t, price) {
         }
     }
     console.log("buyset", JSON.stringify(buyset));
+	var vipbuyset = JSON.parse(JSON.stringify(buyset));
     //当省份数量大于price.ProvinceMaxCount 按照全国计算
-    if (buyset.areacount > price.provinceMaxCount) {
-        buyset.areacount = -1
+    if (vipbuyset.areacount > price.provinceMaxCount) {
+        vipbuyset.areacount = -1
     }
     //当行业数量大于price.buyerClassMaxCount按照全行业
-    if (buyset.buyerclasscount > price.buyerClassMaxCount) {
-        buyset.buyerclasscount = -1
+    if (vipbuyset.buyerclasscount > price.buyerClassMaxCount) {
+        vipbuyset.buyerclasscount = -1
     }
     if (t[0] > price.monthMaxCount && t[1] === 2) t[0] = 10;//月份十个月以上价格一样
 
-    if (buyset.areacount === -1) {//计算全国套餐价格
-        if (buyset.buyerclasscount === 1) return getSetMealPrice(0, 1, t[1], price) * t[0] / 100; //全国1行业套餐
-        if (buyset.buyerclasscount === 0) return getSetMealPrice(0, 0, t[1], price) * t[0] / 100; //全国全行业套餐
-        return getSetMealPrice(0, buyset.buyerclasscount, t[1], price) * t[0] / 100 //全国多行业套餐
+    if (vipbuyset.areacount === -1) {//计算全国套餐价格
+        if (vipbuyset.buyerclasscount === 1) return getSetMealPrice(0, 1, t[1], price) * t[0] / 100; //全国1行业套餐
+        if (vipbuyset.buyerclasscount === 0) return getSetMealPrice(0, 0, t[1], price) * t[0] / 100; //全国全行业套餐
+        return getSetMealPrice(0, vipbuyset.buyerclasscount, t[1], price) * t[0] / 100 //全国多行业套餐
     }
 
-    //var final_price = buyset.areacount * getSetMealPrice(1, buyset.buyerclasscount, t[1], price) * t[0];//计算省份价格
+    //var final_price = vipbuyset.areacount * getSetMealPrice(1, vipbuyset.buyerclasscount, t[1], price) * t[0];//计算省份价格
     var final_price = 0;//计算省份价格
 
-    for (var i in buyset.citys) {
+    for (var i in vipbuyset.citys) {
         var thisPrice = 0;
-        if (buyset.citys[i] === 1) {//单城市
-            thisPrice = getSetMealPrice(2, buyset.buyerclasscount, t[1], price) * t[0];
+        if (vipbuyset.citys[i] === 1) {//单城市
+            thisPrice = getSetMealPrice(2, vipbuyset.buyerclasscount, t[1], price) * t[0];
         } else {//多城市
-            if (buyset.buyerclasscount === 0 || buyset.buyerclasscount === 1) {//多城市 单行业
-                if (buyset.citys[i] > price.cityMaxCount) {
-                    buyset.areacount++;
+            if (vipbuyset.buyerclasscount === 0 || vipbuyset.buyerclasscount === 1) {//多城市 单行业
+                if (vipbuyset.citys[i] > price.cityMaxCount) {
+                    vipbuyset.areacount++;
                 } else {
-					thisPrice = buyset.citys[i] * getSetMealPrice(2, buyset.buyerclasscount, t[1], price) * t[0];
+					thisPrice = vipbuyset.citys[i] * getSetMealPrice(2, vipbuyset.buyerclasscount, t[1], price) * t[0];
 				}
 			} else {//多城市 多行业
-                //var industry_Price = price.buyerClassPrice * buyset.buyerclasscount;
-                //var city_Price = price.cityPrice * buyset.citys[i];
+                //var industry_Price = price.buyerClassPrice * vipbuyset.buyerclasscount;
+                //var city_Price = price.cityPrice * vipbuyset.citys[i];
                 //thisPrice = (industry_Price + city_Price) * t[0];
-                if (buyset.citys[i] > price.cityMaxCount) {
-                    buyset.areacount++;
+                if (vipbuyset.citys[i] > price.cityMaxCount) {
+                    vipbuyset.areacount++;
                 } else {
-                    thisPrice = getSetMealPrice(2, buyset.buyerclasscount, t[1], price) * buyset.citys[i] * t[0];
+                    thisPrice = getSetMealPrice(2, vipbuyset.buyerclasscount, t[1], price) * vipbuyset.citys[i] * t[0];
                     // if (t[1] === 1) thisPrice *= 10 //年的价格是月价格的10倍
                 }
 
@@ -184,7 +185,7 @@ function getsubVipOrderPriceBybuyset(buyset, t, price) {
         }
         final_price += thisPrice;
     }
-    final_price += buyset.areacount * getSetMealPrice(1, buyset.buyerclasscount, t[1], price) * t[0]
+    final_price += vipbuyset.areacount * getSetMealPrice(1, vipbuyset.buyerclasscount, t[1], price) * t[0]
 	return final_price / 100
 }
 

+ 24 - 14
src/web/templates/weixin/vipsubscribe/vip_upgrade.html

@@ -721,6 +721,7 @@
 	    var starts = "";
 	    var endTime = "";
 	    var ends = "";
+		var oldBuyset = "";
 	 	$DoPost("/subscribepay/renewUpgrade/getBuyMsg", {}, function (data) {
             if (data) {
                 area = data.area;
@@ -733,8 +734,10 @@
 			    starts = data.starttime;
 			    endTime = data.end;
 			    ends = data.endtime;
+				oldBuyset = data.buyset;
 			}
         },false);
+		console.log("666666666333",oldBuyset)
         //
         var completeMonth = 0;
         var completeYear = 0;
@@ -914,7 +917,6 @@
 			// 	}
 			// }
 			//
-			console.log("areasArr",areasArr)
 			// if(sessionStorage.vipSubSelectIndustryAdd!==""&&sessionStorage.vipSubSelectIndustryAdd!==undefined){
 			// 	var vipIndustry = JSON.parse(sessionStorage.vipSubSelectIndustryAdd);
 			// 	for(let i in vipIndustry){
@@ -1028,8 +1030,10 @@
 			console.log("month",nowUpgrade)
 			//
 			if (nowUpgradeYear >= 1) {
-				let monthprice = getsubVipOrderPrice(buyArea, buyIndustry, [nowUpgrade, 2])
-				let yearprice = getsubVipOrderPrice(buyArea, buyIndustry, [nowUpgradeYear, 1])
+				// let monthprice = getsubVipOrderPrice(buyArea, buyIndustry, [nowUpgrade, 2])
+				// let yearprice = getsubVipOrderPrice(buyArea, buyIndustry, [nowUpgradeYear, 1])
+				let monthprice = getsubVipOrderPriceBybuyset(oldBuyset, [nowUpgrade, 2])
+				let yearprice = getsubVipOrderPriceBybuyset(oldBuyset, [nowUpgradeYear,1]);
 				oldPrice = yearprice + monthprice
 				if (monthprice == 0) {
 					oldMonthPrice = ((yearprice / nowUpgradeYear) / 10).toFixed(1);
@@ -1039,8 +1043,7 @@
 					oldYearPrice = ((monthprice / nowUpgrade) * 10).toFixed(1);
 				}
 			} else {
-				console.log(buyArea)
-				oldPrice = getsubVipOrderPrice(buyArea, buyIndustry, [nowUpgrade, 2])
+				oldPrice = getsubVipOrderPriceBybuyset(oldBuyset, [nowUpgrade, 2])
 				oldMonthPrice = (oldPrice / nowUpgrade)
 				oldYearPrice = ((oldPrice / nowUpgrade) * 10).toFixed(1);
 			}
@@ -1071,7 +1074,7 @@
 				// price = addAreaPriceY + addAreaPriceM + oldAreaPriceY + oldAreaPriceM + addIndustryPriceY + addIndustryPriceM;
 				// ------- 升级价格交叉计算 ---------
 				// ------- 升级价格差价计算 ---------
-				let buyset = getBuySet(buyArea,buyIndustry)
+				// let buyset = getBuySet(buyArea,buyIndustry)
 				// let newPriceY = getsubVipOrderPrice(allBuyArea,allIndustry,[nowUpgradeYear,1]);
 				// let newPriceM = getsubVipOrderPrice(allBuyArea,allIndustry,[nowUpgrade,2]);
 				// let yearprice = getsubVipOrderPrice(allBuyArea,allIndustry,[nowUpgradeYear,1]);
@@ -1344,17 +1347,23 @@
 	//     	return areasObj
 	//     }
 	function areaObj(){
-		let buyset = getBuySet(buyArea,buyIndustry)
+		let newbuyset = {}
+		let oldset = JSON.parse(JSON.stringify(oldBuyset))
+		newbuyset.areacount = oldset.areacount;
+		newbuyset.buyerclasscount = oldset.buyerclasscount;
+		newbuyset.citys = oldset.citys;
+		// let buyset = oldBuyset
+		console.log("11111",newbuyset)
 		if(sessionStorage.vipSubSelectAreaAdd!==undefined&&sessionStorage.vipSubSelectAreaAdd!==""){
 			let addbuyset = JSON.parse(sessionStorage.vipSubSelectAreaAdd);
 			if(addbuyset.country !== -1){
 				if(addbuyset.province !== 0){
-					buyset.areacount = buyset.areacount + addbuyset.province;
+					newbuyset.areacount = newbuyset.areacount + addbuyset.province;
 				}
 				if(!checkObj(addbuyset.city)){
 					let cityArr = addbuyset.city
 					for(var i in cityArr){
-						let citysArr = buyset.citys
+						let citysArr = newbuyset.citys
 						if(citysArr[i] !== undefined){
 							citysArr[i] = citysArr[i] + cityArr[i]
 						}else{
@@ -1363,19 +1372,20 @@
 					}
 				}
 			}else{
-				buyset.areacount = -1;
-				buyset.citys = {};
+				newbuyset.areacount = -1;
+				newbuyset.citys = {};
 			}
 		}
 		if(sessionStorage.vipSubSelectIndustryAdd!==undefined){
 			var addindustrys = JSON.parse(sessionStorage.vipSubSelectIndustryAdd);
 			if(addindustrys.length === 1 && addindustrys[0] === "全部行业"){
-				buyset.buyerclasscount = -1;
+				newbuyset.buyerclasscount = -1;
 			}else{
-				buyset.buyerclasscount = buyset.buyerclasscount + addindustrys.length;
+				newbuyset.buyerclasscount = newbuyset.buyerclasscount + addindustrys.length;
 			}
 		}
-		return buyset
+		console.log("233333",newbuyset)
+		return newbuyset
 	}
 	    
     </script>