index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. $(function (event) {
  2. var x = document.getElementById("mediaId");
  3. var x2 = document.getElementById("mediaShow");
  4. function play() {
  5. x.play();
  6. x.muted = false
  7. }
  8. x2.pause();
  9. x2.muted = true
  10. function playShow() {
  11. x.pause();
  12. x.muted = true
  13. x2.play();
  14. x2.muted = false
  15. }
  16. var stopStep = 1;
  17. var runT = null;
  18. var step = -1;
  19. var during = 2;
  20. $("#choujiang").click(function (event) {
  21. play()
  22. stopStep = 5
  23. runT = setTimeout(runF, 100);
  24. });
  25. function choice(number) {
  26. if (number == 1) {
  27. alert("香水");
  28. }
  29. if (number == 2) {
  30. alert("帽子");
  31. }
  32. if (number == 3) {
  33. alert("再接再厉哟");
  34. }
  35. if (number == 4) {
  36. alert("华为p20");
  37. }
  38. if (number == 5) {
  39. $('#photoBody').hide()
  40. $('#hongbao').show()
  41. playShow()
  42. // alert("5元话费");
  43. }
  44. if (number == 6) {
  45. alert("剃须刀");
  46. }
  47. if (number == 7) {
  48. alert("明日再战");
  49. }
  50. if (number == 8) {
  51. alert("短柄伞");
  52. }
  53. }
  54. function runF() {
  55. if (step >= (32 + stopStep)) {
  56. $(".gift" + (step % 8)).addClass("back");
  57. step = stopStep;
  58. choice(step);
  59. clearTimeout(runT);
  60. return;
  61. }
  62. if (step >= (24 + stopStep)) {
  63. during += 1;
  64. } else {
  65. if (during <= 2) {
  66. during = 2;
  67. }
  68. during--;
  69. }
  70. step++;
  71. $(".gift").each(function (index, element) {
  72. $(this).removeClass("back");
  73. });
  74. $(".gift" + (step % 8)).addClass("back");
  75. runT = setTimeout(runF, during * 50);
  76. }
  77. });