timer-clock.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <el-dialog :visible.sync="show" title="计时器" custom-class="content" center :close-on-click-modal="false" destroy-on-close
  3. style="background-color: #00142f63;backdrop-filter: blur(4px);" width="640px">
  4. <!-- <u-subsection :list="['秒表','倒计时']" @change="tabChange" :current="current"></u-subsection> -->
  5. <view style="padding: 30px 30px 0 30px;">
  6. <view v-show="current == 0" style="min-height: 250px;">
  7. <led ref="led" v-if="show && start" :mode="3" :twinkle="start && !pause"></led>
  8. <view v-else>
  9. <led :mode="4" :val-arr="[0,0,':',0,0]"></led>
  10. </view>
  11. </view>
  12. <view v-show="current == 1" style="min-height: 250px;">
  13. <!-- <led :mode="4" :val-arr="arr"></led> -->
  14. </view>
  15. </view>
  16. <view class="text-center ui-mt40">
  17. <el-button type="primary" round @click="setStart">{{ start ? '重新开始' : '开始计时'}}</el-button>
  18. <el-button round @click="setPause" v-if="start">{{ pause ? '恢复' : '暂停' }}</el-button>
  19. </view>
  20. </el-dialog>
  21. </template>
  22. <script>
  23. import led from '@/components/mehaotian-numled/mehaotian-numled.vue';
  24. export default {
  25. components: {
  26. led
  27. },
  28. data() {
  29. return {
  30. show: false,
  31. current : 0,
  32. arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],
  33. start : false,
  34. pause : false,
  35. }
  36. },
  37. computed: {},
  38. methods: {
  39. open() {
  40. this.show = true;
  41. setTimeout(() => {
  42. this.arr = [0, 9, ':', 8, 1];
  43. }, 2000);
  44. },
  45. tabChange(index){
  46. this.current = index;
  47. },
  48. setStart(){
  49. this.start = true;
  50. this.pause = false;
  51. this.$nextTick(() => {
  52. this.$refs.led.restart();
  53. })
  54. },
  55. setPause(){
  56. if(this.pause){
  57. this.pause = false;
  58. this.$refs.led.recover();
  59. }else{
  60. this.pause = true;
  61. this.$nextTick(() => {
  62. this.$refs.led.pause();
  63. })
  64. }
  65. }
  66. }
  67. }
  68. </script>
  69. <style>
  70. /deep/ .content {
  71. background-image: url('https://zhxy.obs.cn-hz1.ctyun.cn:443/static/desk_bg/class_bj.jpg');
  72. background-size: auto;
  73. border: 1px solid #0d5396;
  74. }
  75. /deep/ .el-dialog__header {
  76. background: #022c5a80;
  77. border-bottom: 2px solid #051d37;
  78. }
  79. /deep/ .el-dialog__title {
  80. color: #fff;
  81. }
  82. /deep/ .el-dialog__body {
  83. /* background-color: rgba(255, 255, 255, 1); */
  84. }
  85. </style>