import * as compnt from "../../../public/js/compnt.js"; import * as unicom from "../../../public/js/unicom.js"; import "../scss/womusic.scss"; import "../../../public/scss/unicom.scss"; init(); function init() { compnt.showLoading(); unicom.init().then(function(response) { compnt.hideLoading(); unicom.setProduct(response.data.product[0]); unicom.setFesname(response.data.festival); bindCancel(); unicom.queryStock(unicom.query.code).then(function(response) { compnt.hideLoading(); switch (response.data.resultCode) { case "0000": bindOrder() bindLogin() break; default: var errorInfo = response.data.errorInfo + "
" + response.data.result_msg; errorInfo = errorInfo.replace('商品', '链接'); /* * result_msg: "已领取" resultCode: "1029" errorInfo: "该商品已失效!" result_code: "2" */ if (response.data.result_code == '2' && response.data.resultCode == '1029') { errorInfo = '您已领取成功,该链接已失效。'; } compnt.showAlert(errorInfo, true); break; } }); }) } function bindLogin() { let $container = $('.section-login').find('.form-group'); $container.find('.sendcode').unbind('click').on('click', function () { unicom.sendSms($container, 'orderlogin');//705 }) } function bindOrder() { let $container = $('.section-login').find('.form-group'); $container.find('.login').unbind('click').on('click', function () { compnt.showLoading(); unicom.checkCode($container).then(function() { unicom.orderBack(unicom.query.code).then(function(response) { compnt.hideLoading(); switch (response.data.resultCode) { case "0000": compnt.showAlert('领取成功'); window.location.reload(); break; default: let prefix = ''; if (response.data.errorInfo.indexOf('订购失败') < 0) { prefix = '领取失败,'; } response.data.errorInfo = response.data.errorInfo.replace('操作失败,', ''); response.data.errorInfo = response.data.errorInfo.replace('订购', '领取'); compnt.showAlert(prefix + response.data.errorInfo); break; } }).catch(function(data) { compnt.hideLoading(); }) }).catch(function(data) { compnt.hideLoading(); }) }) } function bindCancel() { $("#btn-refund").attr('href', 'refund.html?fes=' + unicom.query.fes + '&sou=' + unicom.query.sou + '&code=' + unicom.query.code); }