watch-button.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view>
  3. <!-- 按钮 -->
  4. <button :class="['buttonBorder',!_rotate?'dlbutton':'dlbutton_loading']" :style="{'background':bgColor, 'color': fontColor}">
  5. <view :class="_rotate?'rotate_loop':''">
  6. <text v-if="_rotate" class="cuIcon cuIcon-loading1 "></text>
  7. <text v-if="!_rotate">{{ text }}</text>
  8. </view>
  9. </button>
  10. </view>
  11. </template>
  12. <script>
  13. export default{
  14. props:{
  15. text: String, //显示文本
  16. rotate:{
  17. //是否启动加载
  18. type: [Boolean,String],
  19. default: false,
  20. },
  21. bgColor:{
  22. //按钮背景颜色
  23. type: String,
  24. default: "linear-gradient(to right, rgba(255, 231, 21, 0.8), rgba(255, 193, 7, 0.8))",
  25. },
  26. fontColor:{
  27. //按钮字体颜色
  28. type: String,
  29. default: "#FFFFFF",
  30. },
  31. },
  32. computed:{
  33. _rotate() {
  34. //处理值
  35. return String(this.rotate) !== 'false'
  36. },
  37. }
  38. }
  39. </script>
  40. <style>
  41. @import url("./css/icon.css");
  42. .dlbutton {
  43. color: #FFFFFF;
  44. font-size: 30upx;
  45. width:601upx;
  46. height:100upx;
  47. background:linear-gradient(to right, rgba(0,0,0,0.7), rgba(0,0,0,0.6));
  48. box-shadow:0upx 0upx 13upx 0upx rgba(164,217,228,0.4);
  49. border-radius:2.5rem;
  50. line-height: 100upx;
  51. text-align: center;
  52. margin-left: auto;
  53. margin-right: auto;
  54. margin-top: 96upx;
  55. }
  56. .dlbutton_loading {
  57. color: #FFFFFF;
  58. font-size: 30upx;
  59. width:100upx;
  60. height:100upx;
  61. background:linear-gradient(to right, rgba(0,0,0,0.7), rgba(0,0,0,0.6));
  62. box-shadow:0upx 0upx 13upx 0upx rgba(164,217,228,0.4);
  63. border-radius:2.5rem;
  64. line-height: 100upx;
  65. text-align: center;
  66. margin-left: auto;
  67. margin-right: auto;
  68. margin-top: 96upx;
  69. }
  70. .buttonBorder{
  71. border: none ;
  72. border-radius: 2.5rem ;
  73. -webkit-box-shadow: 0 0 60upx 0 rgba(57, 181, 74, 0.2);
  74. box-shadow: 0 0 60upx 0 rgba(57, 181, 74, 0.2);
  75. -webkit-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
  76. -moz-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
  77. -ms-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
  78. -o-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
  79. transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
  80. }
  81. /* 旋转动画 */
  82. .rotate_loop{
  83. -webkit-transition-property: -webkit-transform;
  84. -webkit-transition-duration: 1s;
  85. -moz-transition-property: -moz-transform;
  86. -moz-transition-duration: 1s;
  87. -webkit-animation: rotate 1s linear infinite;
  88. -moz-animation: rotate 1s linear infinite;
  89. -o-animation: rotate 1s linear infinite;
  90. animation: rotate 1s linear infinite;
  91. }
  92. @-webkit-keyframes rotate{from{-webkit-transform: rotate(0deg)}
  93. to{-webkit-transform: rotate(360deg)}
  94. }
  95. @-moz-keyframes rotate{from{-moz-transform: rotate(0deg)}
  96. to{-moz-transform: rotate(359deg)}
  97. }
  98. @-o-keyframes rotate{from{-o-transform: rotate(0deg)}
  99. to{-o-transform: rotate(359deg)}
  100. }
  101. @keyframes rotate{from{transform: rotate(0deg)}
  102. to{transform: rotate(359deg)}
  103. }
  104. button::after{ border: none;}
  105. </style>