about.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 curTime = new Date().getTime();
  34. if (endTime - curTime < 0) {
  35. document.getElementById('buy').className += ' none';
  36. actEnd = true;
  37. } else {
  38. timer(endTime);
  39. originPrice = res.data.originalPrice;
  40. price = res.data.price;
  41. name = encodeURIComponent(res.data.title);
  42. console.log(123, name)
  43. }
  44. }
  45. });
  46. }
  47. getProduct()