普兆健康管家前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

131 lines
2.7 KiB

  1. <template>
  2. <view class="card">
  3. <image class="card-bg" :src="data.url" mode="scaleToFill"></image>
  4. <view class="flex card-bar">
  5. <uv-count-down
  6. v-if="time"
  7. :time="time"
  8. format="DD:HH:mm:ss"
  9. autoStart
  10. millisecond
  11. @change="onChange">
  12. <view class="flex countdown">
  13. 距开始<text class="count">{{ timeData.days }}</text>
  14. <text class="count">{{ timeData.hours>10?timeData.hours:'0'+timeData.hours}}</text>:<text class="count">{{ timeData.minutes }}</text>:<text class="count">{{ timeData.seconds }}</text>
  15. </view>
  16. </uv-count-down>
  17. <button class="flex btn">进入直播间</button>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import dayjs from "dayjs";
  23. import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'
  24. dayjs.extend(isSameOrBefore);
  25. export default {
  26. props: {
  27. data: {
  28. type: Object,
  29. default() {
  30. return {}
  31. }
  32. }
  33. },
  34. data() {
  35. return {
  36. time: null,
  37. timeData: {}
  38. }
  39. },
  40. watch: {
  41. data: {
  42. handler() {
  43. this.updateCountdown()
  44. },
  45. immediate: true,
  46. deep: true,
  47. }
  48. },
  49. methods: {
  50. onChange(e) {
  51. this.timeData = e
  52. },
  53. updateCountdown() {
  54. let current = dayjs()
  55. let startTime = dayjs(this.data.startTime)
  56. if (startTime.isSameOrBefore(current)) {
  57. this.time = null
  58. return
  59. }
  60. this.time = startTime.diff(current, 'millisecond')
  61. },
  62. },
  63. }
  64. </script>
  65. <style scoped lang="scss">
  66. .card {
  67. position: relative;
  68. width: 100%;
  69. height: 316rpx;
  70. border-radius: 40rpx;
  71. overflow: hidden;
  72. box-shadow: -5rpx -5rpx 10rpx 0 #FFFFFF,
  73. 10rpx 10rpx 20rpx 0 #AAAACC80,
  74. 4rpx 4rpx 10rpx 0 #AAAACC40,
  75. -2rpx -2rpx 5rpx 0 #FFFFFF;
  76. &-bg {
  77. width: 100%;
  78. height: 100%;
  79. }
  80. &-bar {
  81. justify-content: space-between;
  82. position: absolute;
  83. left: 0;
  84. bottom: 0;
  85. width: 100%;
  86. padding: 13rpx 32rpx;
  87. background: #FFFFFF69;
  88. box-sizing: border-box;
  89. .countdown {
  90. font-family: PingFang SC;
  91. font-weight: 400;
  92. font-size: 28rpx;
  93. line-height: 1.4;
  94. color: #252545;
  95. .count {
  96. margin: 0 8rpx;
  97. display: inline-flex;
  98. align-items: center;
  99. justify-content: center;
  100. min-width: 40rpx;
  101. height: 40rpx;
  102. background: #0000002B;
  103. border-radius: 8rpx;
  104. }
  105. }
  106. .btn {
  107. font-family: PingFang SC;
  108. font-weight: 600;
  109. font-size: 24rpx;
  110. line-height: 1.5;
  111. color: #252545;
  112. padding: 7rpx 16rpx;
  113. border-radius: 24rpx;
  114. background: #FFFFFF;
  115. }
  116. }
  117. }
  118. </style>