vip_index_new.js 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326
  1. var subNode = new Vue({
  2. delimiters: ['${', '}'],
  3. el: '#vip-body',
  4. components: {
  5. subComponent: subComponent
  6. },
  7. data: function() {
  8. return {
  9. linkObj: {
  10. area: '/front/vipsubscribe/toChangeArea?header=save',
  11. industry: '/front/vipsubscribe/toChangeIndustry?header=save',
  12. keyword: '/front/vipsubscribe/toSetKeyWordPage',
  13. infotype: '/front/vipsubscribe/toSetInfoTypePage',
  14. resultview: '/front/vipsubscribe/toVIPViewPage',
  15. pushsetting: '/front/setting/push_detail?header=超级订阅推送设置&type=super_subscribe'
  16. },
  17. initData: {},
  18. userAreaNum: 1, // 用户修改地区剩余次数
  19. userType: false, // 用户是否为付费用户
  20. userAreaAllNum: 1, // 用户可修改地区总次数
  21. subscribeTime: '', // 用户订阅的时间
  22. vSwitch:'', // 用户版本权限
  23. }
  24. },
  25. created () {
  26. this.getUserSubscribe()
  27. this.getUserType()
  28. },
  29. methods: {
  30. superOrderTemplateMounted () {
  31. $('#pushResultPreview').attr('data-cl-event', 'c_wx_preview_buttonclick')
  32. },
  33. // 点击广告跳转超级订阅落地页
  34. toPaySupSub: function() {
  35. if (this.vSwitch !== 'v') {
  36. var href = '/front/vipsubscribe/introducePage'
  37. location.href = href
  38. }
  39. },
  40. // 得到用户是否购买省份包
  41. getUserSubscribe: function () {
  42. let _this = this
  43. $.ajax({
  44. url: '/publicapply/free/subscribe',
  45. type: 'POST',
  46. success: function (res) {
  47. _this.userAreaNum = res.data.areanum
  48. _this.userType = res.data.provincenum === 0 ? false : true
  49. _this.userAreaAllNum = res.data.areanum + res.data.provincenum
  50. // _this.$emit('UserSubscribe',res)
  51. _this.subscribeTime = new Date(res.data.ppstart * 1000).pattern('yyyy年MM月dd日') + "-" + new Date(res.data.ppend * 1000).pattern('yyyy年MM月dd日')
  52. _this.initdata = res.data
  53. }
  54. })
  55. },
  56. // 省份订阅包续费
  57. renewBtn: function () {
  58. location.href = '/areaPack/wx/page/buy?type=renew'
  59. },
  60. // 省份订阅包升级
  61. updateBtn: function () {
  62. location.href = '/areaPack/wx/page/buy?type=upgrade'
  63. },
  64. // 判断用户权限版本
  65. getUserType: function (data) {
  66. let _this = this
  67. $.ajax({
  68. type: 'POST',
  69. url: '/publicapply/subscribe/vipSwitch',
  70. data: {
  71. vt:data || ''
  72. },
  73. success: function(res) {
  74. if (res.data.vt !== 'v' ) {
  75. _this.vSwitch = 'f'
  76. } else {
  77. _this.vSwitch = 'v'
  78. }
  79. }
  80. })
  81. }
  82. }
  83. })
  84. function showGiveStatus (t) {
  85. if (t) {
  86. $(".banner-ad-box").hide()
  87. $("#giveTimeBox").attr('data-new-year', 'true')
  88. if ($(".try-seven").is(':visible')) {
  89. $(".banner-ad-box.trial").show()
  90. } else {
  91. $(".banner-ad-box.update").show()
  92. }
  93. // $(".banner-ad-box").css('display', 'flex')
  94. /*$("#giveTimeBox").addClass('hasDoubleEleven')
  95. $('.discount-button').show().on('click', function () {
  96. var details = $('.discount-details')
  97. if (details.is(':hidden')) {
  98. $('.discount-details').show()
  99. $(this).children('.icon-arrow').addClass('up')
  100. } else {
  101. $('.discount-details').hide()
  102. $(this).children('.icon-arrow').removeClass('up')
  103. }
  104. })
  105. $(".j-icon.icon-del-grey.cancel").on('click', function () {
  106. $('.weui-mask').trigger('click')
  107. })*/
  108. } else {
  109. /*$("#giveTimeBox").removeClass('hasDoubleEleven')
  110. $(".origin-price").hide()*/
  111. $(".banner-ad-box").hide()
  112. }
  113. }
  114. // @NewYearMarketing 2021/1/25
  115. getNewYearMarketing()
  116. function getNewYearMarketing () {
  117. $.ajax({
  118. url: '/getJson/NewYearMarketing?t=' + new Date().getTime(),
  119. async: false,
  120. success: function (r) {
  121. if (r && r.status) {
  122. showGiveStatus(true)
  123. }
  124. }
  125. })
  126. }
  127. // 拦截获取价格接口读取11.11活动信息
  128. /*$.ajaxSetup({
  129. complete:function(XMLHttpRequest,textStatus){
  130. if (this.url.indexOf('/subscribepay/vipsubscribe/getPrice') !== -1) {
  131. if (textStatus === 'success') {
  132. var data = XMLHttpRequest.responseJSON
  133. if (data && data.isActiving && data.isWritten === 0) {
  134. showGiveStatus(true)
  135. } else {
  136. showGiveStatus(false)
  137. }
  138. }
  139. }
  140. }
  141. });*/
  142. $(function () {
  143. /* vue 代码 start 提交订单 */
  144. // var coupon = new Vue({
  145. // el: '#coupon-vue',
  146. // data: function () {
  147. // return {
  148. // type: 'vip-update',
  149. // initPrice: 0, // 原价
  150. // realPrice: 0, // 实付价
  151. // checkboxStatus: false, // checkbox状态
  152. // submitStatus: true, // 提交按钮状态
  153. // links: [
  154. // {
  155. // text: '《剑鱼标讯线上购买与服务条款》',
  156. // url: '/front/staticPage/wx-serviceterms.html',
  157. // event: this.readEvent
  158. // }
  159. // ],
  160. // buttons: {
  161. // submit: this.submitOrder,
  162. // cancel: this.cancelEvent
  163. // },
  164. // }
  165. // },
  166. // mounted () {
  167. // this.init()
  168. // },
  169. // methods: {
  170. // // 更新价格相关
  171. // updatePrice: function (before) {
  172. // console.log( '原价:' + before)
  173. // this.initPrice = before;
  174. // // 调用子组件查询最优卡券
  175. // this.$refs.couponRef.getCoupon();
  176. // },
  177. // // 初始化及回显相关
  178. // init: function () {
  179. // if (sessionStorage.getItem("vip_index_read") === "true") {
  180. // this.checkboxStatus = true
  181. // this.$refs.couponRef.submitStatus = false
  182. // } else {
  183. // this.checkboxStatus = false
  184. // this.$refs.couponRef.submitStatus = true
  185. // }
  186. // },
  187. // // 勾选阅读协议
  188. // updateS: function(data) {
  189. // data.callback(this.checkSubmitStatus(data.check))
  190. // },
  191. // // 校验checkbox
  192. // checkSubmitStatus: function (checkStatus) {
  193. // if(checkStatus) {
  194. // $('.checkbox').addClass("checked");
  195. // } else {
  196. // $('.checkbox').removeClass("checked");
  197. // }
  198. // $('.vip-footer.upgrade .confirm').prop('disabled', !checkStatus);
  199. // sessionStorage.setItem("vip_index_read", checkStatus ? true : false);
  200. // return sessionStorage.getItem("vip_index_read") == 'true';
  201. // },
  202. // // 阅读协议点击事件
  203. // readEvent: function () {},
  204. // // 点击优惠券跳转存储当前页面数据
  205. // savePageData: function () {
  206. // sessionStorage.setItem('index_read_cache', '0');
  207. // },
  208. // cancelEvent: function() {
  209. // $('.weui-mask').trigger('click')
  210. // window.history.back();
  211. // },
  212. // // 订单提交事件
  213. // submitOrder: function () {
  214. // doSubmit()
  215. // }
  216. // }
  217. // })
  218. // 清除商品规格当前选择
  219. sessionStorage.removeItem("vip-cur-select-size")
  220. // 清除商品优惠券当前选择
  221. sessionStorage.removeItem("vip-cur-select-coupon")
  222. sessionStorage.removeItem("$select-coupon")
  223. /* vue 代码 end */
  224. //项目匹配开关
  225. var checkedflag = true;
  226. function setprojectmatch(index) {
  227. if (checkedflag) {
  228. checkedflag = false;
  229. $.post("/subscribepay/afterPay/setUserInfo", {pageType: "projectMatch", pmindex: index}, function (r) {
  230. if (r.flag) {
  231. checkedflag = true;
  232. reqData.projectmatch = index;
  233. sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData))
  234. }
  235. })
  236. }
  237. }
  238. function setMatchway(index) {
  239. $.post("/subscribepay/afterPay/setUserInfo", {pageType: "saveSeniorset", matchtype: index}, function (r) {
  240. if (r.flag) {
  241. reqData.matchway = index;
  242. sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData))
  243. }
  244. })
  245. }
  246. var checkedflag_other = true; //其他采购单位开关
  247. function setotherbuyerclass(index) {
  248. if (checkedflag_other) {
  249. checkedflag_other = false;
  250. $.post("/subscribepay/afterPay/setUserInfo", {pageType: "other_buyerclass", other: index}, function (r) {
  251. if (r.flag) {
  252. checkedflag_other = true;
  253. reqData.otherbuyerclass = index;
  254. sessionStorage.setItem('sub_vip_state', JSON.stringify(reqData))
  255. }
  256. })
  257. }
  258. }
  259. function flushSubtotal(list) {
  260. var returnHtml = "";
  261. for (var i = 0; i < list.length; i++) {
  262. var showTime = new Date(list[i].startTime * 1000).pattern('yyyy年MM月dd日') + "-" + new Date(list[i].endTime * 1000).pattern('yyyy年MM月dd日');
  263. var typeName = "";
  264. if (list[i].type === 1) {
  265. typeName = "续费"
  266. } else if (list[i].type === 0) {
  267. typeName = "升级"
  268. }
  269. var showArea = "";
  270. if (list[i].buyset.areacount === -1) {
  271. showArea = "全国"
  272. } else {
  273. if (list[i].buyset.areacount > 0) {
  274. showArea = list[i].buyset.areacount + "个省";
  275. }
  276. if (list[i].buyset.citys.length > 0) {
  277. var cityCount = 0;
  278. for (var j = 0; j < list[i].buyset.citys.length; j++) {
  279. cityCount += list[i].buyset.citys[j];
  280. }
  281. if (list[i].buyset.areacount > 0) showArea += "、";
  282. showArea += cityCount + "个市";
  283. if (list[i].buyset.citys.length > 1) {
  284. showArea += "(分布在" + list[i].buyset.citys.length + "个省内)"
  285. }
  286. }
  287. }
  288. var industryShow = "";
  289. if (list[i].buyset.buyerclasscount === -1) {
  290. industryShow = "全行业"
  291. } else {
  292. industryShow = list[i].buyset.buyerclasscount + "个行业";
  293. }
  294. returnHtml += "<li class=\"list-item\">"
  295. + "<div class=\"item-top\">"
  296. + "<div class=\"item-header\">"
  297. + "<span class=\"header-label\">有效日期:</span>"
  298. + "<span class=\"header-content ellipsis\">" + showTime + "</span>"
  299. + "</div>"
  300. + "<div class=\"item-body\">"
  301. + "<div class=\"b-item body-area\">"
  302. + "<div class=\"body-area-title text-title\">区域</div>"
  303. + "<div class=\"body-area-sub\">" + showArea + "</div>"
  304. + "</div>"
  305. + "<div class=\"b-item body-industry\">"
  306. + "<div class=\"body-industry-title text-title\">采购单位行业</div>"
  307. + "<div class=\"body-industry-sub\">" + industryShow + "</div>"
  308. + "</div>";
  309. if (typeName != "") {
  310. returnHtml += "<div class=\"vp-type\">"
  311. + "<div class=\"vp-type-text\">" + typeName + "</div>"
  312. + "</div>"
  313. }
  314. returnHtml += "</div>"
  315. + "</div>"
  316. + "<div class=\"item-footer\">"
  317. + "<span class=\"footer-label\">小计:</span>"
  318. + "<span class=\"footer-content text-title\">¥" + formatMoney(list[i].price) + "</span>"
  319. + "</div>"
  320. + "</li>"
  321. }
  322. $(".list-content").html(returnHtml);
  323. }
  324. function getDataWitXHR() {
  325. $DoPost('/subscribepay/vipsubscribe/getSubBuyMsg', {}, function (res) {
  326. if (!res.success) return;
  327. if(!res.data.industry) {
  328. res.data.industry = []
  329. }
  330. res.data.oldArea = res.data.area;
  331. res.data.oldIndustry = res.data.industry;
  332. var globalStateStr = JSON.stringify(res.data);
  333. sessionStorage.setItem('sub_vip_state', globalStateStr);
  334. sessionStorage.setItem('vip_index_read', true);
  335. globalState = JSON.parse(globalStateStr);
  336. reqData = JSON.parse(globalStateStr);
  337. sessionStorage.removeItem('industryNull')
  338. sessionStorage.removeItem('areaNull')
  339. subNode.initData = res.data
  340. init(res.data)
  341. })
  342. }
  343. // 设置已选择的区域和行业
  344. function setSelectedAreaAndInd(selected) {
  345. // buySet = {
  346. // areacount: 2,
  347. // buyerclasscount: 2,
  348. // newcitys: []
  349. // }
  350. // 设置已选择区域
  351. var citySum = arrSum(selected.citys);
  352. var text = {
  353. p: selected.areacount === 0 ? '' : selected.areacount + '个省',
  354. c: citySum === 0 ? '' : citySum + '个市',
  355. s: selected.citys.length === 1 ? '' : '(分布在' + selected.citys.length + '个省内)'
  356. };
  357. if (selected.areacount === -1) {
  358. $('.vip-body .area .selected-area').text('全国')
  359. } else {
  360. var dunhao = '';
  361. if (citySum !== 0 && selected.areacount !== 0) {
  362. dunhao = '、'
  363. }
  364. if (citySum === 0 || citySum === 1) {
  365. text.s = ''
  366. }
  367. $('.vip-body .area .selected-area').text(text.p + dunhao + text.c + text.s);
  368. }
  369. // 设置已选择行业
  370. if (selected.buyerclasscount === -1) {
  371. $('.vip-body .industry .selected-industry').text('全行业')
  372. } else {
  373. $('.vip-body .industry .selected-industry').text(selected.buyerclasscount + '个行业')
  374. }
  375. }
  376. // 设置已购买的区域和行业
  377. function setBuyAreaAndInd(buySet) {
  378. // 设置已购买区域
  379. var buySetCitySum = arrSum(buySet.newcitys)
  380. var text = {
  381. p: buySet.areacount === 0 ? '' : buySet.areacount + '个省',
  382. c: buySetCitySum === 0 ? '' : buySetCitySum + '个市',
  383. s: buySet.newcitys.length === 1 ? '' : '(分布在' + buySet.newcitys.length + '个省内)'
  384. }
  385. if (buySet.areacount === -1) {
  386. $('.vip-body .area .buy-set-area').text('全国')
  387. } else {
  388. var dunhao = '';
  389. // 如果省或者市都不为0,则添加顿号
  390. if (buySetCitySum !== 0 && buySet.areacount !== 0) {
  391. dunhao = '、'
  392. }
  393. // 如果市等于0或者1,text.s不需要显示
  394. if (buySetCitySum === 0 || buySetCitySum === 1) {
  395. text.s = ''
  396. }
  397. $('.vip-body .area .buy-set-area').text(text.p + dunhao + text.c + text.s);
  398. }
  399. // 设置已选择行业
  400. if (buySet.buyerclasscount === -1) {
  401. $('.vip-body .industry .buy-set-industry').text('全行业')
  402. } else {
  403. $('.vip-body .industry .buy-set-industry').text(buySet.buyerclasscount + '个行业')
  404. }
  405. }
  406. function showTimeOut(endTime, isTrail) {
  407. if (!isTrail) {
  408. $('.vip-header .expire-remind .remind-link').attr('href', '/front/vipsubscribe/vipsubscribe_renew').text('去续费')
  409. } else {
  410. $('.vip-header .expire-remind .remind-link').attr('href', '/front/vipsubscribe/vipsubscribe_new').text('去购买')
  411. }
  412. var timeSub = endTime * 1000 - new Date().getTime();
  413. if (timeSub > 0 && timeSub < 60 * 60 * 24 * 1000 * 3) {
  414. var hours = Math.floor(timeSub / (60 * 60 * 1000));
  415. var day = Math.floor(hours / 24);
  416. if (day > 0) {
  417. if (!isTrail) {
  418. $(".expire-remind .remind-text").text("超级订阅服务还有" + (day + 1) + "天到期,请及时续费!");
  419. } else {
  420. $(".expire-remind .remind-text").text("超级订阅服务还有" + (day + 1) + "天到期,请及时购买!");
  421. }
  422. } else {
  423. if (!isTrail) {
  424. $(".expire-remind .remind-text").text("超级订阅服务今天到期,请及时续费!");
  425. } else {
  426. $(".expire-remind .remind-text").text("超级订阅服务今天到期,请及时购买!");
  427. }
  428. }
  429. $(".expire-remind").show();
  430. }
  431. }
  432. function arrSum(arr) {
  433. var sum = 0
  434. arr.forEach(function (item, i) {
  435. sum += item
  436. })
  437. return sum
  438. }
  439. // picker的显示隐藏
  440. function pickerShow(selector, f) {
  441. if (f) {
  442. // 添加进场动画,并显示
  443. $(selector).find('.weui-mask').removeClass('weui-animate-fade-out').addClass('weui-animate-fade-in')
  444. $(selector).find('.weui-picker').removeClass('weui-animate-slide-down').addClass('weui-animate-slide-up')
  445. $(selector).show(300);
  446. } else {
  447. // 添加离场动画,并隐藏
  448. $(selector).find('.weui-mask').removeClass('weui-animate-fade-in').addClass('weui-animate-fade-out')
  449. $(selector).find('.weui-picker').removeClass('weui-animate-slide-up').addClass('weui-animate-slide-down')
  450. $(selector).hide(300);
  451. }
  452. }
  453. // 其他采购单位行业问号点击事件
  454. $('.other .icon-bangzhu').on('click', function () {
  455. var str = '每条信息的采购单位行业属性由机器自动识别,会存在少数无法识别的情况,此时将归类为“其它”。(注:当采购单位行业选择为全部时,关闭无效)'
  456. weui.alert(str, {
  457. title: '“其它”采购单位',
  458. className: 'jy-alert',
  459. buttons: [{
  460. label: '我知道了'
  461. }]
  462. });
  463. })
  464. // 计算标准点击事件
  465. $('.billing-list-btn').on('click', function () {
  466. pickerShow('.billing-list-container', true)
  467. })
  468. // 计算标准隐藏
  469. $('.billing-list-container .dialog_hd__close').on('click', function () {
  470. pickerShow('.billing-list-container', false)
  471. })
  472. $('.weui-mask').on('click', function () {
  473. pickerShow('.billing-list-container', false)
  474. $('.coupon-picker').hide()
  475. $('.discount-details').hide()
  476. $('.discount-button .icon-arrow').removeClass('up')
  477. })
  478. $('body').on('click', '.jy-dialog .weui-mask', function () {
  479. pickerShow('.jy-dialog', false)
  480. })
  481. $('.close-expire-remind').on("click", function () {
  482. $(".expire-remind").hide();
  483. });
  484. // 阅读并接受协议前的模拟checkbox点击事件
  485. if (sessionStorage.getItem("vip_index_read") === "true") {
  486. $('.checkbox').addClass("checked");
  487. $('.vip-footer.upgrade .confirm').prop('disabled', false);
  488. }
  489. $('.checkbox').on('click', function () {
  490. $(this).toggleClass('checked');
  491. var state = $(this).hasClass('checked');
  492. $('.vip-footer.upgrade .confirm').prop('disabled', !state);
  493. sessionStorage.setItem("vip_index_read", state ? true : false);
  494. });
  495. if (sessionStorage.liveActiveCode_new === "jianyu360") {
  496. $('.coupon-code-tx .keywords-text').text("支付成功赠送30天订阅周期");
  497. $('.coupon-picker .weui-input').val("jianyu360");
  498. $('.coupon-code-tx').off('click');
  499. }
  500. var $dialog;
  501. //保存取消提示 module 1 修改 2升级 3续费 4购买
  502. function cancelTip(module) {
  503. var content = "";
  504. var labName = "";
  505. var title = "";
  506. if (module === 1) {
  507. content = "所选订阅设置已做修改,返回后修改的设置将不做保存。";
  508. labName = "保存修改";
  509. title = "";
  510. } else if (module === 2) {
  511. content = "所选订阅设置已超出购买范围,升级后方才生效,返回后修改的设置将不做保存。";
  512. labName = "立即升级";
  513. title = "并升级";
  514. } else if (module === 3) {
  515. content = "所选订阅设置已超出购买范围,续费后方才生效,返回后修改的设置将不做保存。";
  516. labName = "立即续费";
  517. } else {
  518. content = "所选订阅设置已超出试用范围,购买后方才生效,返回后修改的设置将不做保存。";
  519. labName = "立即购买";
  520. title = "去购买";
  521. }
  522. $dialog = weui.dialog({
  523. title: '保存修改' + title,
  524. content: content,
  525. className: 'jy-dialog',
  526. buttons: [
  527. {
  528. label: '不保存',
  529. type: 'default',
  530. onClick: function () {
  531. clearSessionStorage();
  532. window.history.go(-1);
  533. window.location.reload();
  534. }
  535. },
  536. {
  537. label: labName,
  538. type: 'primary',
  539. onClick: function () {
  540. // doSubmit();
  541. // $('.vip-footer .button-r.confirm').trigger('click')
  542. // coupon.submitOrder()
  543. }
  544. }
  545. ]
  546. });
  547. }
  548. //展示订阅周期时间
  549. function flushShowTime(isTrial, changeValue, startValue, endValue) {
  550. if (isTrial) {
  551. sessionStorage.removeItem("vip_trial_buy");
  552. }
  553. var dEnd;
  554. if (isTrial && changeValue) {
  555. // 初始化订阅周期
  556. endValue = new Date().getTime() / 1000;
  557. startValue = new Date().getTime() / 1000;
  558. }
  559. if (changeValue) {
  560. var afterEndTime;
  561. if (isTrial) {
  562. $(".cycle .tip").text("购买订阅周期" + changeValue).show();
  563. } else {
  564. $(".cycle .tip").text("延长订阅周期" + changeValue).show();
  565. }
  566. if (changeValue.indexOf("月") > -1) {
  567. var monthNum = parseInt(changeValue.replace("个月", ""));
  568. afterEndTime = getVipEndDate(2, monthNum, endValue);
  569. changeTime = [monthNum, 2]
  570. } else {
  571. var yearNum = parseInt(changeValue.replace("年", ""));
  572. afterEndTime = getVipEndDate(1, yearNum, endValue);
  573. changeTime = [yearNum, 1]
  574. }
  575. dEnd = new Date(afterEndTime * 1000).pattern('yyyy年MM月dd日');
  576. } else {
  577. dEnd = new Date(endValue * 1000).pattern('yyyy年MM月dd日')
  578. }
  579. var dStart = new Date(startValue * 1000).pattern('yyyy年MM月dd日');
  580. var sDuration = dStart + ' - ' + dEnd;
  581. $('.cycle .buy-cycle').text(sDuration);
  582. }
  583. function initCycleSelector() {
  584. $('.vip-body .cycle').on('click', function () {
  585. pickerShow('#time_cycle', true)
  586. })
  587. // 打开dialog
  588. $('#time_cycle .weui-mask').on('click', function () {
  589. pickerShow('#time_cycle', false)
  590. })
  591. // 关闭dialog
  592. $('#time_cycle .box_hd .cancel').on('click', function () {
  593. pickerShow('#time_cycle', false)
  594. })
  595. // 选择完成(确定)按钮的点击事件
  596. $('#enter_period').on('click', function () {
  597. var checkedValue = $('#time_cycle input:radio[name="time"]:checked').val();
  598. var result = null
  599. if (checkedValue == 'month') {
  600. result = $('#number_box_month .month_number').text() + '个月'
  601. } else if (checkedValue == 'year') {
  602. result = $('#number_box_year span.active').attr('data-id') + '年'
  603. }
  604. console.log(result)
  605. $('.vip-body .extend-cycle').show().text('延长订阅周期' + result)
  606. pickerShow('#time_cycle', false)
  607. })
  608. // 1. 对订阅时间选择的input绑定点击事件
  609. $('#time_cycle input:radio[name="time"]').on('click', function (e) {
  610. // 解除确认按钮的锁定
  611. $('#time_cycle .form-btn button').removeAttr('disabled')
  612. if ($(e.target).hasClass('monthly')) {
  613. // 按月订阅
  614. $('#number_box_month').addClass('active');
  615. $('#number_box_year span').removeClass('active');
  616. } else {
  617. // 按年订阅
  618. $('#number_box_month').removeClass('active');
  619. // $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active');
  620. }
  621. })
  622. /* --------控制月份number_box的事件 点击加减号触发的事件------- */
  623. $('#number_box_month').on('click', 'button', function (e) {
  624. // 点击加减号让input radio选中
  625. $("#monthly").prop('checked', true);
  626. $('#yearly').prop('checked', false);
  627. $('.number_box span').removeClass('active')
  628. $('#number_box_month').addClass('active');
  629. var $number = $('#number_box_month span.month_number');
  630. var $monthlyInput = $('#monthly');
  631. // 未整理的data数组,里面的值都是字符串
  632. var preData = e.delegateTarget.dataset
  633. var currentNum = parseInt($number.text());
  634. var data = {};
  635. // 把字符串转换成数字
  636. for (var i in preData) {
  637. data[i] = preData[i] - 0
  638. }
  639. if (!$monthlyInput.prop('checked')) {
  640. return
  641. }
  642. // 判断是点击的是+ 还是-
  643. if ($(e.target).hasClass('add') || $(e.currentTarget).hasClass('add')) {
  644. // 点的+
  645. // currentNum = currentNum >= 12 ? 12 : currentNum + 1;
  646. currentNum = currentNum >= data.numboxMax ? data.numboxMax : (currentNum + data
  647. .numboxStep);
  648. } else {
  649. // 点的-
  650. // currentNum = currentNum <= 1 ? 1 : currentNum - 1;
  651. currentNum = currentNum <= data.numboxMin ? data.numboxMin : (currentNum - data
  652. .numboxStep);
  653. }
  654. $number.text(currentNum)
  655. var price = (5.8 * currentNum).toFixed(1);
  656. $('.computed_price').html(price)
  657. var firstButton = $('#number_box_month button:first')
  658. var lastButton = $('#number_box_month button:last')
  659. if (currentNum >= 10) {
  660. $('.profit_tips').show()
  661. } else {
  662. $('.profit_tips').hide()
  663. }
  664. // 如果为操作后的结果为1,则锁定减号按钮
  665. if (currentNum === data.numboxMin) {
  666. firstButton.attr('disabled', true)
  667. } else {
  668. firstButton.removeAttr('disabled')
  669. }
  670. // 如果为操作后的结果为12,则锁定加号按钮
  671. if (currentNum === data.numboxMax) {
  672. lastButton.attr('disabled', true)
  673. } else {
  674. lastButton.removeAttr('disabled')
  675. }
  676. })
  677. /* -------- 控制年份number_box的事件 点击1年 2年 3年触发的事件------- */
  678. $('#number_box_year').on('click', 'span', function (e) {
  679. $('#number_box_month').removeClass('active');
  680. console.log(e.target.dataset.id)
  681. var id = e.target.dataset.id;
  682. $('.profit_tips').hide()
  683. $(this).addClass('active').siblings().removeClass('active')
  684. $('#yearly').prop('checked', true);
  685. $("#monthly").prop('checked', false);
  686. // 渲染结果 保留一位小数
  687. var result = (Number(id) * 58).toFixed(1);
  688. $('.computed_price').html(result)
  689. })
  690. /* -------- 选择按月订阅 radio触发的事件------- */
  691. $('#monthly').on('change', function (e) {
  692. var isChecked = $(this).is(':checked')
  693. var val = $('.month_number').text();
  694. if (val >= 10) {
  695. $('.profit_tips').show()
  696. }
  697. if (!isChecked) {
  698. $('#number_box_month button').attr('disabled', true)
  699. } else {
  700. $('#number_box_month button').removeAttr('disabled')
  701. }
  702. if (val === 1) {
  703. $('#number_box_month button:eq(0)').prop('disabled', true)
  704. }
  705. if (val === 12) {
  706. $('#number_box_month button:eq(1)').prop('disabled', true)
  707. }
  708. var result = (Number(val) * 5.8).toFixed(1);
  709. $('.computed_price').html(result)
  710. })
  711. /* -------- 选择按年订阅 radio触发的事件------- */
  712. $('#yearly').on('change', function (e) {
  713. $('.profit_tips').hide()
  714. // console.log($(this).is(':checked'))
  715. var isChecked = $(this).is(':checked')
  716. // 按年订阅默认选择1年
  717. var val = 1;
  718. $('.computed_price').html(Number(val) * 58);
  719. if (isChecked) {
  720. $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active')
  721. }
  722. });
  723. }
  724. //提交请求
  725. $('.vip-footer .button-r.confirm').on('click', function () {
  726. $(this).attr("disabled", "disabled");
  727. // doSubmit();
  728. $(this).removeAttr("disabled");
  729. });
  730. // 以下数据交互 -------------------
  731. // 定义全部变量state
  732. var globalState = {};
  733. var changeTime = [];
  734. var submitPrice = 0;
  735. var selectTime = "";
  736. function init(state) {
  737. checkmerge(state.industry, state.isread)
  738. // init 已选择的区域和行业
  739. // var selectedAreaAndInd = getBuySet(state.area, state.industry);
  740. // 2021-5-21修改
  741. var selectedAreaAndInd = getSelectBuyset(state.area, state.industry)
  742. setSelectedAreaAndInd(selectedAreaAndInd);
  743. // 初始化,已购买的城市和行业
  744. setBuyAreaAndInd(state.buyset);
  745. //是否提示即将到期
  746. showTimeOut(state.endTime, state.isTrial);
  747. selectTime = sessionStorage.getItem("vip_change_time");
  748. var endflag = state.endTime;
  749. var stratFlag = state.startTime;
  750. //刷新展示周期
  751. flushShowTime(state.isTrial, selectTime, stratFlag, endflag);
  752. // 初始化关键词
  753. // if (state.items.length === 0) {
  754. // $('.body-item.keywords .keywords-text').text('未分类')
  755. // } else {
  756. // var arr = []
  757. // state.items.forEach(function (item, index) {
  758. // arr.push(item['s_item'])
  759. // })
  760. // $('.body-item.keywords .keywords-text').text(arr.join('、'))
  761. // }
  762. if (state.matchway) {
  763. var ModeArr = ['按标题匹配', '按全文匹配']
  764. var nowMode = ModeArr[state.matchway - 1] || '按标题匹配'
  765. $(".body-item.match-way .keywords-text.match-way-value").text(nowMode)
  766. var popDom = $("#iosActionsheet .weui-actionsheet__cell.active")
  767. if (popDom.find('.cell_title').text() !== nowMode) {
  768. popDom.removeClass('active').siblings().addClass('active');
  769. }
  770. }
  771. // 推送设置初始化
  772. var pushSettingMap = {
  773. 1: '实时推送',
  774. 2: '每日推送',
  775. 3: '每周推送',
  776. 4: '每月推送',
  777. }
  778. $('.body-item.push-setting .push-setting-text').text(pushSettingMap[state.ratemode])
  779. // 初始化“其他"开关
  780. console.log(state.otherbuyerclass)
  781. if (state.otherbuyerclass == 1 || state.otherbuyerclass == null) {
  782. $('.switch_other').addClass('checked')
  783. } else {
  784. $('.switch_other').removeClass('checked')
  785. }
  786. //试用不展示续费
  787. if (!state.isTrial) {
  788. $('.super-title').show();
  789. $(".renew").show();
  790. if ($("#giveTimeBox").is('[data-new-year]')) {
  791. showGiveStatus(true)
  792. }
  793. } else {
  794. $('.try-seven').show();
  795. $(".trail").show();
  796. if ($("#giveTimeBox").is('[data-new-year]')) {
  797. showGiveStatus(true)
  798. }
  799. }
  800. $('[data-update-tips]').hide()
  801. // 如果购买的是升级版套餐 不显示升级提示 且如果是全国全行业 则不显示升级按钮
  802. if (state.buyset.upgrade === 1) {
  803. $('[data-update-tips]').hide()
  804. if (state.buyset.areacount == -1) {
  805. $('*[data-bind-update]').hide()
  806. $('button[data-bind-renew]').css("margin-right", 0)
  807. }
  808. }
  809. // 清除升级页面的区域选择
  810. sessionStorage.removeItem('vipSubSelectArea')
  811. }
  812. // 给订阅周期栏目绑定点击事件(订阅周期选择框显示与隐藏等各种操作)
  813. //initCycleSelector()
  814. var subVipState = sessionStorage.getItem('sub_vip_state');
  815. var reqData = JSON.parse(subVipState);
  816. // if (subVipState) {
  817. // init(reqData);
  818. // subNode.initData = reqData
  819. // //判断是否修改
  820. // var IndustryNoChange = JSON.stringify(reqData.oldIndustry.sort()) === JSON.stringify(reqData.industry.sort());
  821. // var tmp1 = getAreaClassArr(reqData.oldArea);
  822. // var tmp2 = getAreaClassArr(reqData.area);
  823. // var areaNoChange = (JSON.stringify(tmp1[0].sort()) === JSON.stringify(tmp2[0].sort())) && (JSON.stringify(tmp1[1].sort()) === JSON.stringify(tmp2[1].sort()));
  824. // if (IndustryNoChange && areaNoChange && changeTime.length === 0) {
  825. // getDataWitXHR()
  826. // return
  827. // }
  828. // //判断是否需要升级
  829. // var status = getUpgradeFinalStatus(getBuySet(reqData.area, reqData.industry), {
  830. // "areacount": reqData.buyset.areacount,
  831. // "buyerclasscount": reqData.buyset.buyerclasscount,
  832. // "citys": reqData.buyset.newcitys
  833. // }, changeTime, reqData.endTime, reqData.renewList, reqData.isTrial);
  834. // // 双11.11活动
  835. // var giveT = [changeTime[1] === 1 ? 1 :changeTime[0], changeTime[1]]
  836. // if (!giveT[0] || !giveT[1]) {
  837. // giveT = []
  838. // }
  839. // var giveStatue = getUpgradeFinalStatus(getBuySet(reqData.area, reqData.industry), {
  840. // "areacount": reqData.buyset.areacount,
  841. // "buyerclasscount": reqData.buyset.buyerclasscount,
  842. // "citys": reqData.buyset.newcitys
  843. // }, giveT, reqData.endTime, reqData.renewList, reqData.isTrial);
  844. // var givePrice = giveStatue[0]
  845. // var giveCycle = changeTime[1] === 1 ? ('1年') : ((changeTime[0] ? changeTime[0] : 1) + '个月')
  846. // if (status[0] === -2) {
  847. // weui.toast('订单冲突', {
  848. // duration: 3000,
  849. // className: 'jy-toast',
  850. // });
  851. // return
  852. // }
  853. // if (status[0] === -1) {
  854. // //直接修改
  855. // $(".vip-footer.modify").show();
  856. // // doSubmit()
  857. // // initBack(1);
  858. // return
  859. // }
  860. // //区域需要升级
  861. // if (status[1]) {
  862. // if (reqData.isTrial) {
  863. // $(".area .tip").text("需购买");
  864. // }
  865. // $(".area .tip-need-upgrade").show();
  866. // }
  867. // //行业需要升级
  868. // if (status[2]) {
  869. // if (reqData.isTrial) {
  870. // $(".industry .tip").text("需购买");
  871. // }
  872. // $(".industry .tip-need-upgrade").show()
  873. // }
  874. // console.log(status[0],'111111')
  875. // if (status[0] > 0) {
  876. // //需要付钱
  877. // $(".vip-footer.upgrade").show();
  878. // //价格展示
  879. // var nowTime = new Date().getTime();
  880. // var startTime = live20200707.startTime;
  881. // var endTime = live20200707.endTime;
  882. // var activeDiscount = parseFloat(live20200707.activeDiscount);
  883. // var startTimes = parseInt(startTime) * 1000;
  884. // var endTimes = parseInt(endTime) * 1000;
  885. // if (nowTime >= startTimes && nowTime < endTimes) {
  886. // var price = status[0];
  887. // $(".price-num").text(price);
  888. // status[0] = parseFloat(price) * activeDiscount;
  889. // var activePrice = formatMoney(parseFloat(price) - parseFloat(price) * activeDiscount);
  890. // $(".reduce-price").text(formatMoney(activePrice));
  891. // // for (var i=0;i<status.length;i++){
  892. // // if(i===3){
  893. // // for (var a in status[i]){
  894. // // status[i][a].price = parseFloat(status[i][a].price) * activeDiscount;
  895. // // }
  896. // // }
  897. // // }
  898. // }
  899. // $(".vip-footer.upgrade .billing-price").text(formatMoney(status[0]));
  900. // submitPrice = status[0] * 10000 / 100
  901. // // 活动期间,则显示优惠码
  902. // if ($('.vip-upgrade').hasClass('live-20200707')) {
  903. // // 优惠码选项
  904. // $('.coupon-code-tx').show()
  905. // // 原价现价
  906. // $('.origin-price').css('display', 'flex')
  907. // // 优惠提示
  908. // $('.j-notice-bar.vip-bar').css('display', 'flex')
  909. // }
  910. // // coupon.updatePrice(status[0])
  911. // }
  912. // if (reqData.isTrial) {//试用购买
  913. // if ($("#giveTimeBox").hasClass('hasDoubleEleven')) {
  914. // $(".origin-price").css('display', 'flex')
  915. // $("#giveTimeBox").show()
  916. // $("#giveTimeText").text(giveCycle)
  917. // $('.origin-price .price-num').text(formatMoney(status[0] + givePrice));
  918. // // 优惠明细
  919. // $('.discount-price .dis-price').text(formatMoney(givePrice))
  920. // $('.now-price .dis-price').text(formatMoney(status[0]));
  921. // }
  922. // if (changeTime.length === 0) {
  923. // //刷新展示时间
  924. // changeTime = [1, 2];//
  925. // flushShowTime(true, "1个月");
  926. // sessionStorage.setItem("vip_trial_buy", true);
  927. // selectTime = "1个月"
  928. // }
  929. // initBack(4);
  930. // $(".vip-footer.upgrade .confirm").text("立即购买");
  931. // // coupon.$refs.couponRef.btnText = "立即购买"
  932. // } else if ((!status[1] && !status[2])) {//续费
  933. // initBack(2);
  934. // } else {//升级
  935. // //升级展示计价清单
  936. // if (!reqData.isTrial) {
  937. // $(".preview-label").text("需补差价:");
  938. // $(".billing-list-btn").text("计费清单");
  939. // $(".va-total-container .total-price").text("共计:¥" + formatMoney(status[0]));
  940. // flushSubtotal(status[3]);
  941. // console.log("subtotail", status[3])
  942. // }
  943. // // initBack(2);// 升级
  944. // }
  945. // } else {
  946. // }
  947. getDataWitXHR()
  948. //返回提示使用
  949. function pushHistory() {
  950. var state = {
  951. title: "title",
  952. url: "#"
  953. };
  954. window.history.pushState(state, "title", "#");
  955. }
  956. function initBack(module) {
  957. pushHistory();
  958. //weui.toast(module);
  959. $('.vip-footer .button-l.reset').off("click").on("click", function () {
  960. $('.weui-mask').trigger('click')
  961. cancelTip(module);
  962. });
  963. window.addEventListener("popstate", function (e) {
  964. // 如果订单计费清单显示,则关闭清单;
  965. if ($(".billing-list-container").css("display") != "none" && module === 2) {
  966. pickerShow('.billing-list-container', false);
  967. pushHistory();
  968. } else {
  969. // 提示是否保存
  970. $('.weui-mask').trigger('click')
  971. var flagString = location.href.slice(-1)
  972. if (flagString === '#') return
  973. if (history.state && history.state.flag === "pay") {
  974. return
  975. }
  976. cancelTip(module);
  977. }
  978. }, false);
  979. }
  980. //保存 or 升级
  981. var submited = false;
  982. function doSubmit() {
  983. if (submited) {
  984. return
  985. }
  986. submited = true;
  987. setTimeout(function () {
  988. submited = false;
  989. }, 1000);
  990. //校验是否点击阅读条款
  991. // if (submitPrice > 0) {
  992. // if (!$('.checkbox').hasClass("checked")) {
  993. // weui.toast('请勾选服务条款', {
  994. // duration: 1500,
  995. // className: 'jy-toast',
  996. // });
  997. // $dialog.hide(function () {
  998. // });
  999. // return
  1000. // }
  1001. // }
  1002. //优惠码
  1003. var activeCode = $('.coupon-picker .weui-input').val();
  1004. var activeCodes = "";
  1005. if (activeCode.toLowerCase() === 'jianyu360' && $('.coupon-code-tx .keywords-text').text() === '支付成功赠送30天订阅周期') {
  1006. activeCodes = 'jianyu360';
  1007. }
  1008. weui.loading()
  1009. $DoPost('/subscribepay/vipsubscribe/saveChange', {
  1010. "userLotteryId":coupon.$refs.couponRef.coupon.userLotteryId,
  1011. "lotteryId": coupon.$refs.couponRef.coupon.lotteryId,
  1012. "area": reqData.area["全国"] ? '{}' : JSON.stringify(reqData.area),
  1013. "industry": reqData.industry.join(","),
  1014. "time": selectTime,
  1015. "price": (coupon.initPrice - coupon.$refs.couponRef.coupon.value)* 10000 / 100,
  1016. "activeCode": activeCodes
  1017. }, function (r) {
  1018. if (r.success) {
  1019. if (r.data.needPay) {
  1020. weui.loading().hide()
  1021. //创建支付订单
  1022. clearSessionStorage();
  1023. history.replaceState({"flag": "pay"}, '', '/front/vipsubscribe/toOrderDetailPage?orderCode=' + r.data.code);
  1024. var nextHref = "/weixin/pay/checkout_subvip?orderCode=" + r.data.code
  1025. if (reqData.isTrial) {
  1026. nextHref += "&t=3"
  1027. } else {
  1028. nextHref += "&t=2"
  1029. }
  1030. window.location.href = nextHref
  1031. } else {
  1032. weui.loading().hide()
  1033. //订阅修改
  1034. if (r.data.doSuccess) {
  1035. clearSessionStorage();
  1036. getDataWitXHR()
  1037. // clearSessionStorage();
  1038. // window.location.reload();
  1039. } else {
  1040. weui.toast('修改保存失败', {
  1041. duration: 1500,
  1042. className: 'jy-toast',
  1043. });
  1044. }
  1045. }
  1046. }
  1047. }, false);
  1048. }
  1049. // 活动事件绑定
  1050. var couponInfo = {
  1051. code: 'jianyu360',
  1052. successTip: '支付成功赠送30天订阅周期'
  1053. }
  1054. $('.j-picker').on('click', '.cancel', function () {
  1055. $('.coupon-picker').hide()
  1056. })
  1057. $('.coupon-code-tx').on('click', function () {
  1058. if ($('.vip-upgrade').hasClass('live-20200707')) {
  1059. $('.coupon-picker').show()
  1060. } else {
  1061. return
  1062. }
  1063. var input = $('.coupon-picker .weui-input')
  1064. var confirmButton = $('.coupon-picker .weui-picker__btn')
  1065. var cancelButton = $('.coupon-picker .cancel')
  1066. var value = input.val()
  1067. input.val('').focus().val(value).on('input', function () {
  1068. value = this.value
  1069. confirmButton.prop('disabled', (value === '' || value === undefined))
  1070. })
  1071. confirmButton.on('click', function () {
  1072. if (value.toLowerCase() !== couponInfo.code) {
  1073. weui.toast('优惠码输入错误', {
  1074. className: 'j-toast',
  1075. duration: 1500
  1076. })
  1077. return
  1078. }
  1079. if (value.length === couponInfo.code.length && value.toLowerCase() === couponInfo.code) {
  1080. $('.coupon-code-tx .keywords-text').text(couponInfo.successTip)
  1081. sessionStorage.liveActiveCode_new = "jianyu360"
  1082. $('.coupon-code-tx').off('click')
  1083. cancelButton.trigger('click')
  1084. }
  1085. })
  1086. })
  1087. });
  1088. function clearSessionStorage() {
  1089. sessionStorage.removeItem("sub_vip_state");
  1090. sessionStorage.removeItem("vip_index_read");
  1091. sessionStorage.removeItem("vip_change_time");
  1092. sessionStorage.removeItem("vip_trial_buy");
  1093. //续费页面缓存
  1094. sessionStorage.removeItem("vipSubSelectArea");
  1095. sessionStorage.removeItem("vipSubSelectIndustry");
  1096. sessionStorage.removeItem("vipSubSelectTime");
  1097. sessionStorage.removeItem("endTime");
  1098. sessionStorage.removeItem("liveActiveCode_new");
  1099. sessionStorage.removeItem("liveActiveCode_renew");
  1100. }
  1101. var mergedlist = []
  1102. var merge_industry = ["国土", "林业", "环保", "卫生", "工商", "质监", "食药", "安监", "地震", "公安", "文化", "旅游", "银监", "保监"]
  1103. function checkmerge(state, isread) {
  1104. if (checkindustry(state)) {
  1105. var tips = "<span style='font-size:15px;font-family:PingFang SC;font-weight:bold;color:rgba(29,29,29,1);opacity:1;'>随着政府机构改革和职能转变工作深入推进,部分采购单位行业与现实不一致,为了提高订阅推送数据的准确性,剑鱼标讯需要针对采购单位行业名称进行优化。</span><br><span style='font-size:13px;font-family:PingFang SC;font-weight:400;color:rgba(104,104,104,1);opacity:1;'>采购单位名称的调整不影响所购买的采购单位数量,您仍可按需调整。<br><br>您订阅的:<br></span>"
  1106. var hasMerged = isread
  1107. var s_count = h_count = m_count = p_count = cultural_count = CBRC_count = t_count = 0
  1108. var nature_source = ["国土", "林业"];
  1109. var health_commission = ["卫生"]
  1110. var market_supervision = ["工商", "质监", "食药"]
  1111. var contingency_management = ["安监", "地震", "公安"]
  1112. var cultural_tourism = ["文化", "旅游"]
  1113. var CBRC = ["银监", "保监"]
  1114. var ecological_environment = ["环保"]
  1115. state.forEach(function (item, index) {
  1116. if (merge_industry.indexOf(item) > -1) {
  1117. if (item == "国土" || item == "林业") {
  1118. mergedlist.push("自然资源")
  1119. // hasMerged = true
  1120. nature_source = Highlight(nature_source, item)
  1121. s_count++
  1122. } else if (item == "环保") {
  1123. mergedlist.push("生态环境")
  1124. // hasMerged = true
  1125. ecological_environment = Highlight(ecological_environment, item)
  1126. h_count++
  1127. } else if (item == "卫生") {
  1128. mergedlist.push("卫健委")
  1129. // hasMerged = true
  1130. health_commission = Highlight(health_commission, item)
  1131. p_count++
  1132. } else if (item == "工商" || item == "质监" || item == "食药") {
  1133. mergedlist.push("市场监管")
  1134. // hasMerged = true
  1135. market_supervision = Highlight(market_supervision, item)
  1136. m_count++
  1137. } else if (item == "地震" || item == "安监" || item == "公安") {
  1138. if (item !== "公安") {
  1139. mergedlist.push("应急管理")
  1140. } else {
  1141. mergedlist.push("公安")
  1142. }
  1143. // hasMerged = true
  1144. contingency_management = Highlight(contingency_management, item)
  1145. t_count++
  1146. } else if (item == "文化" || item == "旅游") {
  1147. mergedlist.push("文旅")
  1148. // hasMerged = true
  1149. cultural_tourism = Highlight(cultural_tourism, item)
  1150. cultural_count++
  1151. } else if (item == "银监" || item == "保监") {
  1152. mergedlist.push("银保监")
  1153. // hasMerged = true
  1154. CBRC = Highlight(CBRC, item)
  1155. CBRC_count++
  1156. }
  1157. } else {
  1158. mergedlist.push(item)
  1159. }
  1160. })
  1161. if (s_count >= 1) {
  1162. tips += nature_source.join('、') + " 合并为 【自然资源】<br>"
  1163. }
  1164. if (h_count >= 1) {
  1165. tips += ecological_environment.join('、') + " 整合其他部门部分职能后更改为 【生态环境】<br>"
  1166. }
  1167. if (p_count >= 1) {
  1168. tips += health_commission.join('、') + " 变更为 【卫健委】<br>"
  1169. }
  1170. if (m_count >= 1) {
  1171. tips += market_supervision.join('、') + " 合并为 【市场监管】<br>"
  1172. }
  1173. if (t_count >= 1) {
  1174. tips += contingency_management.join('、') + "中的消防 合并为 【应急管理】<br>"
  1175. }
  1176. if (cultural_count >= 1) {
  1177. tips += cultural_tourism.join('、') + " 合并为 【文旅】<br>"
  1178. }
  1179. if (CBRC_count >= 1) {
  1180. tips += CBRC.join('、') + " 合并为 【银保监】<br>"
  1181. }
  1182. if (!hasMerged) {
  1183. $("#merge_content").html(tips)
  1184. $("#merge_dialog").show()
  1185. }
  1186. }
  1187. }
  1188. function Highlight(a_list, key) {
  1189. a_list.forEach(function (item, index) {
  1190. if (item == key) {
  1191. var m = "<span style='color:red'>" + item + "</span>"
  1192. a_list[index] = m
  1193. }
  1194. })
  1195. return a_list
  1196. }
  1197. function acceptchange() {
  1198. var q = removeDuplicatedItem(mergedlist)
  1199. $.post("/subscribepay/vipsubscribe/mergeIndustry", {"industry": q.toString(), "isread": true}, function (r) {
  1200. if (r.success) {
  1201. sessionStorage.removeItem("sub_vip_state")
  1202. console.log("行业合并成功")
  1203. } else {
  1204. console.log("行业合并失败")
  1205. }
  1206. })
  1207. $("#merge_dialog").hide()
  1208. }
  1209. function removeDuplicatedItem(ar) {
  1210. var ret = [];
  1211. for (var i = 0, j = ar.length; i < j; i++) {
  1212. if (ret.indexOf(ar[i]) === -1) {
  1213. ret.push(ar[i]);
  1214. }
  1215. }
  1216. return ret;
  1217. }
  1218. function checkindustry(industry) {
  1219. var isinclude = false
  1220. industry.forEach(function (item, index) {
  1221. if (merge_industry.indexOf(item) > -1) {
  1222. isinclude = true
  1223. return
  1224. }
  1225. })
  1226. return isinclude
  1227. }
  1228. // 解决ios微信下软键盘收起后,页面留白
  1229. document.body.addEventListener("focusout", function () {
  1230. //软键盘收起的事件处理
  1231. setTimeout(function () {
  1232. const scrollHeight =
  1233. document.documentElement.scrollTop || document.body.scrollTop || 0;
  1234. window.scrollTo(0, Math.max(scrollHeight - 1, 0));
  1235. }, 100);
  1236. });