h5-countdown.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div :class="config.classText.join(' ')">
  3. <div class="countdown2-box"
  4. :style="{ backgroundImage: config.bgImage && config.bgImage !== '#' ? `url(${config.bgImage})` : '' }"
  5. >
  6. 距结束<span id="days" :style="{background: config.mainColor}">{{ config.days }}</span>天
  7. <span id="hours" :style="{background: config.mainColor}">{{ config.hours }}</span>时
  8. <span id="minutes" :style="{background: config.mainColor}">{{ config.minutes }}</span>分
  9. <span id="seconds" :style="{background: config.mainColor}">{{ config.seconds }}</span>秒
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'h5-countdown',
  16. props: {
  17. config: {
  18. type: Object,
  19. default: () => {
  20. return {
  21. days: 'x',
  22. hours: 'x',
  23. minutes: 'x',
  24. seconds: 'x',
  25. classText: ['active'],
  26. bgImage: '#',
  27. mainColor:''
  28. }
  29. }
  30. }
  31. },
  32. watch:{
  33. 'config.bgImage':{
  34. handler(val){
  35. console.info('bgImage change:',val)
  36. },
  37. deep:true
  38. }
  39. },
  40. created() {
  41. console.info('h5-text loaded:', this.config)
  42. }
  43. }
  44. </script>
  45. <style src="./css/base.css"></style>
  46. <style lang="scss" scoped>
  47. p {
  48. white-space: pre-line;
  49. }
  50. .active {
  51. border-color: #02ff9b;
  52. }
  53. .countdown2-box {
  54. background: url('#') no-repeat center;
  55. background-size: 100%;
  56. width: 100%;
  57. height: 54px;
  58. line-height: 54px;
  59. color: #515A6E;
  60. font-size: 14px;
  61. text-align: center;
  62. }
  63. .countdown2-box span {
  64. display: inline-block;
  65. color: #fff;
  66. width: 22px;
  67. line-height: 20px;
  68. text-align: center;
  69. height: 20px;
  70. border-radius: 3px;
  71. margin: 7px;
  72. background: #FF5A29;
  73. }
  74. </style>