index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view class="u-demo">
  3. <view class="u-demo-wrap">
  4. <view class="u-demo-title">演示效果</view>
  5. <view class="u-demo-area">
  6. <u-toast ref="uToast"></u-toast>
  7. <u-count-down class="count-down-demo" :timestamp="timestamp" :separator="separator" :showBorder="showBorder"
  8. :separator-color="separatorColor" :showDays="showDays" :fontSize="fontSize" @change="change" ref="uCountDown"
  9. :border-color="borderColor" :color="color" @end="end" bg-color="rgb(250, 250, 250)"></u-count-down>
  10. </view>
  11. </view>
  12. <view class="u-config-wrap">
  13. <view class="u-config-title u-border-bottom">
  14. 参数配置
  15. </view>
  16. <view class="u-config-item">
  17. <view class="u-item-title">调整时间</view>
  18. <u-subsection :list="['60', '86400', '983272']" @change="timestampChange"></u-subsection>
  19. </view>
  20. <view class="u-config-item">
  21. <view class="u-item-title">分隔符</view>
  22. <u-subsection :list="['英文冒号', '中文名称']" @change="separatorChange"></u-subsection>
  23. </view>
  24. <view class="u-config-item">
  25. <view class="u-item-title">自定义样式</view>
  26. <u-subsection current="1" :list="['是', '否']" @change="styleChange"></u-subsection>
  27. </view>
  28. <view class="u-config-item">
  29. <view class="u-item-title">显示天</view>
  30. <u-subsection current="1" :list="['是', '否']" @change="showDaysChange"></u-subsection>
  31. </view>
  32. <view class="u-config-item">
  33. <view class="u-item-title">字体大小</view>
  34. <u-subsection current="1" :list="['26', '30', '34']" @change="fontSizeChange"></u-subsection>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. timestamp: 60,
  44. separator: 'colon',
  45. showBorder: false,
  46. borderColor: '#303133',
  47. color: '#303133',
  48. showDays: false,
  49. fontSize: 30,
  50. separatorColor: '#303133',
  51. };
  52. },
  53. methods: {
  54. timestampChange(index) {
  55. this.timestamp = index == 0 ? 60 : index == 1 ? 86400 : 983272;
  56. },
  57. separatorChange(index) {
  58. this.separator = index == 0 ? 'colon' : 'zh';
  59. },
  60. styleChange(index) {
  61. if(index == 0) {
  62. this.showBorder = true;
  63. this.borderColor = this.$u.color['primary'];
  64. this.color = this.$u.color['primary'];
  65. this.separatorColor = this.$u.color['primary'];
  66. } else {
  67. this.showBorder = false;
  68. this.borderColor = '#303133';
  69. this.color = '#303133';
  70. this.separatorColor = '#303133';
  71. }
  72. },
  73. showDaysChange(index) {
  74. this.showDays = index == 0 ? true : false;
  75. },
  76. fontSizeChange(index) {
  77. this.fontSize = index == 0 ? 26 : index == 1 ? 30 : 34;
  78. },
  79. end() {
  80. this.$refs.uToast.show({
  81. title: '倒计时结束',
  82. type: 'warning'
  83. })
  84. },
  85. change(timestamp) {
  86. // console.log(timestamp);
  87. },
  88. getSeconds() {
  89. // console.log(this.$refs.uCountDown.seconds);
  90. }
  91. }
  92. };
  93. </script>
  94. <style scoped lang="scss">
  95. .count-down-demo {
  96. justify-content: center;
  97. }
  98. </style>