about.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. require('./index.less');
  2. import Api from './helper/const';
  3. import Utils from './helper/utils';
  4. import './helper/response';
  5. // 时间
  6. let actEnd = false;
  7. let originPrice = 0;
  8. let price = 0;
  9. let name = ''
  10. $('#buy').on('click', () => {
  11. if (actEnd) return;
  12. window.location.href = `http://ott80-web.ai160.com/otttest/efunbox_xyyf/res/h5pay/index.html?op=${originPrice}&p=${price}&name=${name}`;
  13. // console.log(321,name)
  14. // window.location.href = `http://192.168.1.66:3000?op=${originPrice}&p=${price}&name=${name}`;
  15. });
  16. const timer = (endTime) => {
  17. setTimeout(() => {
  18. let curTime = new Date().getTime();
  19. let coutDown = Utils.setTimeAgo(endTime, curTime);
  20. document.getElementById('timer').innerHTML = coutDown;
  21. timer(endTime);
  22. }, 1000)
  23. }
  24. const getProduct = (orderId) => {
  25. // 获取商品还有时间
  26. $.ajax({
  27. url: Api.composeApiPath(`product/101001`),
  28. dataType: "json",
  29. async: true,
  30. type: "GET",
  31. success: function (res) {
  32. let endTime = res.data.endTime;
  33. let startTime = res.data.startTime;
  34. let curTime = new Date().getTime();
  35. // if(startTime - endTime )
  36. console.log(333, startTime - curTime)
  37. if (startTime - curTime > 0) {
  38. // 活动还未开始
  39. document.getElementById('buy').className += ' none';
  40. actEnd = true;
  41. $('.top').html('活动开始时间')
  42. $('#timer').html(Utils.formatTime(startTime))
  43. } else if (endTime - curTime < 0) {
  44. document.getElementById('buy').className += ' none';
  45. actEnd = true;
  46. } else {
  47. timer(endTime);
  48. originPrice = res.data.originalPrice;
  49. price = res.data.price;
  50. name = encodeURIComponent(res.data.title);
  51. console.log(123, name)
  52. }
  53. }
  54. });
  55. }
  56. getProduct()