womusic-refund.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.data.product[0]);
  12. unicom.setFesname(response.data.festival);
  13. $('#code').text(unicom.query.code);
  14. queryStock()
  15. })
  16. };
  17. function queryStock() {
  18. unicom.queryStock(unicom.query.code).then(function(response) {
  19. compnt.hideLoading();
  20. switch (response.data.resultCode) {
  21. case "0000":
  22. bindRefund()
  23. bindCaptcha();
  24. break;
  25. default:
  26. $captcha && $captcha.refresh();
  27. unicom.product.captchaCode = null;
  28. $('#btn-refund').css('opacity', 0.5)
  29. var errorInfo = response.data.errorInfo + "<br>" + response.data.result_msg;
  30. errorInfo = errorInfo.replace('商品', '链接');
  31. compnt.showAlert(errorInfo, true);
  32. break;
  33. }
  34. });
  35. }
  36. function bindRefund() {
  37. $('#btn-refund').css('opacity', 0.5)
  38. $('#btn-refund').off('click').on('click', function() {
  39. let username = $('#username').val();
  40. let password = $('#password').val();
  41. if (username == null || username.trim() == '') {
  42. alert('请填写用户名');
  43. return;
  44. }
  45. if (password == null || password.trim() == '') {
  46. alert('请填写密码');
  47. return;
  48. }
  49. if (unicom.query.code == null || unicom.query.code.trim() == '') {
  50. alert('code参数错误');
  51. return;
  52. }
  53. if (unicom.product.captchaCode == null || unicom.product.captchaCode == '') {
  54. alert('请先完成滑动拼图')
  55. return;
  56. }
  57. unicom.refund(unicom.query.code, username, password).then(function(response) {
  58. switch(response.data.resultCode) {
  59. case "0000":
  60. alert('操作成功,链接已经失效')
  61. window.location.reload();
  62. break;
  63. default:
  64. alert(response.data.errorInfo)
  65. $captcha.refresh();
  66. unicom.product.captchaCode = null;
  67. $('#btn-refund').css('opacity', 0.5)
  68. break;
  69. }
  70. }).catch(function(e) {
  71. });
  72. })
  73. }
  74. function bindCaptcha() {
  75. $captcha = $('#captcha').sliderCaptcha({
  76. width: 280,
  77. height: 150,
  78. sliderL: 42,
  79. sliderR: 9,
  80. offset: 5,
  81. loadingText: '正在加载中...',
  82. failedText: '再试一次',
  83. barText: '向右滑动填充拼图',
  84. repeatIcon: 'fa fa-redo',
  85. remoteUrl: unicom.root + "-s1api" + '/sliderCaptcha/verify',
  86. verifySuccess: function(data) {
  87. // console.log(data);
  88. unicom.product.captchaCode = data.captchaCode;
  89. },
  90. /*verify: function(arr, url) {
  91. var result = unicom.verifyCaptcha(arr);
  92. console.log(result)
  93. return result;
  94. },*/
  95. setSrc: function () {
  96. // alert('setSrc')
  97. },
  98. onSuccess: function () {
  99. // unicom.refund(unicom.query.code);
  100. $('#btn-refund').css('opacity', 1)
  101. },
  102. onFail: function () {
  103. // alert('onFail')
  104. $('#btn-refund').css('opacity', 0.5)
  105. },
  106. onRefresh: function () {
  107. // alert('onRefresh')
  108. }
  109. });
  110. }