gift-detail.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. $(function () {
  2. $("#J_recommend_gift").load('/Layout/recommendGiftList');
  3. $(".public_nav li").removeClass('current_page').eq(2).addClass('current_page')
  4. });
  5. // 复制礼包码
  6. $(".copy1").click(function () {
  7. var code = document.getElementById("gift_code").innerText;
  8. var oInput = document.createElement('input');
  9. oInput.value = code;
  10. document.body.appendChild(oInput);
  11. oInput.select(); // 选择对象
  12. document.execCommand("Copy"); // 执行浏览器复制命令
  13. oInput.className = 'oInput';
  14. oInput.style.display = 'none';
  15. layer.msg('复制成功', { offset: '300px' });
  16. })
  17. $(".copy2").click(function () {
  18. var coded = document.getElementById("gift_coded").innerText;
  19. var oInpute = document.createElement('input');
  20. oInpute.value = coded;
  21. document.body.appendChild(oInpute);
  22. oInpute.select(); // 选择对象
  23. document.execCommand("Copy"); // 执行浏览器复制命令
  24. oInpute.className = 'oInput';
  25. oInpute.style.display = 'none';
  26. layer.msg('复制成功', { offset: '300px' });
  27. })
  28. function receiveGift(id) {
  29. $.ajax({
  30. type: "POST",
  31. timeOut: 10000,
  32. url: '/gift/receiveGift',
  33. data: {
  34. "id": id
  35. },
  36. async: false,
  37. success: function (res) {
  38. // console.log(res);
  39. if (res.code == 1) {
  40. $('#gift_code').text(res.data);
  41. $("#gift_code_ing").show();
  42. } else if (res.code == 2) {
  43. $('#gift_coded').text(res.data);
  44. $("#gift_code_ed").show();
  45. } else if (res.code == -1) {
  46. $("#expire").show();
  47. } else if (res.code == -2) {
  48. $("#finished").show();
  49. } else if (res.code == -3) {
  50. window.location.href = res.data;
  51. } else {
  52. alert(res.msg);
  53. }
  54. },
  55. error: function () {
  56. layer.msg('网络错误,请刷新页面重试');
  57. }
  58. });
  59. }