watch-button.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view>
  3. <!-- 按钮 -->
  4. <button
  5. :class="['buttonBorder', !_rotate ? 'dlbutton' : 'dlbutton_loading']"
  6. :style="{ background: bgColor, color: fontColor }"
  7. @click="$emit('click', $event)"
  8. @contact="$emit('contact', $event)"
  9. @error="$emit('error', $event)"
  10. @getphonenumber="$emit('getphonenumber', $event)"
  11. @getuserinfo="$emit('getuserinfo', $event)"
  12. @launchapp="$emit('launchapp', $event)"
  13. @longtap="$emit('longtap', $event)"
  14. @opensetting="$emit('opensetting', $event)"
  15. @touchcancel="$emit('touchcancel', $event)"
  16. @touchend="$emit('touchend', $event)"
  17. @touchmove="$emit('touchmove', $event)"
  18. @touchstart="$emit('touchstart', $event)">
  19. <view :class="_rotate ? 'rotate_loop' : ''">
  20. <text v-if="_rotate" class="cuIcon cuIcon-loading1"></text>
  21. <view v-if="!_rotate">
  22. <slot name="text">{{ text }}</slot>
  23. </view>
  24. </view>
  25. </button>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. props: {
  31. text: String, //显示文本
  32. rotate: {
  33. //是否启动加载
  34. type: [Boolean, String],
  35. default: false,
  36. },
  37. bgColor: {
  38. //按钮背景颜色
  39. type: String,
  40. default: "linear-gradient(to right, rgb(255 0 0 / 70%), rgb(255 1 1))",
  41. },
  42. fontColor: {
  43. //按钮字体颜色
  44. type: String,
  45. default: "#FFFFFF",
  46. },
  47. },
  48. computed: {
  49. _rotate() {
  50. //处理值
  51. return String(this.rotate) !== "false";
  52. },
  53. },
  54. };
  55. </script>
  56. <style>
  57. @import url("./css/icon.css");
  58. button {
  59. outline: none; /* 或者 outline: 0 */
  60. }
  61. button:after {
  62. border: none;
  63. }
  64. button:focus {
  65. outline: none; /* 或者 outline: 0 */
  66. }
  67. .dlbutton {
  68. display: flex;
  69. justify-content: center;
  70. align-items: center;
  71. color: #ffffff;
  72. font-size: 30rpx;
  73. white-space: nowrap;
  74. overflow: hidden;
  75. width: 601rpx;
  76. height: 100rpx;
  77. background: linear-gradient(to right, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.6));
  78. box-shadow: 0rpx 0rpx 13rpx 0rpx rgba(164, 217, 228, 0.4);
  79. border-radius: 2.5rem;
  80. margin-top: 0rpx;
  81. }
  82. .dlbutton_loading {
  83. display: flex;
  84. justify-content: center;
  85. align-items: center;
  86. color: #ffffff;
  87. font-size: 30rpx;
  88. width: 100rpx;
  89. height: 100rpx;
  90. background: linear-gradient(to right, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.6));
  91. box-shadow: 0rpx 0rpx 13rpx 0rpx rgba(164, 217, 228, 0.4);
  92. border-radius: 2.5rem;
  93. margin-top: 0rpx;
  94. }
  95. .buttonBorder {
  96. border: none;
  97. border-radius: 2.5rem;
  98. -webkit-box-shadow: 0 0 60rpx 0 rgba(0, 0, 0, 0.2);
  99. box-shadow: 0 0 60rpx 0 rgba(0, 0, 0, 0.2);
  100. -webkit-transition: all 0.4s cubic-bezier(0.57, 0.19, 0.51, 0.95);
  101. -moz-transition: all 0.4s cubic-bezier(0.57, 0.19, 0.51, 0.95);
  102. -ms-transition: all 0.4s cubic-bezier(0.57, 0.19, 0.51, 0.95);
  103. -o-transition: all 0.4s cubic-bezier(0.57, 0.19, 0.51, 0.95);
  104. transition: all 0.4s cubic-bezier(0.57, 0.19, 0.51, 0.95);
  105. }
  106. /* 旋转动画 */
  107. .rotate_loop {
  108. -webkit-transition-property: -webkit-transform;
  109. -webkit-transition-duration: 1s;
  110. -moz-transition-property: -moz-transform;
  111. -moz-transition-duration: 1s;
  112. -webkit-animation: rotate 1s linear infinite;
  113. -moz-animation: rotate 1s linear infinite;
  114. -o-animation: rotate 1s linear infinite;
  115. animation: rotate 1s linear infinite;
  116. }
  117. @-webkit-keyframes rotate {
  118. from {
  119. -webkit-transform: rotate(0deg);
  120. }
  121. to {
  122. -webkit-transform: rotate(360deg);
  123. }
  124. }
  125. @-moz-keyframes rotate {
  126. from {
  127. -moz-transform: rotate(0deg);
  128. }
  129. to {
  130. -moz-transform: rotate(359deg);
  131. }
  132. }
  133. @-o-keyframes rotate {
  134. from {
  135. -o-transform: rotate(0deg);
  136. }
  137. to {
  138. -o-transform: rotate(359deg);
  139. }
  140. }
  141. @keyframes rotate {
  142. from {
  143. transform: rotate(0deg);
  144. }
  145. to {
  146. transform: rotate(359deg);
  147. }
  148. }
  149. </style>