countdown.nvue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <view>
  3. <text class="example-info">倒计时组件主要用于促销商品剩余时间,发送短信验证等待时间等场景</text>
  4. <uni-section title="一般用法" type="line"></uni-section>
  5. <view class="example-body">
  6. <uni-countdown :day="1" :hour="1" :minute="12" :second="40" />
  7. </view>
  8. <uni-section title="不显示天数" type="line"></uni-section>
  9. <view class="example-body">
  10. <uni-countdown :show-day="false" :hour="12" :minute="12" :second="12" />
  11. </view>
  12. <uni-section title="文字分隔符" type="line"></uni-section>
  13. <view class="example-body">
  14. <uni-countdown :minute="30" :second="0" :show-colon="false" />
  15. </view>
  16. <uni-section title="修改颜色" type="line"></uni-section>
  17. <view class="example-body">
  18. <uni-countdown :day="1" :hour="2" :minute="30" :second="0" color="#FFFFFF" background-color="#007AFF" border-color="#007AFF" />
  19. </view>
  20. <uni-section title="倒计时回调事件" type="line"></uni-section>
  21. <view class="example-body">
  22. <uni-countdown :show-day="false" :second="10" @timeup="timeup" />
  23. </view>
  24. <uni-section title="动态赋值" type="line"></uni-section>
  25. <view class="example-body">
  26. <uni-countdown :show-day="false" :hour="testHour" :minute="testMinute" :second="testSecond" />
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. components: {},
  33. data() {
  34. return {
  35. testHour: 0,
  36. testMinute: 0,
  37. testSecond: 0
  38. }
  39. },
  40. created() {
  41. setTimeout(() => {
  42. this.testHour = 1
  43. this.testMinute = 1
  44. this.testSecond = 0
  45. }, 2000)
  46. },
  47. methods: {
  48. timeup() {
  49. uni.showToast({
  50. title: '时间到'
  51. })
  52. }
  53. }
  54. }
  55. </script>
  56. <style>
  57. @charset "UTF-8";
  58. /* 头条小程序组件内不能引入字体 */
  59. /* #ifdef MP-TOUTIAO */
  60. @font-face {
  61. font-family: uniicons;
  62. font-weight: normal;
  63. font-style: normal;
  64. src: url("~@/static/uni.ttf") format("truetype");
  65. }
  66. /* #endif */
  67. /* #ifndef APP-NVUE */
  68. page {
  69. display: flex;
  70. flex-direction: column;
  71. box-sizing: border-box;
  72. background-color: #efeff4;
  73. min-height: 100%;
  74. height: auto;
  75. }
  76. view {
  77. font-size: 14px;
  78. line-height: inherit;
  79. }
  80. .example {
  81. padding: 0 15px 15px;
  82. }
  83. .example-info {
  84. padding: 15px;
  85. color: #3b4144;
  86. background: #ffffff;
  87. }
  88. .example-body {
  89. /* #ifndef APP-NVUE */
  90. display: flex;
  91. /* #endif */
  92. flex-direction: row;
  93. flex-wrap: wrap;
  94. justify-content: center;
  95. padding: 0;
  96. font-size: 14px;
  97. background-color: #ffffff;
  98. }
  99. /* #endif */
  100. .example {
  101. padding: 0 15px;
  102. }
  103. .example-info {
  104. /* #ifndef APP-NVUE */
  105. display: block;
  106. /* #endif */
  107. padding: 15px;
  108. color: #3b4144;
  109. background-color: #ffffff;
  110. font-size: 14px;
  111. line-height: 20px;
  112. }
  113. .example-info-text {
  114. font-size: 14px;
  115. line-height: 20px;
  116. color: #3b4144;
  117. }
  118. .example-body {
  119. flex-direction: column;
  120. padding: 15px;
  121. background-color: #ffffff;
  122. }
  123. .word-btn-white {
  124. font-size: 18px;
  125. color: #FFFFFF;
  126. }
  127. .word-btn {
  128. /* #ifndef APP-NVUE */
  129. display: flex;
  130. /* #endif */
  131. flex-direction: row;
  132. align-items: center;
  133. justify-content: center;
  134. border-radius: 6px;
  135. height: 48px;
  136. margin: 15px;
  137. background-color: #007AFF;
  138. }
  139. .word-btn--hover {
  140. background-color: #4ca2ff;
  141. }
  142. .example-body {
  143. padding: 10px;
  144. }
  145. </style>