womusic.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import * as compnt from "../../../public/js/compnt.js";
  2. import * as unicom from "../../../public/js/unicom.js";
  3. import "../scss/womusic.scss";
  4. import "../../../public/scss/unicom.scss";
  5. init();
  6. function init() {
  7. compnt.showLoading();
  8. unicom.init().then(function(response) {
  9. compnt.hideLoading();
  10. unicom.setProduct(response.product[0]);
  11. unicom.setFesname(response.festival);
  12. bindCancel();
  13. unicom.queryStock(unicom.query.code).then(function(response) {
  14. compnt.hideLoading();
  15. switch (response.resultCode) {
  16. case "0000":
  17. bindOrder()
  18. bindSend()
  19. break;
  20. default:
  21. //bindOrder()
  22. //bindSend()
  23. var errorInfo = response.errorInfo + "<br>" + response.result_msg;
  24. errorInfo = errorInfo.replace('商品', '链接');
  25. compnt.showAlert(errorInfo, true);
  26. break;
  27. }
  28. });
  29. if (location.href.indexOf('/cancel') >= 0) {
  30. unicom.burypointLogId('110002');// 退订页面pv, pv去重得到uv
  31. } else if (location.href.indexOf('/draw') >= 0) {
  32. unicom.burypointLogId('110003');// 领取页面pv, pv去重得到uv
  33. } else if (location.href.indexOf('/flow') >= 0) {
  34. unicom.burypointLogId('110004');// 流量查询pv, pv去重得到uv
  35. } else if (location.href.indexOf('/active') >= 0) {
  36. unicom.burypointLogId('110005');// 激活页面pv, pv去重得到uv
  37. } else if (location.href.indexOf('/refund') >= 0) {
  38. unicom.burypointLogId('110006');// 退款
  39. } else {
  40. // location.href.indexOf('/index') >= 0
  41. // location.href.indexOf('/order') >= 0
  42. unicom.burypointLogId('110001');// 订购页面pv, pv去重得到uv
  43. }
  44. })
  45. }
  46. function bindSend() {
  47. // @ts-ignore
  48. let $container = $('.section-login').find('.form-group');
  49. $container.find('.sendcode').unbind('click').on('click', function () {
  50. unicom.sendSms($container, 'login');
  51. })
  52. }
  53. function bindOrder() {
  54. // @ts-ignore
  55. let $container = $('.section-login').find('.form-group');
  56. $container.find('.login').unbind('click').on('click', function () {
  57. compnt.showLoading();
  58. unicom.checkCode($container).then(function() {
  59. unicom.orderBack(unicom.query.code).then(function(response) {
  60. compnt.hideLoading();
  61. switch (response.resultCode) {
  62. case "0000":
  63. compnt.showAlert('领取成功,该链接已经失效').then(function() {
  64. window.location.reload();
  65. });
  66. break;
  67. case "1018": // 手机号领取过
  68. compnt.showAlert('领取失败,每个号码每月限领1次');
  69. break;
  70. case "1029": // 包含1、链接不存在;2、已经领取过;3、链接已经退费、4、已经失效
  71. compnt.showAlert('领取失败,请联系客服。该链接已失效。');
  72. break;
  73. default:
  74. let prefix = '';
  75. if (response.errorInfo.indexOf('订购失败') < 0) {
  76. prefix = '领取失败,';
  77. }
  78. // 温馨提示,您已领取成功,该链接已失效。
  79. response.errorInfo = response.errorInfo.replace('操作失败,', '');
  80. response.errorInfo = response.errorInfo.replace('订购', '领取');
  81. compnt.showAlert(prefix + response.errorInfo);
  82. break;
  83. }
  84. }).catch(function(data) {
  85. compnt.hideLoading();
  86. })
  87. }).catch(function(data) {
  88. compnt.hideLoading();
  89. })
  90. })
  91. }
  92. function bindCancel() {
  93. // @ts-ignore
  94. $("#btn-refund").attr('href', 'refund.html?fes=' + unicom.query.fes
  95. + '&sou=' + unicom.query.sou + '&code=' + unicom.query.code);
  96. }