vip_index_new.js 54 KB

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