-
Notifications
You must be signed in to change notification settings - Fork 557
/
Copy pathindex.js
2 lines (2 loc) · 3.07 KB
/
index.js
1
2
/*! vue-ydui v1.2.7 by YDCSS (c) 2019 Licensed MIT */
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ydui=e():t.ydui=e()}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={exports:{},id:i,loaded:!1};return t[i].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="/dist/",e(0)}({0:function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.CountDown=void 0;var o=n(164),r=i(o);e.CountDown=r.default},1:function(t,e){t.exports=function(t,e,n,i){var o,r=t=t||{},s=typeof t.default;"object"!==s&&"function"!==s||(o=t,r=t.default);var a="function"==typeof r?r.options:r;if(e&&(a.render=e.render,a.staticRenderFns=e.staticRenderFns),n&&(a._scopeId=n),i){var u=a.computed||(a.computed={});Object.keys(i).forEach(function(t){var e=i[t];u[t]=function(){return e}})}return{esModule:o,exports:r,options:a}}},47:function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default={name:"yd-countdown",data:function(){return{str:"",timer:null,tempFormat:"",showTpl:!0}},props:{time:{type:[String,Number,Date]},format:{type:String,default:"{%d}天{%h}时{%m}分{%s}秒"},timetype:{validator:function(t){return["datetime","second","timestamp"].indexOf(t)>-1},default:"datetime"},callback:{type:Function},doneText:{type:String,default:"已结束"}},watch:{time:function(t){clearInterval(this.timer),t&&this.run()}},methods:{run:function(){this.time&&("second"===this.timetype?this.lastTime=Math.floor(new Date/1e3)+~~this.time:"timestamp"===this.timetype?this.lastTime=Math.floor(new Date(this.time).getTime()):this.lastTime=Math.floor(new Date(this.time).getTime()/1e3),this.time instanceof Date&&(this.lastTime=Math.floor(this.time.getTime()/1e3)),this.doRun(),this.timer=setInterval(this.doRun,1e3))},doRun:function(){var t=this.lastTime-Math.floor((new Date).getTime()/1e3);t>0?this.str=this.timestampTotime(t):(this.callback&&this.callback(),this.str=this.doneText,clearInterval(this.timer))},timestampTotime:function(t){var e=this.tempFormat,n={};n.s=t%60,t=Math.floor(t/60),n.m=t%60,t=Math.floor(t/60),n.h=t%24,n.d=Math.floor(t/24);var i=function(t){return t<=0?"00":t<10?"0"+t:t},o=["d","h","m","s"];return o.forEach(function(t){var o=i(n[t]).toString().split("");e=e.replace("{%"+t+"}",i(n[t])),e=e.replace("{%"+t+"0}",0!==~~o[o.length-3]?o[o.length-3]:""),e=e.replace("{%"+t+"1}",~~o[o.length-2]),e=e.replace("{%"+t+"2}",~~o[o.length-1])}),e}},mounted:function(){var t=this;this.$nextTick(function(){t.tempFormat=t.$slots.default?t.$refs.tpl.innerHTML:t.format,t.showTpl=!1,t.run()})},beforeDestroy:function(){clearInterval(this.timer)}}},164:function(t,e,n){var i=n(1)(n(47),n(261),null,null);t.exports=i.exports},261:function(t,e){t.exports={render:function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("span",[n("span",{domProps:{innerHTML:t._s(t.str)}}),t._v(" "),t.showTpl?n("span",{ref:"tpl"},[t._t("default")],2):t._e()])},staticRenderFns:[]}}})});