gui-article-info.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view
  3. class="gui-editor-show gui-border-box"
  4. :style="{
  5. paddingLeft:padding+'rpx',
  6. paddingRight:padding+'rpx',
  7. width:'750rpx'
  8. }">
  9. <view
  10. v-for="(item, index) in article" :key="index">
  11. <!-- 文本 -->
  12. <text class="gui-block-text"
  13. :decode="true"
  14. :selectable="true"
  15. :user-select="true"
  16. :style="textStyle"
  17. v-if="item.type == 'txt'">{{item.content}}</text>
  18. <!-- 居中 -->
  19. <text class="gui-block-text gui-text-center"
  20. :selectable="true"
  21. :user-select="true"
  22. :decode="true"
  23. :style="centerStyle"
  24. v-if="item.type == 'center'">{{item.content}}</text>
  25. <!-- 图片 -->
  26. <view class="gui-img-in"
  27. v-else-if="item.type == 'img'"
  28. :data-url="item.content" @tap="showImgs">
  29. <gui-image :src="item.content" :height="0"
  30. :borderRadius="imgRadius"
  31. :width="(750-padding*2)"></gui-image>
  32. </view>
  33. <!-- 引用 源码 -->
  34. <text class="gui-block-text"
  35. :selectable="true"
  36. :user-select="true"
  37. :style="quoteStyle"
  38. :decode="true"
  39. v-else-if="
  40. item.type == 'quote' || item.type == 'pre'
  41. ">{{item.content}}</text>
  42. <!-- 加粗 -->
  43. <text class="gui-block-text gui-bold"
  44. :selectable="true"
  45. :user-select="true"
  46. :style="strongStyle"
  47. :decode="true"
  48. v-else-if="item.type == 'strong'">{{item.content}}</text>
  49. <!-- 链接 -->
  50. <view v-else-if="item.type == 'link'">
  51. <gui-link :url="item.content" :title="item.content"></gui-link>
  52. </view>
  53. <!-- 分割符 -->
  54. <text class="gui-block-text gui-text-center"
  55. :selectable="true"
  56. :user-select="true"
  57. :style="splineStyle"
  58. v-else-if="item.type == 'spline'">● ● ●</text>
  59. <!-- h1 -->
  60. <text class="gui-block-text gui-h1"
  61. :decode="true"
  62. :selectable="true"
  63. :user-select="true"
  64. v-else-if="item.type == 'h1'">{{item.content}}</text>
  65. <!-- h2 -->
  66. <text class="gui-block-text gui-h2"
  67. :selectable="true"
  68. :user-select="true"
  69. :decode="true"
  70. v-else-if="item.type == 'h2'">{{item.content}}</text>
  71. <!-- h3 -->
  72. <text class="gui-block-text gui-h3"
  73. :selectable="true"
  74. :user-select="true"
  75. :decode="true"
  76. v-else-if="item.type == 'h3'">{{item.content}}</text>
  77. <!-- h4 -->
  78. <text class="gui-block-text gui-h4"
  79. :selectable="true"
  80. :user-select="true"
  81. :decode="true"
  82. v-else-if="item.type == 'h4'">{{item.content}}</text>
  83. <!-- h5 -->
  84. <text class="gui-block-text gui-h5"
  85. :selectable="true"
  86. :user-select="true"
  87. :decode="true"
  88. v-else-if="item.type == 'h5'">{{item.content}}</text>
  89. <!-- h6 -->
  90. <text class="gui-block-text gui-h6"
  91. :selectable="true"
  92. :user-select="true"
  93. :decode="true"
  94. v-else-if="item.type == 'h6'">{{item.content}}</text>
  95. <!-- 视频 -->
  96. <view v-if="item.type == 'video'">
  97. <video
  98. :style="{width:(750-padding*2)+'rpx'}"
  99. :src="item.content"
  100. controls></video>
  101. </view>
  102. <!-- 间距 -->
  103. <view :style="{height:itemMargin}"></view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. export default{
  109. name : "gui-article-info",
  110. props : {
  111. article : {
  112. type : Array,
  113. default : function(){return new Array();}
  114. },
  115. itemMargin : {
  116. type : String,
  117. default : '20rpx',
  118. },
  119. padding : {
  120. type : Number,
  121. default : 30,
  122. },
  123. textStyle : {
  124. type : String,
  125. default : 'line-height:58rpx; font-size:30rpx; color:#2B2E3D; text-align:justify;'
  126. },
  127. centerStyle : {
  128. type : String,
  129. default : 'line-height:58rpx; font-size:30rpx; color:#2B2E3D;'
  130. },
  131. imgRadius : {
  132. type : String,
  133. default : '6rpx',
  134. },
  135. quoteStyle : {
  136. type : String,
  137. default : 'line-height:58rpx; font-size:30rpx; color:#2B2E3D; padding:20rpx; background-color:#F8F8F8;'
  138. },
  139. strongStyle : {
  140. type : String,
  141. default : 'line-height:58rpx; font-size:30rpx; color:#2B2E3D;'
  142. },
  143. splineStyle : {
  144. type : String,
  145. default : 'line-height:58rpx; font-size:30rpx; color:rgba(69, 90, 100, 0.6);'
  146. }
  147. },
  148. methods: {
  149. showImgs:function(e){
  150. var currentUrl = e.currentTarget.dataset.url;
  151. var imgs = [];
  152. var items = this.article;
  153. for(let i = 0; i < items.length; i++){
  154. if(items[i].type == 'img'){
  155. imgs.push(items[i].content);
  156. }
  157. }
  158. uni.previewImage({
  159. urls:imgs,
  160. current:currentUrl
  161. })
  162. }
  163. }
  164. }
  165. </script>
  166. <style scoped>
  167. /* #ifndef APP-NVUE */
  168. .gui-block-text{word-break: break-all;}
  169. /* #endif */
  170. </style>