| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- exports.ids = [7];
- exports.modules = {
- /***/ 144:
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
- "use strict";
- // ESM COMPAT FLAG
- __webpack_require__.r(__webpack_exports__);
- // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/count-down.vue?vue&type=template&id=2fbaab86&
- var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (_vm.time >= 0)?_c('div',[_c('client-only',[(_vm.isSlot)?_vm._t("default"):_c('span',[_vm._v(_vm._s(_vm.formateTime))])],2)],1):_vm._e()}
- var staticRenderFns = []
- // CONCATENATED MODULE: ./components/count-down.vue?vue&type=template&id=2fbaab86&
- // CONCATENATED MODULE: ./utils/parseTime.js
- const SECOND = 1000;
- const MINUTE = 60 * SECOND;
- const HOUR = 60 * MINUTE;
- const DAY = 24 * HOUR;
- function parseTimeData(time) {
- const days = Math.floor(time / DAY);
- const hours = sliceTwo(Math.floor(time % DAY / HOUR));
- const minutes = sliceTwo(Math.floor(time % HOUR / MINUTE));
- const seconds = sliceTwo(Math.floor(time % MINUTE / SECOND));
- return {
- days: days,
- hours: hours,
- minutes: minutes,
- seconds: seconds
- };
- }
- function sliceTwo(str) {
- return (0 + str.toString()).slice(-2);
- }
- function parseFormat(format, timeData) {
- let days = timeData.days;
- let hours = timeData.hours,
- minutes = timeData.minutes,
- seconds = timeData.seconds;
- if (format.indexOf('dd') !== -1) {
- format = format.replace('dd', days);
- }
- if (format.indexOf('hh') !== -1) {
- format = format.replace('hh', sliceTwo(hours));
- }
- if (format.indexOf('mm') !== -1) {
- format = format.replace('mm', sliceTwo(minutes));
- }
- if (format.indexOf('ss') !== -1) {
- format = format.replace('ss', sliceTwo(seconds));
- }
- return format;
- }
- // CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--2-0!./node_modules/@nuxt/components/dist/loader.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./components/count-down.vue?vue&type=script&lang=js&
- //
- //
- //
- //
- //
- //
- //
- //
- //
- /* harmony default export */ var count_downvue_type_script_lang_js_ = ({
- components: {},
- props: {
- isSlot: {
- type: Boolean,
- default: false
- },
- time: {
- type: Number,
- default: 0
- },
- format: {
- type: String,
- default: 'hh:mm:ss'
- },
- autoStart: {
- type: Boolean,
- default: true
- }
- },
- watch: {
- time: {
- immediate: true,
- handler(value) {
- if (value) {
- this.reset();
- }
- }
- }
- },
- data() {
- return {
- timeObj: {},
- formateTime: 0
- };
- },
- created() {},
- computed: {},
- methods: {
- createTimer(fn) {
- return setTimeout(fn, 100);
- },
- isSameSecond(time1, time2) {
- return Math.floor(time1) === Math.floor(time2);
- },
- start() {
- if (this.counting) {
- return;
- }
- this.counting = true;
- this.endTime = Date.now() + this.remain * 1000;
- this.setTimer();
- },
- setTimer() {
- this.tid = this.createTimer(() => {
- let remain = this.getRemain();
- if (!this.isSameSecond(remain, this.remain) || remain === 0) {
- this.setRemain(remain);
- }
- if (this.remain !== 0) {
- this.setTimer();
- }
- });
- },
- getRemain() {
- return Math.max(this.endTime - Date.now(), 0);
- },
- pause() {
- this.counting = false;
- clearTimeout(this.tid);
- },
- reset() {
- this.pause();
- this.remain = this.time;
- this.setRemain(this.remain);
- if (this.autoStart) {
- this.start();
- }
- },
- setRemain(remain) {
- const {
- format
- } = this;
- this.remain = remain;
- const timeData = parseTimeData(remain);
- this.formateTime = parseFormat(format, timeData);
- this.$emit('change', timeData);
- if (remain === 0) {
- this.pause();
- this.$emit('finish');
- }
- }
- }
- });
- // CONCATENATED MODULE: ./components/count-down.vue?vue&type=script&lang=js&
- /* harmony default export */ var components_count_downvue_type_script_lang_js_ = (count_downvue_type_script_lang_js_);
- // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
- var componentNormalizer = __webpack_require__(1);
- // CONCATENATED MODULE: ./components/count-down.vue
- function injectStyles (context) {
-
-
- }
- /* normalize component */
- var component = Object(componentNormalizer["a" /* default */])(
- components_count_downvue_type_script_lang_js_,
- render,
- staticRenderFns,
- false,
- injectStyles,
- null,
- "4090b4e2"
-
- )
- /* harmony default export */ var count_down = __webpack_exports__["default"] = (component.exports);
- /***/ })
- };;
- //# sourceMappingURL=count-down.js.map
|