/** * User: yongwang * Date: 12-01-17 * Time: 上午9:54 */ define(function(require,exports,module){ require("../../common/utils"); var Detail=require("./detail"); var PatList=require("./list"); function CountDown(){ this.options = { //countdown元素id countId : '', //outerCountId元素id outerCountId : '', //销售开始倒计时是否结束 isSellBeginEnd : false, //销售结束倒计时是否结束 isSellEndEnd : false, //销售开始时间点 sellBeginTimeStemp:null, //销售结束时间点 sellEndTimeStemp:null, //输入的服务器当前时间对象 currStemp:null, //销售开始倒计时时间结束点 以ms为单位 countDownBeginStemp:0,//ms //销售结束倒计时时间结束点 以ms为单位 countDownEndStemp:0,//ms type:0,//默认倒计时 1为商品销售倒计时 autStatus:null,//出价状态 00为未出价 01为出局 02为领先 minAmount:0,//当前最低价 validateCodeStats:null,//验证码验证状态 0为未验证 1为验证过 activityStatus:0,//活动状态 0有效 1结束 inputStatus:0,//输入状态 mdseDetailJson:null,//商品详情 rootPath:"",//链接根目录 isDutchEnd:false,//总倒计时已经结束 /** * 初始化倒计时 * @param currnt * @param end */ init : function(o){ this.countId = o.countId || 'CountDown'; this.outerCountId = o.outerCountId||''; this.rootPath=o.rootPath||''; this.sellBeginTimeStemp=o.sellBeginTimeStemp||null; this.sellEndTimeStemp=o.sellEndTimeStemp||null; this.currStemp=o.currStemp||null; if(o.mdseDetailJson){ this.mdseDetailJson=(new Function("","return "+o.mdseDetailJson))();; } if(this.currStemp){ this.currStemp=HP.parseDateMilliseconds(this.currStemp); }else{ console.error("传入的服务器时间不符合规则!请检查"); return; } if(this.sellBeginTimeStemp){ this.sellBeginTimeStemp=HP.parseDateMilliseconds(this.sellBeginTimeStemp); this.countDownBeginStemp=this.sellBeginTimeStemp- this.currStemp; }else{ console.error("传入的活动开始时间不符合规则!请检查"); return; } if(this.sellEndTimeStemp){ this.sellEndTimeStemp=HP.parseDateMilliseconds(this.sellEndTimeStemp); if(this.sellBeginTimeStemp<this.currStemp){ this.countDownEndStemp=this.sellEndTimeStemp- this.currStemp; }else{ this.countDownEndStemp=this.sellEndTimeStemp- this.sellBeginTimeStemp; } }else{ console.error("传入的活动结束时间不符合规则!请检查"); return; } //测试 //this.countDownEndStemp=0; this.type=o.type||0; this.validateCodeStats=o.validateCodeStats||0; this.autStatus=o.autStatus||"00"; this._CountDownLoop(); }, _CountDownLoop : function(){ if(this.activityStatus==1){ //转向抢拍结果页 Detail.gotoAuctionResult(this); } if(this.countDownBeginStemp<= 0){ this.isSellBeginEnd = true; } if(this.countDownEndStemp<= 0){ this.isSellEndEnd = true; } //如果结束则调用结束回调 if(this.isSellBeginEnd === true){ console.log('销售开始时间已经到了'); if(this.isSellEndEnd===true){ console.log('销售结束时间已经到了'); this._renderEndEnd(); return; }else{ //console.log('销售结束倒计时开始'); switch(this.type){ case 1: this._renderSellEnd(this.countDownEndStemp); break; case 2: this._renderSellEnd(this.countDownEndStemp); break; case 3: this._renderSellEnd(this.countDownEndStemp); break; default: this._renderSellEnd(this.countDownEndStemp); break; } } }else{ console.log('销售开始倒计时开始'); switch(this.type){ case 1: this._renderSellerGoods(this.countDownBeginStemp); break; case 2: this._renderSellerGoods(this.countDownBeginStemp); break; case 3: this._renderSellerGoods(this.countDownBeginStemp); break; default: this._renderSellerGoods(this.countDownBeginStemp); break; } } if(this.isDutchEnd===true){//已经完全结束 return; } var that=this; requestAnimation(function(){ that._CountDownLoop(); }); }, //活动开始倒计时方法 _renderSellerGoods:function(){ this.countDownBeginStemp=this.countDownBeginStemp-1000; var t =this.countDownBeginStemp; //小时 var remain_hour=parseInt(t/(1000*60*60)); if (remain_hour < 10){ remain_hour = "0" + remain_hour; } //分钟 var remain_minute=parseInt((t-(remain_hour*1000*60*60))/(1000*60)); if (remain_minute < 10){ remain_minute = "0" + remain_minute; } //秒数 var remain_sec=parseInt((t-(remain_hour*1000*60*60)-(remain_minute*1000*60))/1000); if (remain_sec < 10){ remain_sec = "0" + remain_sec; } if(this.type==0){//列表页处理 PatList.showListActNoCountDown(this,remain_hour,remain_minute,remain_sec); }else if(this.type==2){//详情页处理 Detail.showAuctStatus(this,null); Detail.actNoInfoShow(this); Detail.showAuctStatus(this,null); //提前10分钟显示验证码输入 //根据验证码状态显示验证码输入框 this.inputStatus=Detail.showValidateCodeInputBefore10Min(this); Detail.showDetailActNoCountDown(this,remain_hour,remain_minute,remain_sec); } }, //活动结束倒计时调用方法 _renderSellEnd:function(){ this.countDownEndStemp=this.countDownEndStemp-1000; var t = this.countDownEndStemp; //小时 var remain_hour=parseInt(t/(1000*60*60)); if (remain_hour < 10){ remain_hour = "0" + remain_hour; } //分钟 var remain_minute=parseInt((t-(remain_hour*1000*60*60))/(1000*60)); if (remain_minute < 10){ remain_minute = "0" + remain_minute; } //秒数 var remain_sec=parseInt((t-(remain_hour*1000*60*60)-(remain_minute*1000*60))/1000); if (remain_sec < 10){ remain_sec = "0" + remain_sec; } if(this.type==0){//列表页处理 PatList.showListActStartCountDown(this,remain_hour,remain_minute,remain_sec); //活动详情页 活动开始 出价列表 }else if(this.type==2){ //type==2为详情页使用 Detail.actStartInfoShow(this); //根据验证码状态显示验证码输入框 Detail.showValidateCodeInput(this); Detail.showAuctStatus(this,this.autStatus); Detail.showDetailActStartCountDown(this,remain_hour,remain_minute,remain_sec); Detail.setAuctionPriceListEnable(this); } }, //活动开始调用方法 _renderBeginEnd:function(){ this.isDutchEnd=true;//倒计时完全结束 if(this.type==0){//列表页处理 PatList.showListActNoEndCountDown(this); //活动详情页 活动未开始 出价列表 }else if(this.type==2){//type==2为详情页使用 Detail.showAuctStatus(this,null); Detail.showDetailActNoEndCountDown(this); Detail.setAuctionPriceListEnable(this); } }, _renderEndEnd:function(){ this.isDutchEnd=true;//倒计时完全结束 if(this.type==0){//列表页处理 PatList.showListActStartEndCountDown(this); //活动详情页 活动结束 }else if(this.type==2){ Detail.showAuctStatus(this,null); Detail.showDetailActStartEndCountDown(this); //type==2为详情页使用 出价列表 Detail.setAuctionPriceListDisable(this); } } }; }; var requestAnimation = (function(callback,time){ return function(callback,time) { if(time){ window.setTimeout(callback, time); }else{ window.setTimeout(callback, 1000); } }; })(); module.exports=CountDown; });
相关推荐
本文实例为大家分享了vue实现秒杀倒计时组件的具体代码,供大家参考,具体内容如下 下面是使用Vue实现秒杀倒计时组件 1.请求服务器获取这一刻的服务器时间(统一以服务器时间为基准) 2.获取用户当前电脑时间与...
vue实现秒杀倒计时组件.docx
教程名称: 尚硅谷Android视频教程《CountdownView秒杀倒计时》 CountdownView是Android中第三方的倒计时秒杀控件,在商城购物相关软件秒杀和倒计时中经常用到;它可以在ListView和RecyclerView中显示秒杀倒计时,...
主要介绍了vue 实现倒计时秒杀的组件,紧接着通过实例代码给大家介绍小程序或者vue商品秒杀倒计时功能,需要的朋友可以参考下
主要介绍了vue设计一个倒计时秒杀的组件,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
该资源在 ...这篇文章中介绍过,效果图部分代码都有讲解。 这个资源就是这篇文章的代码以及图片资源都有。 ...2.每个模块代码都有注释可...3.没有用到任何的组件,纯html+css+js编写。 4.适合于刚学习完js的人群去了解代码。
主要介绍了Android秒杀倒计时自定义TextView示例,大家参考使用吧
首先是这样一个场景,我的业务需要实现倒计时,倒计时你懂得,倒计时经常应用在预告一个活动的开始,像秒杀,像开售抢购等,或者活动的截止。 我们来梳理一下这个倒计时的功能: 定时更新时间,以秒为度; 可以...
功能: 适用于电商应用的限时团购、商品秒杀等 先来看下最终效果: git源:http://git.oschina.net/dotton/CountDown 分步骤-性子急的朋友,可以直接看最后那段代码。 wxml文件放个text <text>second: {{second}} ...
CountdownView是Android中第三方的倒计时秒杀控件,在商城购物相关软件秒杀和倒计时中经常用 到,它可以在ListView和RecyclerView中显示秒杀倒计时,滑动时候并且时间不会错乱,且性能良好
(3)使用BOM调用浏览器功能1次,例如页面滚动、秒杀倒计时、打印、通知、本地存储等。 (4)使用ECharts库(https://echarts.apache.org)实现数据可视化1次。使用Swiper框架(https://www.swiper.com.cn)实现轮播图1次。 ...
### 秒杀未开始(此时正在倒计时) ![秒杀未开始(此时正在倒计时)][26] ### 开始秒杀提示界面 ![开始秒杀提示界面][2] ### 秒杀结束提示界面 ![秒杀结束提示界面][3] ## 新建一个Maven项目 以IntelliJ IDEA...
4. 限时秒杀:独立秒杀中心、商品详情秒杀倒计时、自动开始结束 5. 优惠券:满减劵、折扣劵、注册送、用户领取、管理员发放 6. 报价单:商品报价单excel导出、在线打印、自定义字段及拖拽排序 7.
4. 限时秒杀:独立秒杀中心、商品详情秒杀倒计时、自动开始结束 5. 优惠券:满减劵、折扣劵、注册送、用户领取、管理员发放 6. 报价单:商品报价单excel导出、在线打印、自定义字段及拖拽排序 7. 商品相册标签:...
4. 限时秒杀:独立秒杀中心、产品概况秒杀倒计时、主动开端完毕 5. 优惠券:满减劵、扣头劵、注册送、用户收取、办理员发放 6. 报价单:产品报价单excel导出、在线打印、自定义字段及拖拽排序 7. 产品相册标签:...
4. 限时秒杀:独立秒杀中心、产品概况秒杀倒计时、主动开端完毕 5. 优惠券:满减劵、扣头劵、注册送、用户收取、办理员发放 6. 报价单:产品报价单excel导出、在线打印、自定义字段及拖拽排序 7. 产品相册标签:...
(3)使用BOM调用浏览器功能1次,例如页面滚动、秒杀倒计时、打印、通知、本地存储等。 (4)使用ECharts库(https://echarts.apache.org)实现数据可视化1次。使用Swiper框架(https://www.swiper.com.cn)实现轮播图1次。 ...