watch-button.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. .dlbutton {
  58. display: flex;
  59. justify-content: center;
  60. align-items: center;
  61. color: #FFFFFF;
  62. font-size: 30rpx;
  63. white-space:nowrap;
  64. overflow: hidden;
  65. width:601rpx;
  66. height:100rpx;
  67. background:linear-gradient(to right, rgba(0,0,0,0.7), rgba(0,0,0,0.6));
  68. box-shadow:0rpx 0rpx 13rpx 0rpx rgba(164,217,228,0.4);
  69. border-radius:2.5rem;
  70. margin-top: 0rpx;
  71. }
  72. .dlbutton_loading {
  73. display: flex;
  74. justify-content: center;
  75. align-items: center;
  76. color: #FFFFFF;
  77. font-size: 30rpx;
  78. width:100rpx;
  79. height:100rpx;
  80. background:linear-gradient(to right, rgba(0,0,0,0.7), rgba(0,0,0,0.6));
  81. box-shadow:0rpx 0rpx 13rpx 0rpx rgba(164,217,228,0.4);
  82. border-radius:2.5rem;
  83. margin-top: 0rpx;
  84. }
  85. .buttonBorder{
  86. border: none ;
  87. border-radius: 2.5rem ;
  88. -webkit-box-shadow: 0 0 60rpx 0 rgba(0,0,0,.2) ;
  89. box-shadow: 0 0 60rpx 0 rgba(0,0,0,.2) ;
  90. -webkit-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
  91. -moz-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
  92. -ms-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
  93. -o-transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
  94. transition: all 0.4s cubic-bezier(.57,.19,.51,.95);
  95. }
  96. /* 旋转动画 */
  97. .rotate_loop{
  98. -webkit-transition-property: -webkit-transform;
  99. -webkit-transition-duration: 1s;
  100. -moz-transition-property: -moz-transform;
  101. -moz-transition-duration: 1s;
  102. -webkit-animation: rotate 1s linear infinite;
  103. -moz-animation: rotate 1s linear infinite;
  104. -o-animation: rotate 1s linear infinite;
  105. animation: rotate 1s linear infinite;
  106. }
  107. @-webkit-keyframes rotate{from{-webkit-transform: rotate(0deg)}
  108. to{-webkit-transform: rotate(360deg)}
  109. }
  110. @-moz-keyframes rotate{from{-moz-transform: rotate(0deg)}
  111. to{-moz-transform: rotate(359deg)}
  112. }
  113. @-o-keyframes rotate{from{-o-transform: rotate(0deg)}
  114. to{-o-transform: rotate(359deg)}
  115. }
  116. @keyframes rotate{from{transform: rotate(0deg)}
  117. to{transform: rotate(359deg)}
  118. }
  119. </style>