common.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. $(function() {
  2. // 解决ios系统click 事件300毫秒的延迟
  3. FastClick.attach(document.body);
  4. });
  5. //请求同意调用
  6. function $DoPost(url,param={},callback,async=true){
  7. $.ajax({
  8. url: url+"?t="+new Date().getTime(),
  9. type: "POST",
  10. data: param,
  11. async: async,
  12. dataType: "json",
  13. success: function(r){
  14. if(r.error||r.errMsg){
  15. var errTip = r.error||r.errMsg;
  16. weui.toast(errTip,{
  17. duration: 2000,
  18. className: 'custom-toast',
  19. });
  20. }else{
  21. callback(r)
  22. }
  23. }
  24. })
  25. }
  26. //获取url参数
  27. function getParam(name) {
  28. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  29. var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
  30. var context = "";
  31. if (r != null)
  32. context = r[2];
  33. reg = null;
  34. r = null;
  35. return context == null || context == "" || context == "undefined" ? "" : context;
  36. }
  37. //省份 城市 分类
  38. function getAreaClassArr(area){
  39. let cityArr=[];//城市
  40. let provinceArr=[];//省份
  41. for(var i in area) {
  42. let citys=area[i]
  43. if(citys.length>0){
  44. cityArr = cityArr.concat(citys);
  45. }else{
  46. if(i=="全国"){
  47. continue
  48. }
  49. provinceArr.push(i)
  50. }
  51. }
  52. return [provinceArr,cityArr]
  53. }
  54. /* vip订阅
  55. area:地区 {}
  56. industry:行业 []
  57. time[count,unit] count:时间长度 unit 1:年 2:月
  58. return 价格(单位:分)
  59. */
  60. function getsubVipOrderPrice(area,industry,t){
  61. if(industry[0] == "全部行业"){
  62. industry= []
  63. }
  64. if(area["全国"]){
  65. if(industry.length==1) return getSetMealPrice(0,1,t[1])*t[0]/100 //全国1行业套餐
  66. if(industry.length==0) return getSetMealPrice(0,0,t[1])*t[0]/100 //全国全行业套餐
  67. return getSetMealPrice(0,0,t[1])*t[0]/100 //全国多行业套餐
  68. }
  69. var final_price = 0//最终价格
  70. for(var i in area) {
  71. let thisPrice = 0;
  72. let citys = area[i]
  73. if(citys.length>0){//市
  74. if(citys.length==1){//单城市
  75. thisPrice = getSetMealPrice(2,industry.length,t[1])*t[0];
  76. }else{//多城市
  77. if(industry.length==0||industry.length==1){//多城市 单行业
  78. thisPrice = citys.length*getSetMealPrice(2,industry.length,t[1])*t[0];
  79. }else{//多行业 多行业
  80. if(t[1]==2){//月
  81. var industry_Price= 580*industry.length>1800?1800:580*industry.length;
  82. var city_Price = citys.length*580>1180?1180:citys.length*580;
  83. if(t[0]>10) t[0]=10 //月份十个月以上价格一样
  84. thisPrice = (industry_Price + city_Price)*t[0];
  85. }else{//年
  86. var industry_Price= 5800*industry.length>18000?18000:5800*industry.length;
  87. var city_Price = citys.length*5800>11800?11800:citys.length*5800;
  88. thisPrice = (industry_Price + city_Price)*5800*t[0]/100;
  89. }
  90. }
  91. }
  92. }else{//省
  93. thisPrice = getSetMealPrice(1,industry.length,t[1])*t[0];
  94. }
  95. //console.log("thisPrice",i,thisPrice)
  96. final_price += thisPrice;
  97. }
  98. return final_price/100
  99. }
  100. //获取套餐价格
  101. //c(city) 全国:0 省:1 市:2
  102. //i(industry) 全行业:0 行业:1 其他:多个行业
  103. //u(unit) 年:1 月:2
  104. function getSetMealPrice(c,i,u){
  105. let t = u==2 //是否是月单位
  106. let icount=1 //行业个数
  107. if(i>1){
  108. icount=i;
  109. }
  110. switch(c){
  111. case 0:
  112. if(i==0){
  113. if(t)return 38800 //1月全国全行业
  114. return 388000 //1年全国全行业
  115. }else{
  116. if(t)return 11800*icount //1月全国icount个行业
  117. return 118000*icount //1年全国icount个行业
  118. }
  119. case 1:
  120. if(i==0){
  121. if(t)return 3800 //1月1省全行业
  122. return 38000 //1年1省全行业
  123. }else{
  124. if(t)return 1180*icount //1月1省icount个行业
  125. return 11800*icount //1年1省icount个行业
  126. }
  127. default:
  128. if(i==0){
  129. if(t)return 1800 //1月1市全行业
  130. return 18000 //1年1市全行业
  131. }else{
  132. if(t)return 580*icount //1月1市icount个行业
  133. return 5800*icount //1年1市icount个行业
  134. }
  135. }
  136. }