ithui-bullet-two.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /**
  2. * ITHUI®
  3. * ITHUI-Bullet 适用于升级&通知、任务说明、活动规则、置顶公告弹框,兼容小程序、APP、H5。
  4. * Copyright (c) 2023 ITHANG All rights reserved.
  5. * Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  6. * 复制使用请保留本段注释,感谢支持开源!
  7. *
  8. * 作者主页
  9. * https://ithang.cn/
  10. *
  11. * 开源地址
  12. * https://github.com/ithang-cn/ITHUI-Bullet
  13. * https://gitee.com/ithang-cn/ITHUI-Bullet
  14. *
  15. */
  16. <template>
  17. <view class="ithui-bullet">
  18. <u-popup @click="handleCloseOnClickOverlay" :show="value" :zIndex="zIndex" :overlayOpacity="opacity"
  19. :closeOnClickOverlay="closeOnClickOverlay" mode="center" bgColor="transparent">
  20. <view class="bullet-box">
  21. <view class="top">
  22. <view class="bg">
  23. <image src="@/static/top-bg.png" />
  24. </view>
  25. <view class="sub">
  26. <view class="icon">
  27. <image src="@/static/notice.png" />
  28. </view>
  29. <view class="title">{{title}}</view>
  30. </view>
  31. </view>
  32. <scroll-view :scroll-top="scrollTop" :scroll-y="true" class="scroll-Y" @scroll="scroll">
  33. <view class="content">
  34. <rich-text class="rich-val" :nodes="content"></rich-text>
  35. </view>
  36. </scroll-view>
  37. <view class="button" v-if="showButton">
  38. <u-button @click="handleOK" shape="circle" :color="buttonColor" :text="buttonText"></u-button>
  39. </view>
  40. </view>
  41. <view class="bullet-close">
  42. <u-icon @click="handleClose" name="close-circle" color="#fff" size="34"></u-icon>
  43. </view>
  44. </u-popup>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. name: "ithui-bullet-two",
  50. props: {
  51. value: {
  52. type: Boolean,
  53. default: false
  54. },
  55. zIndex: {
  56. type: String | Number,
  57. default: 10086
  58. },
  59. opacity: {
  60. type: String | Number,
  61. default: 0.5
  62. },
  63. closeOnClickOverlay: {
  64. type: Boolean,
  65. default: false
  66. },
  67. icon: {
  68. type: String,
  69. default: ''
  70. },
  71. title: {
  72. type: String,
  73. default: '标题'
  74. },
  75. content: {
  76. type: String,
  77. default: ''
  78. },
  79. buttonColor: {
  80. type: String,
  81. default: 'linear-gradient(to right, #0db5f0, #2d95f1)'
  82. },
  83. buttonText: {
  84. type: String,
  85. default: ''
  86. },
  87. showButton: {
  88. type: Boolean,
  89. default: true
  90. }
  91. },
  92. data() {
  93. return {
  94. scrollTop: 0,
  95. old: {
  96. scrollTop: 0
  97. }
  98. };
  99. },
  100. methods: {
  101. handleOK() {
  102. this.$emit('input', false);
  103. this.$emit('confirm');
  104. },
  105. handleCloseOnClickOverlay() {
  106. if (this.closeOnClickOverlay) {
  107. this.$emit('input', false);
  108. this.$emit('close');
  109. }
  110. },
  111. handleClose() {
  112. this.$emit('input', false);
  113. this.$emit('cancel');
  114. },
  115. scroll(e) {
  116. this.old.scrollTop = e.detail.scrollTop
  117. },
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .ithui {
  123. &-bullet {
  124. .bullet {
  125. &-box {
  126. background-color: #fff;
  127. width: 640rpx;
  128. height: 65vh;
  129. border-radius: 20rpx;
  130. .top {
  131. width: 640rpx;
  132. height: 260rpx;
  133. .bg {
  134. width: 640rpx;
  135. height: 260rpx;
  136. image {
  137. width: 100%;
  138. height: 100%;
  139. border-radius: 20rpx 20rpx 0 0;
  140. }
  141. }
  142. .sub {
  143. width: 640rpx;
  144. height: 260rpx;
  145. position: relative;
  146. top: -260rpx;
  147. text-align: center;
  148. color: #fff;
  149. font-size: 36rpx;
  150. letter-spacing: 5rpx;
  151. .icon {
  152. margin-top: 20rpx;
  153. margin-bottom: 10rpx;
  154. border-radius: 120rpx;
  155. image {
  156. width: 120rpx;
  157. height: 120rpx;
  158. border-radius: 120rpx;
  159. }
  160. }
  161. }
  162. }
  163. .scroll-Y {
  164. margin-top: 15rpx;
  165. height: 35vh;
  166. .content {
  167. margin: 0 30rpx;
  168. }
  169. }
  170. .button {
  171. margin: 40rpx 100rpx;
  172. }
  173. }
  174. &-close {
  175. margin-top: 20rpx;
  176. display: flex;
  177. justify-content: center;
  178. }
  179. }
  180. }
  181. }
  182. .rich-val{
  183. word-break: break-all;
  184. white-space: pre-line;
  185. }
  186. </style>