watch-button.vue 3.5 KB

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