vip_renew.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. var renew = {
  2. oldRules: Calculation.PriceRule.old,
  3. newRules: Calculation.PriceRule.new,
  4. requestRules: {},
  5. price: '', // 单位分
  6. timeSelect: [1, 2], // 续费周期(默认选中1个月)
  7. timeCheckOk: true,
  8. buyInfo: { // 购买的信息
  9. startTime: 0,
  10. endTime: 0,
  11. area: {},
  12. industry: [],
  13. buyset: {
  14. areacount: 0,
  15. newcitys: [],
  16. buyerclasscount: 0,
  17. upgrade: 0
  18. },
  19. isTrial: false,
  20. renewList: []
  21. },
  22. init: function () {
  23. this.initEvents()
  24. this.recoverState()
  25. this.getPrice()
  26. this.getBuySetInfo()
  27. this.setTimePickerSelected(this.timeSelect)
  28. },
  29. setAreaAndIndustry: function () {
  30. var buySet = this.buyInfo.buyset
  31. var result = {
  32. area: '',
  33. industry: ''
  34. }
  35. // 区域
  36. if (buySet.areacount === -1) {
  37. result.area = '全国'
  38. } else {
  39. var strArr = []
  40. if (buySet.areacount) {
  41. strArr.push(buySet.areacount + '个省')
  42. }
  43. if (buySet.newcitys && buySet.newcitys.length !== 0) {
  44. var count = 0
  45. buySet.newcitys.forEach(function (item) {
  46. count += item
  47. })
  48. strArr.push(count + '个市(分布在' + buySet.newcitys.length + '个省内')
  49. }
  50. result.area = strArr.join('、')
  51. }
  52. // 行业
  53. if (buySet.buyerclasscount === -1) {
  54. result.industry = '全部行业'
  55. } else {
  56. result.industry = buySet.buyerclasscount + '个行业'
  57. }
  58. $('.area .item-r').text(result.area)
  59. $('.industry .item-r').text(result.industry)
  60. return result
  61. },
  62. initEvents: function () {
  63. this.initClickEvents()
  64. this.initPickerEvents()
  65. },
  66. getBuySetInfo: function () {
  67. var _this = this
  68. $.ajax({
  69. url: '/subscribepay/vipsubscribe/getSubBuyMsg',
  70. type: 'POST',
  71. success: function (r) {
  72. if (r.success && r.data) {
  73. Object.assign(_this.buyInfo, r.data)
  74. _this.setAreaAndIndustry()
  75. _this.checkShowDueTip()
  76. // 初始化默认续费周期
  77. _this.calcDuration(true)
  78. // 初始化价格计算类
  79. Calculation.Init(
  80. _this.buyInfo.isTrial,
  81. new Buyset(
  82. _this.buyInfo.buyset.areacount,
  83. _this.buyInfo.buyset.newcitys,
  84. _this.buyInfo.buyset.buyerclasscount,
  85. _this.buyInfo.buyset.upgrade || 0
  86. )
  87. )
  88. // 新超级订阅续费
  89. if (r.data.buyset.upgrade == 1) {
  90. $("[data-new-vip]").show()
  91. $("[data-old-vip]").hide()
  92. if (_this.buyInfo.buyset.areacount == -1) {
  93. goodsSize.props.areaCount = 16
  94. } else {
  95. goodsSize.props.areaCount = _this.buyInfo.buyset.areacount
  96. }
  97. }
  98. // 初始化默认金额
  99. _this.setPrice(_this.calcPrice())
  100. }
  101. }
  102. })
  103. },
  104. getPrice: function () {
  105. var _this = this
  106. $.ajax({
  107. url: '/subscribepay/vipsubscribe/getPrice',
  108. type: 'POST',
  109. success: function (r) {
  110. if (r) {
  111. _this.requestRules = r
  112. // 将价格列表传至商品规格组件
  113. goodsSize.props.priceInfo = r.new
  114. }
  115. }
  116. })
  117. },
  118. // 计算价格
  119. calcPrice: function (timeSelect) {
  120. return Calculation.GetTotal(undefined, timeSelect ? timeSelect : this.timeSelect)
  121. },
  122. // 设置价格
  123. setPrice: function (price) {
  124. this.price = parseInt(price)
  125. var size = JSON.parse(sessionStorage.getItem('vip-cur-select-size'))
  126. // console.log(renew.buyInfo.buyset)
  127. var count = renew.buyInfo.buyset.areacount == -1 ? 16 : renew.buyInfo.buyset.areacount
  128. if (this.buyInfo.buyset.upgrade == 1) {
  129. // 新规则初始化价格
  130. if (size) {
  131. // 初始化上次选择的商品规格
  132. coupon.updatePrice(size.price / 100)
  133. } else {
  134. // 初始化默认一个月*省份数量或全国价格
  135. sessionStorage.removeItem('$select-coupon')
  136. if (count >= 16) {
  137. coupon.updatePrice(59900 / 100)
  138. } else {
  139. coupon.updatePrice(3800*count / 100)
  140. }
  141. }
  142. } else {
  143. // 旧规则初始化价格
  144. coupon.updatePrice(this.price / 100)
  145. }
  146. },
  147. // 根据选中结果得到续费了多长时间的字符串
  148. getDuration: function (timeSelect) {
  149. var durationStr = ''
  150. if (timeSelect[1] === 1) {
  151. // 年
  152. durationStr = timeSelect[0] + '年'
  153. } else if (timeSelect[1] === 2) {
  154. // 月
  155. durationStr = timeSelect[0] + '个月'
  156. }
  157. return durationStr
  158. },
  159. // 计算续费后的日期区间
  160. calcDuration: function (needSet) {
  161. // 根据
  162. var endTime = this.buyInfo.endTime
  163. if (!endTime) {
  164. $('.select_cycle .duration').hide()
  165. return
  166. }
  167. var durationStamp = getVipEndDate(this.timeSelect[1], this.timeSelect[0], endTime) - endTime // 续费时间段时间戳
  168. var durationStr = this.getDuration(this.timeSelect) // 续费时间段字符串
  169. var buyEndTimeString = new Date(endTime * 1000).pattern('yyyy年MM月dd日') // svip到期时间
  170. var renewEndTimeString = new Date((endTime + durationStamp) * 1000).pattern('yyyy年MM月dd日') //续费后到期时间
  171. if (needSet) {
  172. $('.select_cycle .month').text(durationStr)
  173. $('.select_cycle .duration').text(buyEndTimeString + ' - ' + renewEndTimeString)
  174. } else {
  175. return {
  176. duration: durationStr, // 续费时间段字符串
  177. buyEndTimeString: buyEndTimeString, // svip到期时间
  178. renewEndTimeString: renewEndTimeString, //续费后到期时间
  179. }
  180. }
  181. },
  182. // 月份转年份(超过1年才会转)
  183. monthToYear: function (num) {
  184. var year = Math.floor(num / 12)
  185. var month = num % 12
  186. var str = ''
  187. if (year) {
  188. str += (year + '年')
  189. }
  190. if (month) {
  191. str += (month + '个月')
  192. }
  193. return {
  194. str: str,
  195. year: year,
  196. month: month
  197. }
  198. },
  199. checkOver3Years: function (timeSelect) {
  200. // 根据
  201. var endTime = this.buyInfo.endTime
  202. if (!endTime) {
  203. return
  204. }
  205. var maxEndMonth = 36 // 最大续费36个月
  206. var durationStamp = getVipEndDate(timeSelect[1], timeSelect[0], endTime) - endTime // 续费时间段时间戳
  207. // 最长订阅周期不可超过3年 ------------
  208. var nowStamp = Math.floor(Date.now() / 1000)
  209. // 已购买的套餐剩余月数
  210. var lastMonthStamp = endTime - nowStamp
  211. var lastMonth = Math.round(lastMonthStamp / (60 * 60 * 24 * 30))
  212. // 续费后套餐剩余月数(需要加上原剩余月数lastMonth)
  213. var renewMonthTotalStamp = lastMonthStamp + durationStamp
  214. var renewMonthTotal = Math.round(renewMonthTotalStamp / (60 * 60 * 24 * 30))
  215. if (renewMonthTotal > maxEndMonth) {
  216. var showTipText = '<div style="white-space: nowrap;">最长订阅周期不可超过3年</div>剩余周期:' + this.monthToYear(lastMonth).str
  217. weui.toast(showTipText, {
  218. duration: 3000,
  219. className: 'jy-toast',
  220. })
  221. // 确认按钮置灰
  222. $('#enter_period').prop('disabled', true)
  223. } else {
  224. $('#enter_period').prop('disabled', false)
  225. }
  226. },
  227. // 是否展示即将到期
  228. checkShowDueTip () {
  229. var endTime = this.buyInfo.endTime * 1000
  230. var timeSub = endTime - Date.now()
  231. if (timeSub > 0 && timeSub < 60 * 60 * 24 * 1000 * 3) {
  232. $('.vip-header').show()
  233. }
  234. },
  235. setTimePickerSelected: function (timeSelect) {
  236. if (timeSelect[1] == 1) {
  237. // 年
  238. var cButton = $('.year_number.j-button-select[data-id=' + timeSelect[0] + ']')
  239. if (cButton) {
  240. cButton.trigger('click')
  241. } else {
  242. $('input[value=year]').trigger('click')
  243. }
  244. } else if (timeSelect[1] == 2) {
  245. // 月
  246. $('input[value=month]').trigger('click')
  247. $('#number_box_month .month_number').text(timeSelect[0] - 1)
  248. $('#number_box_month button.add').trigger('click')
  249. }
  250. },
  251. getTimePickerSelected: function () {
  252. var timeSelectPicker = $('#time_cycle')
  253. var $checkInput = timeSelectPicker.find('input[name=time]:checked')
  254. if (!$checkInput) return
  255. // year/month(按年或者按月购买)
  256. var checkedType = $checkInput.val()
  257. // timeSelectedArr[0] 代表选择的内容
  258. // timeSelectedArr[1] 代表选择的类型 1年份 2月份
  259. var timeSelectedArr = []
  260. if (checkedType === 'month') {
  261. timeSelectedArr = [$('#number_box_month .month_number').text() - 0, 2]
  262. } else if (checkedType === 'year') {
  263. timeSelectedArr = [$('#number_box_year .year_number.active').attr('data-id') - 0, 1]
  264. }
  265. return timeSelectedArr
  266. },
  267. onTimePickerChange: function () {
  268. var timeSelect = this.getTimePickerSelected()
  269. var price = this.calcPrice(timeSelect)
  270. $('.computed_price').text(formatMoney(price / 100))
  271. this.checkOver3Years(timeSelect)
  272. },
  273. // 恢复数据
  274. recoverState: function () {
  275. var vipSubSelectTime = sessionStorage.getItem('vipSubSelectTime')
  276. if (vipSubSelectTime) {
  277. this.timeSelect = JSON.parse(vipSubSelectTime)
  278. }
  279. this.flushSubmit()
  280. },
  281. // 保存数据
  282. saveState: function () {
  283. sessionStorage.setItem('vipSubSelectTime', JSON.stringify(this.timeSelect))
  284. },
  285. // 是否可提交
  286. flushSubmit: function () {
  287. if (this.timeCheckOk && sessionStorage.getItem("vipSub_read") === "true") {
  288. $('.vip-footer.renew .confirm').prop('disabled', false)
  289. coupon.checkboxStatus = true
  290. coupon.$refs.couponRef.submitStatus = false
  291. } else {
  292. $('.vip-footer.renew .confirm').prop('disabled', true)
  293. coupon.$refs.couponRef.submitStatus = true
  294. }
  295. },
  296. initClickEvents: function () {
  297. var _this = this
  298. /*------ 关闭弹窗事件 点击取消或遮罩层 -----*/
  299. $('.weui-mask').click(hideDialog);
  300. $('.cancel').click(hideDialog);
  301. // 确认订阅周期
  302. $('#enter_period').on('click', function () {
  303. $('.weui-mask').trigger('click')
  304. _this.timeSelect = _this.getTimePickerSelected()
  305. _this.calcDuration(true)
  306. _this.setPrice(_this.calcPrice())
  307. _this.saveState()
  308. })
  309. $('.vip-footer.renew .confirm').on('click', function () {
  310. $('.vip-footer.renew .confirm').prop('disabled', true)
  311. var upgrade = renew.buyInfo.buyset.upgrade
  312. var size = goodsSize.defaultSize
  313. var sizeTime = ''
  314. if (size && size.period) {
  315. if(size.period.indexOf('月') > -1) {
  316. size.period = size.period.replace('月', '个月')
  317. }
  318. sizeTime = size.period
  319. } else {
  320. sizeTime = '1个月'
  321. }
  322. console.log(upgrade,sizeTime, '新or老')
  323. //支付请求
  324. var data = {
  325. userLotteryId :coupon.$refs.couponRef.coupon.userLotteryId,
  326. lotteryId : coupon.$refs.couponRef.coupon.lotteryId,
  327. time : upgrade == 0 ? _this.getDuration(_this.timeSelect).trim() : sizeTime,
  328. orderType: 5,
  329. disWord :GetQueryString('disWord'),
  330. price: coupon.initPrice*10000/100
  331. }
  332. $.ajax({
  333. // url: '/subscribepay/vipsubscribe/createOrder',
  334. url: '/subscribepay/vipsubscribe/renew',
  335. type: 'POST',
  336. data: data,
  337. success: function (r) {
  338. if (r.success) {
  339. clearSessionStorage()
  340. try {
  341. history.replaceState({}, '', '/front/vipsubscribe/toOrderDetailPage?orderCode=' + r.data.code);
  342. window.location.href = "/weixin/pay/checkout_subvip?t=1&orderCode=" + r.data.code;
  343. } catch (e) {
  344. showToast(e)
  345. }
  346. } else {
  347. showToast(r.errMsg || '请求失败')
  348. }
  349. },
  350. complete: function () {
  351. $('.vip-footer.renew .confirm').prop('disabled', false)
  352. }
  353. })
  354. })
  355. },
  356. initPickerEvents: function () {
  357. var _this = this
  358. /* ----- 订阅周期弹窗弹出事件 -------*/
  359. // 选择订阅周期
  360. $('.select_cycle a').click(function (e) {
  361. _this.onTimePickerChange()
  362. $('#time_cycle').show(200);
  363. });
  364. // 对订阅时间选择的input绑定点击事件
  365. $('#time_cycle input:radio[name="time"]').on('click', function (e) {
  366. // 解除确认按钮的锁定
  367. if ($(e.target).hasClass('monthly') !== $('#number_box_month').hasClass('active')) {
  368. $('#time_cycle .form-btn button').removeAttr('disabled');
  369. }
  370. if ($(e.target).hasClass('monthly')) {
  371. // 按月订阅
  372. $('#number_box_month').addClass('active');
  373. $('#number_box_year span').removeClass('active');
  374. } else {
  375. // 按年订阅
  376. $('#number_box_month').removeClass('active');
  377. }
  378. });
  379. /* --------控制月份number_box的事件 点击加减号触发的事件------- */
  380. $('#number_box_month').on('click', 'button', function (e) {
  381. // 点击加减号让input radio选中
  382. $('#monthly').prop('checked', true);
  383. $('#yearly').prop('checked', false);
  384. $('.number_box span').removeClass('active');
  385. $('#number_box_month').addClass('active');
  386. var $number = $('#number_box_month span.month_number');
  387. var $monthlyInput = $('#monthly');
  388. // 未整理的data数组,里面的值都是字符串
  389. var preData = e.delegateTarget.dataset;
  390. var currentNum = parseInt($number.text());
  391. var data = {};
  392. // 把字符串转换成数字
  393. for (var i in preData) {
  394. data[i] = preData[i] - 0
  395. }
  396. if (!$monthlyInput.prop('checked')) {
  397. return
  398. }
  399. // 判断是点击的是+ 还是-
  400. if ($(e.target).hasClass('add') || $(e.currentTarget).hasClass('add')) {
  401. if (currentNum == 11) { //12个月自动跳转1年
  402. $("#number_box_year .year_number:eq(0)").trigger("click");
  403. return
  404. }
  405. // 点的+
  406. currentNum = currentNum >= data.numboxMax ? data.numboxMax : (currentNum + data.numboxStep);
  407. } else {
  408. // 点的-
  409. currentNum = currentNum <= data.numboxMin ? data.numboxMin : (currentNum - data.numboxStep);
  410. }
  411. $number.text(currentNum);
  412. _this.onTimePickerChange()
  413. var firstButton = $('#number_box_month button:first');
  414. var lastButton = $('#number_box_month button:last');
  415. // 如果为操作后的结果为1,则锁定减号按钮
  416. if (currentNum === data.numboxMin) {
  417. firstButton.attr('disabled', true)
  418. } else {
  419. firstButton.removeAttr('disabled')
  420. }
  421. // 如果为操作后的结果为12,则锁定加号按钮
  422. if (currentNum === data.numboxMax) {
  423. lastButton.attr('disabled', true)
  424. } else {
  425. lastButton.removeAttr('disabled')
  426. }
  427. });
  428. /* -------- 控制年份number_box的事件 点击1年 2年 3年触发的事件------- */
  429. $('#number_box_year').on('click', 'span', function (e) {
  430. $('#number_box_month').removeClass('active');
  431. var id = e.target.dataset.id;
  432. $(this).addClass('active').siblings().removeClass('active');
  433. $('#yearly').prop('checked', true);
  434. $("#monthly").prop('checked', false);
  435. _this.onTimePickerChange()
  436. });
  437. /* -------- 选择按月订阅 radio触发的事件------- */
  438. $('#monthly').on('change', function (e) {
  439. var isChecked = $(this).is(':checked');
  440. var val = $('.month_number').text();
  441. if (!isChecked) {
  442. $('#number_box_month button').attr('disabled', true)
  443. }
  444. _this.onTimePickerChange()
  445. });
  446. /* -------- 选择按年订阅 radio触发的事件------- */
  447. $('#yearly').on('change', function (e) {
  448. var isChecked = $(this).is(':checked');
  449. // 按年订阅默认选择1年
  450. var val = 1;
  451. if (isChecked) {
  452. $('#number_box_year span:eq(0)').addClass('active').siblings().removeClass('active')
  453. }
  454. _this.onTimePickerChange()
  455. });
  456. // 计价标准
  457. $('.billing-list-btn').on('click', function () {
  458. pickerShow('.billing-list-container', true)
  459. })
  460. // 计算标准隐藏
  461. $('.billing-list-container .dialog_hd__close').on('click', function () {
  462. pickerShow('.billing-list-container', false)
  463. })
  464. $('.checkbox').on('click', function () {
  465. $(this).toggleClass('checked')
  466. var state = $(this).hasClass('checked')
  467. sessionStorage.setItem("vipSub_read", state)
  468. renew.flushSubmit()
  469. });
  470. }
  471. }
  472. $(function () {
  473. renew.init()
  474. })
  475. //获取url中"?"符后的字符串并正则匹配
  476. function GetQueryString(name) {
  477. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  478. var r = window.location.search.substr(1).match(reg);
  479. var context = "";
  480. if (r != null)
  481. context = r[2];
  482. reg = null;
  483. r = null;
  484. return context == null || context == "" || context == "undefined" ? "" : context;
  485. }
  486. // 隐藏dialog选择框
  487. function hideDialog() {
  488. $('#pay_way').hide(200);
  489. $('#time_cycle').hide(200);
  490. $('.discount-details').hide()
  491. $('.discount-button .icon-arrow').removeClass('up')
  492. }
  493. function clearSessionStorage() {
  494. sessionStorage.removeItem("vipSubSelectTime");
  495. sessionStorage.removeItem("vipSub_read");
  496. sessionStorage.removeItem("historypushDataCache");
  497. sessionStorage.removeItem("endTime");
  498. sessionStorage.To_introducePage = 2;
  499. //订阅首页
  500. sessionStorage.removeItem("sub_vip_state");
  501. sessionStorage.removeItem("vip_index_read");
  502. sessionStorage.removeItem("vip_change_time");
  503. sessionStorage.removeItem("pay_read_cache")
  504. sessionStorage.removeItem("liveActiveCode_renew");
  505. sessionStorage.removeItem("liveActiveCode_new");
  506. // 清除商品规格当前选择
  507. sessionStorage.removeItem("vip-cur-select-size")
  508. sessionStorage.removeItem("$select-coupon")
  509. }
  510. function showToast(text) {
  511. weui.toast(text, {
  512. duration: 3000,
  513. className: 'jy-toast',
  514. })
  515. }
  516. function pickerShow(selector, f) {
  517. if (f) {
  518. // 添加进场动画,并显示
  519. $(selector).find('.weui-mask').removeClass('weui-animate-fade-out').addClass('weui-animate-fade-in')
  520. $(selector).find('.weui-picker').removeClass('weui-animate-slide-down').addClass('weui-animate-slide-up')
  521. $(selector).show(300);
  522. } else {
  523. // 添加离场动画,并隐藏
  524. $(selector).find('.weui-mask').removeClass('weui-animate-fade-in').addClass('weui-animate-fade-out')
  525. $(selector).find('.weui-picker').removeClass('weui-animate-slide-up').addClass('weui-animate-slide-down')
  526. $(selector).hide(300);
  527. }
  528. }
  529. /* vue 代码 start */
  530. // vip商品规格组件
  531. var goodsSize = new Vue({
  532. el:'#goods-size-vue',
  533. data: function() {
  534. return {
  535. props: {
  536. defaultSize: {},
  537. areaCount: 1,
  538. priceInfo: {}
  539. }
  540. }
  541. },
  542. created () {
  543. },
  544. mounted () {
  545. this.getSizeStorage()
  546. },
  547. methods: {
  548. // 父组件传省份数量至子组件
  549. getAreaCount: function() {
  550. var areaStorage = JSON.parse(sessionStorage.getItem('vipSubSelectArea'))
  551. console.log(renew.buyInfo.buyset.areacount)
  552. if (areaStorage) {
  553. var count = 0
  554. for (var key in areaStorage) {
  555. if (key.indexOf('全国') > -1) {
  556. count = 16
  557. } else {
  558. count++
  559. }
  560. }
  561. this.props.areaCount = count
  562. }
  563. },
  564. getSizeStorage: function() {
  565. // 恢复商品规格选择
  566. var size = JSON.parse(sessionStorage.getItem('vip-cur-select-size'))
  567. // console.log(size, '恢复的商品规格')
  568. if (size) {
  569. this.$refs.goodsSize.goodsActive = size.index
  570. this.defaultSize = size
  571. this.$nextTick(function(){
  572. coupon.updatePrice(size.price/100)
  573. })
  574. }
  575. },
  576. getGoodSize: function(data) {
  577. // console.log(data, '父组件接收子组件传来的商品规格')
  578. sessionStorage.removeItem('$select-coupon')
  579. this.defaultSize = data
  580. coupon.updatePrice(data.price/100)
  581. }
  582. }
  583. })
  584. // 订单提交组件
  585. var coupon = new Vue({
  586. el: '#coupon-vue',
  587. data: function () {
  588. return {
  589. type: 'vip',
  590. initPrice: 0, // 原价
  591. realPrice: 0, // 实付价
  592. checkboxStatus: false, // checkbox状态
  593. submitStatus: true, // 提交按钮状态
  594. links: [
  595. {
  596. text: '《剑鱼标讯线上购买与服务条款》',
  597. url: '/front/staticPage/wx-serviceterms.html',
  598. event: this.readEvent
  599. }
  600. ],
  601. buttons: {
  602. submit: this.submitOrder
  603. }
  604. }
  605. },
  606. mounted () {
  607. this.init()
  608. },
  609. methods: {
  610. // 更新价格相关
  611. updatePrice: function (before) {
  612. console.log( '原价:' + before)
  613. this.initPrice = before;
  614. // 调用子组件查询最优卡券
  615. this.$refs.couponRef.getCoupon();
  616. },
  617. // 初始化及回显相关
  618. init: function () {},
  619. // 勾选阅读协议
  620. updateS: function(data) {
  621. data.callback(this.checkSubmitStatus(data.check))
  622. },
  623. // 校验checkbox
  624. checkSubmitStatus: function (checkStatus) {
  625. sessionStorage.setItem("vipSub_read", checkStatus)
  626. renew.flushSubmit()
  627. return renew.timeCheckOk && sessionStorage.getItem("vipSub_read") === "true"
  628. },
  629. saveEvent: function () {
  630. renew.saveState()
  631. sessionStorage.setItem("pay_read_cache", "0");
  632. },
  633. // 阅读协议点击事件
  634. readEvent: function () {
  635. renew.saveState()
  636. toRead()
  637. },
  638. // 订单提交事件
  639. submitOrder: function () {
  640. this.$refs.couponRef.submitStatus = true
  641. $('.vip-footer.renew .confirm').trigger('click')
  642. this.$refs.couponRef.submitStatus = false
  643. }
  644. }
  645. })
  646. /* vue 代码 end */