123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- import * as compnt from "../../../public/js/compnt.js";
- import * as unicom from "../../../public/js/unicom.js";
- import "../../../public/scss/unicom.scss";
- import "../scss/womusic-refund.scss";
- let $captcha = null;
- init();
- function init() {
- compnt.showLoading();
- unicom.init().then(function(response) {
- compnt.hideLoading();
- unicom.setProduct(response.data.product[0]);
- unicom.setFesname(response.data.festival);
- $('#code').text(unicom.query.code);
- queryStock()
- })
- };
- function queryStock() {
-
- unicom.queryStock(unicom.query.code).then(function(response) {
- compnt.hideLoading();
- switch (response.data.resultCode) {
- case "0000":
- bindRefund()
- bindCaptcha();
- break;
- default:
- $captcha && $captcha.refresh();
- unicom.product.captchaCode = null;
- $('#btn-refund').css('opacity', 0.5)
- var errorInfo = response.data.errorInfo + "<br>" + response.data.result_msg;
- errorInfo = errorInfo.replace('商品', '链接');
- compnt.showAlert(errorInfo, true);
- break;
- }
- });
- }
- function bindRefund() {
- $('#btn-refund').css('opacity', 0.5)
- $('#btn-refund').off('click').on('click', function() {
- let username = $('#username').val();
- let password = $('#password').val();
- if (username == null || username.trim() == '') {
- alert('请填写用户名');
- return;
- }
- if (password == null || password.trim() == '') {
- alert('请填写密码');
- return;
- }
- if (unicom.query.code == null || unicom.query.code.trim() == '') {
- alert('code参数错误');
- return;
- }
- if (unicom.product.captchaCode == null || unicom.product.captchaCode == '') {
- alert('请先完成滑动拼图')
- return;
- }
- unicom.refund(unicom.query.code, username, password).then(function(response) {
- switch(response.data.resultCode) {
- case "0000":
- alert('操作成功,链接已经失效')
-
- window.location.reload();
- break;
- default:
- alert(response.data.errorInfo)
- $captcha.refresh();
- unicom.product.captchaCode = null;
- $('#btn-refund').css('opacity', 0.5)
- break;
- }
- }).catch(function(e) {
- });
- })
- }
- function bindCaptcha() {
- $captcha = $('#captcha').sliderCaptcha({
- width: 280,
- height: 150,
- sliderL: 42,
- sliderR: 9,
- offset: 5,
- loadingText: '正在加载中...',
- failedText: '再试一次',
- barText: '向右滑动填充拼图',
- repeatIcon: 'fa fa-redo',
- remoteUrl: unicom.root + "-s1api" + '/sliderCaptcha/verify',
- verifySuccess: function(data) {
- // console.log(data);
- unicom.product.captchaCode = data.captchaCode;
- },
- /*verify: function(arr, url) {
- var result = unicom.verifyCaptcha(arr);
- console.log(result)
- return result;
- },*/
- setSrc: function () {
- // alert('setSrc')
- },
- onSuccess: function () {
- // unicom.refund(unicom.query.code);
- $('#btn-refund').css('opacity', 1)
- },
- onFail: function () {
- // alert('onFail')
- $('#btn-refund').css('opacity', 0.5)
- },
- onRefresh: function () {
- // alert('onRefresh')
- }
- });
- }
|