refund.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. import * as compnt from "../../../public/js/compnt.js";
  2. import * as unicom from "../../../public/js/unicom.js";
  3. import "../../../public/scss/unicom.scss";
  4. import "../scss/womusic-refund.scss";
  5. let $captcha = null;
  6. init();
  7. function init() {
  8. compnt.showLoading();
  9. unicom.init().then(function(response) {
  10. compnt.hideLoading();
  11. unicom.setProduct(response.product[0]);
  12. unicom.setFesname(response.festival);
  13. $('#code').text(unicom.query.code);
  14. queryStock()
  15. if (location.href.indexOf('/cancel') >= 0) {
  16. unicom.burypointLogId('110002');// 退订页面pv, pv去重得到uv
  17. } else if (location.href.indexOf('/draw') >= 0) {
  18. unicom.burypointLogId('110003');// 领取页面pv, pv去重得到uv
  19. } else if (location.href.indexOf('/flow') >= 0) {
  20. unicom.burypointLogId('110004');// 流量查询pv, pv去重得到uv
  21. } else if (location.href.indexOf('/active') >= 0) {
  22. unicom.burypointLogId('110005');// 激活页面pv, pv去重得到uv
  23. } else {
  24. // location.href.indexOf('/index') >= 0
  25. // location.href.indexOf('/order') >= 0
  26. unicom.burypointLogId('110001');// 订购页面pv, pv去重得到uv
  27. }
  28. })
  29. };
  30. function queryStock() {
  31. unicom.queryStock(unicom.query.code).then(function(response) {
  32. compnt.hideLoading();
  33. switch (response.resultCode) {
  34. case "0000":
  35. bindRefund()
  36. bindCaptcha();
  37. break;
  38. default:
  39. $captcha && $captcha.refresh();
  40. unicom.product.captchaCode = null;
  41. $('#btn-refund').css('opacity', 0.5)
  42. var errorInfo = response.errorInfo + "<br>" + response.result_msg;
  43. errorInfo = errorInfo.replace('商品', '链接');
  44. compnt.showAlert(errorInfo, true);
  45. break;
  46. }
  47. });
  48. }
  49. function bindRefund() {
  50. $('#btn-refund').css('opacity', 0.5)
  51. $('#btn-refund').off('click').on('click', function() {
  52. let username = $('#username').val();
  53. let password = $('#password').val();
  54. if (username == null || username.trim() == '') {
  55. alert('请填写用户名');
  56. return;
  57. }
  58. if (password == null || password.trim() == '') {
  59. alert('请填写密码');
  60. return;
  61. }
  62. if (unicom.query.code == null || unicom.query.code.trim() == '') {
  63. alert('code参数错误');
  64. return;
  65. }
  66. if (unicom.product.captchaCode == null || unicom.product.captchaCode == '') {
  67. alert('请先完成滑动拼图')
  68. return;
  69. }
  70. unicom.refund(unicom.query.code, username, password).then(function(response) {
  71. // console.log(response.data)
  72. switch(response.resultCode) {
  73. case "0000":
  74. alert('操作成功,链接已经失效')
  75. window.location.reload();
  76. break;
  77. default:
  78. alert(response.errorInfo)
  79. $captcha.refresh();
  80. unicom.product.captchaCode = null;
  81. $('#btn-refund').css('opacity', 0.5)
  82. break;
  83. }
  84. }).catch(function() {
  85. });
  86. })
  87. }
  88. function bindCaptcha() {
  89. $captcha = $('#captcha').sliderCaptcha({
  90. width: 280,
  91. height: 150,
  92. sliderL: 42,
  93. sliderR: 9,
  94. offset: 5,
  95. loadingText: '正在加载中...',
  96. failedText: '再试一次',
  97. barText: '向右滑动填充拼图',
  98. repeatIcon: 'fa fa-redo',
  99. remoteUrl: unicom.root + "-s1api" + '/sliderCaptcha/verify',
  100. verifySuccess: function(data) {
  101. // console.log(data);
  102. unicom.product.captchaCode = data.captchaCode;
  103. },
  104. /*verify: function(arr, url) {
  105. var result = unicom.verifyCaptcha(arr);
  106. console.log(result)
  107. return result;
  108. },*/
  109. setSrc: function () {
  110. // alert('setSrc')
  111. },
  112. onSuccess: function () {
  113. // unicom.refund(unicom.query.code);
  114. $('#btn-refund').css('opacity', 1)
  115. },
  116. onFail: function () {
  117. // alert('onFail')
  118. $('#btn-refund').css('opacity', 0.5)
  119. },
  120. onRefresh: function () {
  121. // alert('onRefresh')
  122. }
  123. });
  124. }