my-control-buttons.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <!-- 按钮控制 -->
  3. <view class="flex justify-center" style="margin-top: 16px;">
  4. <view v-if="showLeftRight" class="my-control-button" style=" width: 90rpx;" @tap="_controlButtonTap(false)">
  5. <image class="data-png-26" src="/static/e-left.png"></image>
  6. </view>
  7. <view class="my-control-button " :class="bPlanFinish?'my-custom-breathing-lamp':''" style=" width:256rpx;" @tap="_controlPlayTap()">
  8. <image :class="bControlRun?'data-png-26':'my-control-play'" :src="bControlRun?'/static/e-pause.png':'/static/play.png' "></image>
  9. </view>
  10. <view v-if="showLeftRight" class="my-control-button" style=" width: 90rpx;" @tap="_controlButtonTap(true)">
  11. <image class="data-png-26" src="/static/e-right.png"></image>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import {
  17. mapState,
  18. mapMutations
  19. } from 'vuex';
  20. export default {
  21. computed: mapState(['bPlanFinish'
  22. ]),
  23. props:{
  24. showLeftRight: {
  25. type: [Boolean, String],
  26. default: true
  27. },
  28. },
  29. data() {
  30. return {
  31. // 默认不运行
  32. bControlRun: false,
  33. }
  34. },
  35. methods:{
  36. _controlButtonTap(bRight){
  37. console.log("right==",bRight);
  38. this.$emit('onControlButtonTap',{bRight:bRight});
  39. },
  40. _controlPlayTap(){
  41. console.log("onControlPlayTap");
  42. this.$emit('onControlPlayTap',{bControlRun:this.bControlRun});
  43. },
  44. onPlay(bPlaying){
  45. if(bPlaying){
  46. this.bControlRun = bPlaying;
  47. }else{
  48. this.bControlRun = !this.bControlRun;
  49. }
  50. }
  51. }
  52. }
  53. </script>
  54. <style>
  55. .my-control-button {
  56. background-color: rgba(255, 255, 255, 0.25);
  57. border-radius: 45px;
  58. margin: 5px 12px;
  59. box-shadow: 1px 1px 3px #888888;
  60. display: flex;
  61. justify-content: center;
  62. height: 26px;
  63. }
  64. /* 图标大小 */
  65. .my-control-play {
  66. width: 16px;
  67. height: 16px;
  68. margin-top: 10rpx;
  69. }
  70. /* 呼吸灯 */
  71. .my-custom-breathing-lamp {
  72. animation-duration: 1s;
  73. animation-timing-function: ease-out;
  74. animation-fill-mode: inherit;
  75. animation-iteration-count: infinite;
  76. animation-name: my-custom-run-lamp;
  77. animation-play-state: running;
  78. }
  79. @keyframes my-custom-run-lamp {
  80. 0%,
  81. 100% {
  82. opacity: 1;
  83. transform: scale(1);
  84. }
  85. 50% {
  86. opacity: 0.6;
  87. transform: scale(0.9);
  88. }
  89. }
  90. </style>