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.product[0]); unicom.setFesname(response.festival); $('#code').text(unicom.query.code); queryStock() if (location.href.indexOf('/cancel') >= 0) { unicom.burypointLogId('110002');// 退订页面pv, pv去重得到uv } else if (location.href.indexOf('/draw') >= 0) { unicom.burypointLogId('110003');// 领取页面pv, pv去重得到uv } else if (location.href.indexOf('/flow') >= 0) { unicom.burypointLogId('110004');// 流量查询pv, pv去重得到uv } else if (location.href.indexOf('/active') >= 0) { unicom.burypointLogId('110005');// 激活页面pv, pv去重得到uv } else { // location.href.indexOf('/index') >= 0 // location.href.indexOf('/order') >= 0 unicom.burypointLogId('110001');// 订购页面pv, pv去重得到uv } }) }; function queryStock() { unicom.queryStock(unicom.query.code).then(function(response) { compnt.hideLoading(); switch (response.resultCode) { case "0000": bindRefund() bindCaptcha(); break; default: $captcha && $captcha.refresh(); unicom.product.captchaCode = null; $('#btn-refund').css('opacity', 0.5) var errorInfo = response.errorInfo + "
" + response.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) { // console.log(response.data) switch(response.resultCode) { case "0000": alert('操作成功,链接已经失效') window.location.reload(); break; default: alert(response.errorInfo) $captcha.refresh(); unicom.product.captchaCode = null; $('#btn-refund').css('opacity', 0.5) break; } }).catch(function() { }); }) } 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') } }); }