|
@@ -1,19 +1,19 @@
|
|
|
//请求同意调用
|
|
|
-function $DoPost(url,param={},callback,async=true){
|
|
|
+function $DoPost(url, param = {}, callback, async = true) {
|
|
|
$.ajax({
|
|
|
- url: url+"?t="+new Date().getTime(),
|
|
|
+ url: url + "?t=" + new Date().getTime(),
|
|
|
type: "POST",
|
|
|
data: param,
|
|
|
async: async,
|
|
|
dataType: "json",
|
|
|
- success: function(r){
|
|
|
+ success: function (r) {
|
|
|
callback(r)
|
|
|
- if(r.error||r.errMsg){
|
|
|
- var errTip = r.error||r.errMsg;
|
|
|
- weui.toast(errTip,{
|
|
|
- duration: 2000,
|
|
|
- className: 'custom-toast',
|
|
|
- });
|
|
|
+ if (r.error || r.errMsg) {
|
|
|
+ var errTip = r.error || r.errMsg;
|
|
|
+ weui.toast(errTip, {
|
|
|
+ duration: 2000,
|
|
|
+ className: 'custom-toast',
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
})
|
|
@@ -21,61 +21,90 @@ function $DoPost(url,param={},callback,async=true){
|
|
|
|
|
|
//获取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;
|
|
|
+ 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
|
|
|
+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)
|
|
|
}
|
|
|
- provinceArr.push(i)
|
|
|
- }
|
|
|
- }
|
|
|
- return SortArr(provinceArr)
|
|
|
+ }
|
|
|
+ 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
|
|
|
+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)
|
|
|
}
|
|
|
- provinceArr.push(i)
|
|
|
- }
|
|
|
- }
|
|
|
- return [SortArr(provinceArr),SortArr(cityArr)]
|
|
|
+ }
|
|
|
+ return [SortArr(provinceArr), SortArr(cityArr)]
|
|
|
}
|
|
|
|
|
|
//对数组进行排序(拼音)
|
|
|
-function SortArr(arr){
|
|
|
+function SortArr(arr) {
|
|
|
arr = arr.sort(function compareFunction(item1, item2) {
|
|
|
- return item1.localeCompare(item2);
|
|
|
+ return item1.localeCompare(item2);
|
|
|
});
|
|
|
return arr
|
|
|
}
|
|
|
|
|
|
+//购买设置
|
|
|
+function getBuySet(area, industry) {
|
|
|
+ if (industry[0] === "全部行业") industry = [];
|
|
|
+ if (area["全国"]) area = {};
|
|
|
+ //计算地区数量
|
|
|
+ var buyset = {
|
|
|
+ "areacount": -1, //省份数量
|
|
|
+ "buyerclasscount": -1,
|
|
|
+ "citys": { //购买省份中城市数量
|
|
|
+ }
|
|
|
+ };
|
|
|
+ //行业
|
|
|
+ if (industry.length != 0) {
|
|
|
+ buyset.buyerclasscount = industry.length
|
|
|
+ }
|
|
|
+ //地区
|
|
|
+ if (!$.isEmptyObject(area)) {
|
|
|
+ buyset.areacount = 0;
|
|
|
+ for (var i in area) {
|
|
|
+ let citys = area[i];
|
|
|
+ if (citys.length === 0) {
|
|
|
+ buyset.areacount++
|
|
|
+ } else {
|
|
|
+ buyset.citys[i] = citys.length
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return buyset
|
|
|
+}
|
|
|
|
|
|
/* vip订阅价格
|
|
|
area:地区 {}
|
|
@@ -84,116 +113,147 @@ function SortArr(arr){
|
|
|
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)
|
|
|
+function getsubVipOrderPrice(area, industry, t, price) {
|
|
|
+ return getsubVipOrderPriceBybuyset(getBuySet(area, industry), t, price)
|
|
|
+}
|
|
|
+
|
|
|
+var priceData;
|
|
|
+
|
|
|
+//根据购买设置 获取支付金额
|
|
|
+function getsubVipOrderPriceBybuyset(buyset, 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
|
|
|
- }
|
|
|
+ var vipbuyset = JSON.parse(JSON.stringify(buyset));
|
|
|
+
|
|
|
+ if (!$.isEmptyObject(vipbuyset.citys)) {
|
|
|
+ for (var i in vipbuyset.citys) {
|
|
|
+ if(vipbuyset.citys[i]>price.cityMaxCount){
|
|
|
+ vipbuyset.areacount++
|
|
|
+ delete vipbuyset.citys[i]
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//当省份数量大于price.ProvinceMaxCount 按照全国计算
|
|
|
- if (pCount > price.provinceMaxCount) {
|
|
|
- pCount = -1
|
|
|
+ if (vipbuyset.areacount > price.provinceMaxCount) {
|
|
|
+ vipbuyset.areacount = -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 //全国多行业套餐
|
|
|
+ //当行业数量大于price.buyerClassMaxCount按照全行业
|
|
|
+ if (vipbuyset.buyerclasscount > price.buyerClassMaxCount) {
|
|
|
+ vipbuyset.buyerclasscount = -1
|
|
|
}
|
|
|
-
|
|
|
- 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倍
|
|
|
+ if (t[0] > price.monthMaxCount && t[1] === 2) t[0] = 10;//月份十个月以上价格一样
|
|
|
+
|
|
|
+ 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 = vipbuyset.areacount * getSetMealPrice(1, vipbuyset.buyerclasscount, t[1], price) * t[0];//计算省份价格
|
|
|
+ var final_price = 0;//计算省份价格
|
|
|
+
|
|
|
+ for (var i in vipbuyset.citys) {
|
|
|
+ var thisPrice = 0;
|
|
|
+ if (vipbuyset.citys[i] === 1) {//单城市
|
|
|
+ thisPrice = getSetMealPrice(2, vipbuyset.buyerclasscount, t[1], price) * t[0];
|
|
|
+ } else {//多城市
|
|
|
+ if (vipbuyset.buyerclasscount === 0 || vipbuyset.buyerclasscount === 1) {//多城市 单行业
|
|
|
+ if (vipbuyset.citys[i] > price.cityMaxCount) {
|
|
|
+ vipbuyset.areacount++;
|
|
|
+ } else {
|
|
|
+ thisPrice = vipbuyset.citys[i] * getSetMealPrice(2, vipbuyset.buyerclasscount, t[1], price) * t[0];
|
|
|
+ }
|
|
|
+ } else {//多城市 多行业
|
|
|
+ //var industry_Price = price.buyerClassPrice * vipbuyset.buyerclasscount;
|
|
|
+ //var city_Price = price.cityPrice * vipbuyset.citys[i];
|
|
|
+ //thisPrice = (industry_Price + city_Price) * t[0];
|
|
|
+ if (vipbuyset.citys[i] > price.cityMaxCount) {
|
|
|
+ vipbuyset.areacount++;
|
|
|
+ } else {
|
|
|
+ thisPrice = getSetMealPrice(2, vipbuyset.buyerclasscount, t[1], price) * vipbuyset.citys[i] * t[0];
|
|
|
+ // if (t[1] === 1) thisPrice *= 10 //年的价格是月价格的10倍
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- final_price += thisPrice;
|
|
|
- }
|
|
|
- return final_price/100
|
|
|
+ final_price += thisPrice;
|
|
|
+ }
|
|
|
+ final_price += vipbuyset.areacount * getSetMealPrice(1, vipbuyset.buyerclasscount, t[1], price) * t[0]
|
|
|
+ return final_price / 100
|
|
|
}
|
|
|
+
|
|
|
//获取套餐价格
|
|
|
-//c(city) 全国:0 省:1 市:2
|
|
|
-//iCount(industry) 全行业:0 行业:1 其他:多个行业
|
|
|
+//c(city) 全国:0 省:1 市:2
|
|
|
+//iCount(industry) 全行业:-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个行业
|
|
|
- }
|
|
|
+function getSetMealPrice(c, iCount, u, price) {
|
|
|
+ var t = u === 2; //是否是月单位
|
|
|
+ switch (c) {
|
|
|
+ case 0:
|
|
|
+ if (iCount === -1) {
|
|
|
+ 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 === -1) {
|
|
|
+ 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 === -1) {
|
|
|
+ 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个行业
|
|
|
+ }
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+//查看用户是否有未执行的订单
|
|
|
+function checkOrder(wz) {
|
|
|
+ var flag = false;
|
|
|
+ $.ajax({
|
|
|
+ type: 'post',
|
|
|
+ url: '/subscribepay/afterPay/checkOrder?t=' + new Date().getTime(),
|
|
|
+ data: {},
|
|
|
+ async: false,
|
|
|
+ dataType: 'json',
|
|
|
+ success: function (r) {
|
|
|
+ flag = r.flag;
|
|
|
+ if (r.flag) {
|
|
|
+ if (wz != 1) {
|
|
|
+ weui.toast('订单尚未到期', {
|
|
|
+ duration: 3000,
|
|
|
+ className: 'custom-toast',
|
|
|
+ callback: function () {
|
|
|
+ console.log('close')
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return flag
|
|
|
}
|