$(function () { $("#J_recommend_gift").load('/Layout/recommendGiftList'); $(".public_nav li").removeClass('current_page').eq(2).addClass('current_page') }); // 复制礼包码 $(".copy1").click(function () { var code = document.getElementById("gift_code").innerText; var oInput = document.createElement('input'); oInput.value = code; document.body.appendChild(oInput); oInput.select(); // 选择对象 document.execCommand("Copy"); // 执行浏览器复制命令 oInput.className = 'oInput'; oInput.style.display = 'none'; layer.msg('复制成功', { offset: '300px' }); }) $(".copy2").click(function () { var coded = document.getElementById("gift_coded").innerText; var oInpute = document.createElement('input'); oInpute.value = coded; document.body.appendChild(oInpute); oInpute.select(); // 选择对象 document.execCommand("Copy"); // 执行浏览器复制命令 oInpute.className = 'oInput'; oInpute.style.display = 'none'; layer.msg('复制成功', { offset: '300px' }); }) function receiveGift(id) { $.ajax({ type: "POST", timeOut: 10000, url: '/gift/receiveGift', data: { "id": id }, async: false, success: function (res) { // console.log(res); if (res.code == 1) { $('#gift_code').text(res.data); $("#gift_code_ing").show(); } else if (res.code == 2) { $('#gift_coded').text(res.data); $("#gift_code_ed").show(); } else if (res.code == -1) { $("#expire").show(); } else if (res.code == -2) { $("#finished").show(); } else if (res.code == -3) { window.location.href = res.data; } else { alert(res.msg); } }, error: function () { layer.msg('网络错误,请刷新页面重试'); } }); }