tips.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="tui-tips-box" :class="[fixed?'tui-tips-fixed':'']">
  3. <image :src="imgUrl" class="tui-tips-icon" :style="{width:imgWidth+'rpx',height:imgHeight+'rpx'}"></image>
  4. <view class="tui-tips-content">
  5. <slot></slot>
  6. </view>
  7. <button class="tui-tips-btn" hover-class="tui-tips-btn-hover" :style="{width:btnWidth+'rpx'}" v-if="btnText" @tap="handleClick">{{btnText}}</button>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. name: "tuiTips",
  13. props: {
  14. //是否垂直居中
  15. fixed: {
  16. type: Boolean,
  17. default: true
  18. },
  19. //图片地址,没有则不显示
  20. imgUrl: {
  21. type: String,
  22. default: ""
  23. },
  24. //图片宽度
  25. imgWidth: {
  26. type: Number,
  27. default: 200
  28. },
  29. //图片高度
  30. imgHeight:{
  31. type: Number,
  32. default: 200
  33. },
  34. //按钮宽度
  35. btnWidth:{
  36. type: Number,
  37. default: 200
  38. },
  39. //按钮文字,没有则不显示
  40. btnText:{
  41. type:String,
  42. default: ""
  43. }
  44. },
  45. methods: {
  46. handleClick(e) {
  47. this.$emit('click', {});
  48. }
  49. }
  50. }
  51. </script>
  52. <style>
  53. .tui-tips-box {
  54. display: flex;
  55. flex-direction: column;
  56. justify-content: center;
  57. align-items: center;
  58. }
  59. .tui-tips-fixed {
  60. width: 90%;
  61. position: fixed;
  62. left: 50%;
  63. top: 50%;
  64. -webkit-transform: translate(-50%, -50%);
  65. transform: translate(-50%, -50%);
  66. }
  67. .tui-tips-icon {
  68. display: block;
  69. flex-shrink: 0;
  70. width: 280rpx;
  71. height: 280rpx;
  72. margin-bottom: 40rpx;
  73. }
  74. .tui-tips-content {
  75. text-align: center;
  76. color: #666666;
  77. font-size: 28rpx;
  78. padding: 0 50rpx 24rpx 50rpx;
  79. box-sizing: border-box;
  80. word-break: break-all;
  81. word-wrap: break-word;
  82. }
  83. .tui-tips-btn {
  84. height: 60rpx;
  85. line-height: 60rpx;
  86. font-size: 28rpx;
  87. background: #EB0909;
  88. color: #fff;
  89. border-radius: 6rpx;
  90. margin: 0;
  91. }
  92. .tui-tips-btn-hover {
  93. background: #c80808;
  94. color: #e5e5e5;
  95. }
  96. </style>