s-count-down.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const _sfc_main = {
  4. name: "countDown",
  5. props: {
  6. justifyLeft: {
  7. type: String,
  8. default: ""
  9. },
  10. //距离开始提示文字
  11. tipText: {
  12. type: String,
  13. default: "倒计时"
  14. },
  15. dayText: {
  16. type: String,
  17. default: "天"
  18. },
  19. hourText: {
  20. type: String,
  21. default: "时"
  22. },
  23. minuteText: {
  24. type: String,
  25. default: "分"
  26. },
  27. secondText: {
  28. type: String,
  29. default: "秒"
  30. },
  31. datatime: {
  32. type: Number,
  33. default: 0
  34. },
  35. isDay: {
  36. type: Boolean,
  37. default: true
  38. },
  39. isCol: {
  40. type: Boolean,
  41. default: false
  42. },
  43. bgColor: {
  44. type: Object,
  45. default: null
  46. }
  47. },
  48. data: function() {
  49. return {
  50. day: "00",
  51. hour: "00",
  52. minute: "00",
  53. second: "00"
  54. };
  55. },
  56. created: function() {
  57. this.show_time();
  58. },
  59. mounted: function() {
  60. },
  61. methods: {
  62. show_time: function() {
  63. let that = this;
  64. function runTime() {
  65. let intDiff = that.datatime - Date.parse(/* @__PURE__ */ new Date()) / 1e3;
  66. let day = 0, hour = 0, minute = 0, second = 0;
  67. if (intDiff > 0) {
  68. if (that.isDay === true) {
  69. day = Math.floor(intDiff / (60 * 60 * 24));
  70. } else {
  71. day = 0;
  72. }
  73. hour = Math.floor(intDiff / (60 * 60)) - day * 24;
  74. minute = Math.floor(intDiff / 60) - day * 24 * 60 - hour * 60;
  75. second = Math.floor(intDiff) - day * 24 * 60 * 60 - hour * 60 * 60 - minute * 60;
  76. if (hour <= 9)
  77. hour = "0" + hour;
  78. if (minute <= 9)
  79. minute = "0" + minute;
  80. if (second <= 9)
  81. second = "0" + second;
  82. that.day = day;
  83. that.hour = hour;
  84. that.minute = minute;
  85. that.second = second;
  86. } else {
  87. that.day = "00";
  88. that.hour = "00";
  89. that.minute = "00";
  90. that.second = "00";
  91. }
  92. }
  93. runTime();
  94. setInterval(runTime, 1e3);
  95. }
  96. }
  97. };
  98. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  99. return common_vendor.e({
  100. a: $props.tipText
  101. }, $props.tipText ? {
  102. b: common_vendor.t($props.tipText)
  103. } : {}, {
  104. c: $props.isDay === true
  105. }, $props.isDay === true ? {
  106. d: common_vendor.t(_ctx.day),
  107. e: common_vendor.t($props.bgColor.isDay ? "天" : ""),
  108. f: $props.bgColor.bgColor,
  109. g: $props.bgColor.Color
  110. } : {}, {
  111. h: $props.dayText
  112. }, $props.dayText ? {
  113. i: common_vendor.t($props.dayText),
  114. j: $props.bgColor.timeTxtwidth,
  115. k: $props.bgColor.bgColor
  116. } : {}, {
  117. l: common_vendor.t(_ctx.hour),
  118. m: common_vendor.n($props.isCol ? "timeCol" : ""),
  119. n: $props.bgColor.bgColor,
  120. o: $props.bgColor.Color,
  121. p: $props.bgColor.width,
  122. q: $props.hourText
  123. }, $props.hourText ? {
  124. r: common_vendor.t($props.hourText),
  125. s: common_vendor.n($props.isCol ? "whit" : ""),
  126. t: $props.bgColor.timeTxtwidth,
  127. v: $props.bgColor.bgColor
  128. } : {}, {
  129. w: common_vendor.t(_ctx.minute),
  130. x: common_vendor.n($props.isCol ? "timeCol" : ""),
  131. y: $props.bgColor.bgColor,
  132. z: $props.bgColor.Color,
  133. A: $props.bgColor.width,
  134. B: $props.minuteText
  135. }, $props.minuteText ? {
  136. C: common_vendor.t($props.minuteText),
  137. D: common_vendor.n($props.isCol ? "whit" : ""),
  138. E: $props.bgColor.timeTxtwidth,
  139. F: $props.bgColor.bgColor
  140. } : {}, {
  141. G: common_vendor.t(_ctx.second),
  142. H: common_vendor.n($props.isCol ? "timeCol" : ""),
  143. I: $props.bgColor.bgColor,
  144. J: $props.bgColor.Color,
  145. K: $props.bgColor.width,
  146. L: $props.secondText
  147. }, $props.secondText ? {
  148. M: common_vendor.t($props.secondText)
  149. } : {}, {
  150. N: common_vendor.s($props.justifyLeft)
  151. });
  152. }
  153. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-39f8fd44"], ["__file", "D:/zx/mall-front-app/sheep/components/s-count-down/s-count-down.vue"]]);
  154. wx.createComponent(Component);