//请求同意调用 function $DoPost(url,param={},callback,async=true){ $.ajax({ url: url+"?t="+new Date().getTime(), type: "POST", data: param, async: async, dataType: "json", success: function(r){ callback(r) if(r.error||r.errMsg){ var errTip = r.error||r.errMsg; weui.toast(errTip,{ duration: 2000, className: 'custom-toast', }); } } }) } //获取url参数 function getParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配 var context = ""; if (r != null) context = r[2]; reg = null; r = null; return context == null || context == "" || context == "undefined" ? "" : context; } //省份 城市 分类 function getAreaClassArr_index(area){ let cityArr=[];//城市 let provinceArr=[];//省份 for(var i in area) { let citys=area[i] if(citys.length>0){ cityArr = cityArr.concat(citys); provinceArr.push(i+"("+cityArr.join("、")+")") }else{ if(i=="全国"){ continue } provinceArr.push(i) } } return SortArr(provinceArr) } //省份 城市 分类 function getAreaClassArr(area){ let cityArr=[];//城市 let provinceArr=[];//省份 for(var i in area) { let citys=area[i] if(citys.length>0){ cityArr = cityArr.concat(citys); }else{ if(i=="全国"){ continue } provinceArr.push(i) } } return [SortArr(provinceArr),SortArr(cityArr)] } //对数组进行排序(拼音) function SortArr(arr){ arr = arr.sort(function compareFunction(item1, item2) { return item1.localeCompare(item2); }); return arr } /* vip订阅价格 area:地区 {} industry:行业 [] time[count,unit] count:时间长度 unit 1:年 2:月 price 价格表 return 价格(单位:分) */ var priceData function getsubVipOrderPrice(area,industry,t,price){ if(!price){ if(priceData){ price=priceData }else{ $DoPost("/subscribepay/vipsubscribe/getPrice",{},function(r){ if(r){ price=r; priceData=price; }else{ weui.toast("加载价格异常",{ duration: 2000, className: 'custom-toast', }); } },false) } } if(industry[0] == "全部行业")industry= [] if(area["全国"]) area={} //当行业数量大于最大值price.BuyerClassMaxCount 按照全行业计算 var industryNum = industry.length if (industryNum > price.buyerClassMaxCount) { industryNum = 0 } //计算地区数量 var pCount = -1 //省份数量 var citysCountMap = {} //购买省份中城市数量 if(!$.isEmptyObject(area)){ pCount=0 for(var i in area) { let citys=area[i] if(citys.length==0){ pCount++ }else{ if(citys.length > price.cityMaxCount){ pCount++ }else{ citysCountMap[i]= citys.length } } } } //当省份数量大于price.ProvinceMaxCount 按照全国计算 if (pCount > price.provinceMaxCount) { pCount = -1 } if(t[0]>price.monthMaxCount&&t[1]==2) t[0]=10 //月份十个月以上价格一样 if(pCount == -1){//计算全国套餐价格 if(industryNum==1) return getSetMealPrice(0,1,t[1],price)*t[0]/100 //全国1行业套餐 if(industryNum==0) return getSetMealPrice(0,0,t[1],price)*t[0]/100 //全国全行业套餐 return getSetMealPrice(0,industryNum,t[1],price) * t[0] / 100 //全国多行业套餐 } var final_price = pCount*getSetMealPrice(1,industryNum,t[1],price)*t[0];//计算省份价格 for(var i in citysCountMap) { var thisPrice = 0; var citys = area[i] if(citysCountMap[i]==1){//单城市 thisPrice = getSetMealPrice(2,industryNum,t[1],price)*t[0]; }else{//多城市 if(industryNum==0||industryNum==1){//多城市 单行业 thisPrice = citysCountMap[i] * getSetMealPrice(2,industryNum,t[1],price) * t[0]; }else{//多城市 多行业 var industry_Price= price.buyerClassPrice * industryNum; var city_Price = price.cityPrice *citysCountMap[i]; thisPrice = (industry_Price + city_Price) * t[0]; if(t[1]==1) thisPrice *= 10 //年的价格是月价格的10倍 } } final_price += thisPrice; } return final_price/100 } //获取套餐价格 //c(city) 全国:0 省:1 市:2 //iCount(industry) 全行业:0 行业:1 其他:多个行业 //u(unit) 年:1 月:2 function getSetMealPrice(c,iCount,u,price){ var t = u==2 //是否是月单位 switch(c){ case 0: if(iCount==0){ if(t)return price.month.allProvince_allBuyerClass //1月全国全行业 return price.year.allProvince_allBuyerClass //1年全国全行业 }else{ if(t)return price.month.allProvince_oneBuyerClass * iCount //1月全国icount个行业 return price.year.allProvince_oneBuyerClass * iCount //1年全国icount个行业 } case 1: if(iCount==0){ if(t)return price.month.oneProvince_allBuyerClass //1月1省全行业 return price.year.oneProvince_allBuyerClass //1年1省全行业 }else{ if(t)return price.month.oneProvince_oneBuyerClass * iCount //1月1省icount个行业 return price.year.oneProvince_oneBuyerClass * iCount //1年1省icount个行业 } default: if(iCount==0){ if(t)return price.month.oneCity_allBuyerClass //1月1市全行业 return price.year.oneCity_allBuyerClass //1年1市全行业 }else{ if(t)return price.month.oneCity_oneBuyerClass * iCount //1月1市icount个行业 return price.year.oneCity_oneBuyerClass * iCount //1年1市icount个行业 } } }