watch-button.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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(0,0,0,0.7), rgba(0,0,0,0.6))",
  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: 651upx;
  46. height: 90upx;
  47. background: linear-gradient(to left,#FF7F00 0, #FF7F00 100%);
  48. box-shadow: 0upx 0upx 13upx 0upx rgba(164, 217, 228, 0.4);
  49. border-radius: 2.5rem;
  50. line-height: 90upx;
  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 left,#FF7F00 0, #FF7F00 100%);
  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(0, 0, 0, .2);
  74. box-shadow: 0 0 60upx 0 rgba(0, 0, 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 {
  93. from {
  94. -webkit-transform: rotate(0deg)
  95. }
  96. to {
  97. -webkit-transform: rotate(360deg)
  98. }
  99. }
  100. @-moz-keyframes rotate {
  101. from {
  102. -moz-transform: rotate(0deg)
  103. }
  104. to {
  105. -moz-transform: rotate(359deg)
  106. }
  107. }
  108. @-o-keyframes rotate {
  109. from {
  110. -o-transform: rotate(0deg)
  111. }
  112. to {
  113. -o-transform: rotate(359deg)
  114. }
  115. }
  116. @keyframes rotate {
  117. from {
  118. transform: rotate(0deg)
  119. }
  120. to {
  121. transform: rotate(359deg)
  122. }
  123. }
  124. </style>