12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- require('./index.less');
- import Api from './helper/const';
- import Utils from './helper/utils';
- import './helper/response';
- // 时间
- let actEnd = false;
- let originPrice = 0;
- let price = 0;
- let name = ''
- $('#buy').on('click', () => {
- if (actEnd) return;
- window.location.href = `http://ott80-web.ai160.com/otttest/efunbox_xyyf/res/h5pay/index.html?op=${originPrice}&p=${price}&name=${name}`;
- // console.log(321,name)
- // window.location.href = `http://192.168.1.66:3000?op=${originPrice}&p=${price}&name=${name}`;
- });
- const timer = (endTime) => {
- setTimeout(() => {
- let curTime = new Date().getTime();
- let coutDown = Utils.setTimeAgo(endTime, curTime);
- document.getElementById('timer').innerHTML = coutDown;
- timer(endTime);
- }, 1000)
- }
- const getProduct = (orderId) => {
- // 获取商品还有时间
- $.ajax({
- url: Api.composeApiPath(`product/101001`),
- dataType: "json",
- async: true,
- type: "GET",
- success: function (res) {
- let endTime = res.data.endTime;
- let startTime = res.data.startTime;
- let curTime = new Date().getTime();
- // if(startTime - endTime )
- console.log(333, startTime - curTime)
- if (startTime - curTime > 0) {
- // 活动还未开始
- document.getElementById('buy').className += ' none';
- actEnd = true;
- $('.top').html('活动开始时间')
- $('#timer').html(Utils.formatTime(startTime))
- } else if (endTime - curTime < 0) {
- document.getElementById('buy').className += ' none';
- actEnd = true;
- } else {
- timer(endTime);
- originPrice = res.data.originalPrice;
- price = res.data.price;
- name = encodeURIComponent(res.data.title);
- console.log(123, name)
- }
- }
- });
- }
- getProduct()
|