xiangMuXQ.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="box">
  3. <view class="top_bg">
  4. <topBox></topBox>
  5. <view @click="backBtn" class="back" tabindex="0">返回上一级</view>
  6. </view>
  7. <view class="box_left"><image style="width: 100%; height: 100%" mode="aspectFill" :src="list.image"></image></view>
  8. <view class="box_right">
  9. <view class="banner">
  10. <view class="right_tit">{{ list.title }}</view>
  11. <view class="right_txt">
  12. <!-- <u-parse :content="list.intro ? list.intro : '暂无介绍'"></u-parse> -->
  13. <view class="jieshao scrolling-text" :data-scroll-height="scrollHeight">
  14. {{ list.intro ? list.intro : list.content ? list.content : list.prize ? list.prize : '暂无介绍' | removeHTMLTag }}
  15. </view>
  16. </view>
  17. <view class="btm_box">
  18. <!-- <scroll-view scroll-x="true" style="display: flex; white-space: nowrap">
  19. <view class="container" v-for="(item, index) in projectList" :key="item.index">
  20. <view class="mn_box">
  21. <image style="width: 100%; height: 100%" :src="item.img"></image>
  22. </view>
  23. <text class="title">{{ item.name }}</text>
  24. </view>
  25. </scroll-view> -->
  26. <view class="mn_box">
  27. <image @click="clickImg" style="width: 100%; height: 100%" mode="aspectFill" :src="list.image" tabindex="0"></image>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. let that;
  36. export default {
  37. data() {
  38. return {
  39. scrollHeight: '',
  40. list: []
  41. };
  42. },
  43. onLoad(o) {
  44. that = this;
  45. this.getContentDetails(o);
  46. },
  47. filters: {
  48. removeHTMLTag(str) {
  49. str = str.replace(/<\/?[^>]*>/g, ''); // 去除HTML tag
  50. str = str.replace(/[ | ]*\n/g, '\n'); // 去除行尾空白
  51. str = str.replace(/\n[\s| | ]*\r/g, '\n'); //去除多余空行
  52. str = str.replace(/ /gi, ''); // 去掉
  53. const arrEntities = {
  54. lt: '<',
  55. gt: '>',
  56. nbsp: ' ',
  57. amp: '&',
  58. quot: '"'
  59. }; // 转义符换成普通字符
  60. str = str.replace(/&(lt|gt|nbsp|amp|quot);/gi, function (all, t) {
  61. return arrEntities[t];
  62. });
  63. return str;
  64. }
  65. },
  66. mounted() {
  67. this.calculateScrollHeight();
  68. this.applyAnimation();
  69. },
  70. methods: {
  71. calculateScrollHeight() {
  72. const element = this.$el;
  73. const textHeight = element.offsetHeight;
  74. const containerHeight = element.parentNode.offsetHeight;
  75. // 计算需要滚动的距离,确保文本能够在容器内完全滚动
  76. const scrollHeight = textHeight > containerHeight ? textHeight - containerHeight : textHeight;
  77. this.scrollHeight = scrollHeight + 'px';
  78. },
  79. applyAnimation() {
  80. const element = this.$el;
  81. element.style.webkitAnimation = 'rowup 20s linear infinite';
  82. element.style.animation = 'rowup 20s linear infinite';
  83. // 动态修改关键帧动画,使其根据计算出的滚动距离进行移动
  84. element.addEventListener('animationiteration', () => {
  85. element.style.webkitAnimationName = 'rowup-' + this.scrollHeight;
  86. element.style.animationName = 'rowup-' + this.scrollHeight;
  87. });
  88. },
  89. // 详情
  90. getContentDetails(o) {
  91. this.$api.getContentDetails(
  92. {
  93. main_body_id: 1,
  94. id: o.id
  95. },
  96. function (res) {
  97. that.list = res.data;
  98. console.log(that.list, 'list');
  99. }
  100. );
  101. },
  102. clickImg() {
  103. let img = [];
  104. img.push(this.list.image);
  105. uni.previewImage({
  106. urls: img, //需要预览的图片http链接列表,多张的时候,url直接写在后面就行了
  107. current: '', // 当前显示图片的http链接,默认是第一个
  108. success: function (res) {},
  109. fail: function (res) {}
  110. });
  111. },
  112. backBtn() {
  113. uni.navigateBack({
  114. delta: 1
  115. });
  116. }
  117. }
  118. };
  119. </script>
  120. <style>
  121. .box {
  122. width: 100%;
  123. display: flex;
  124. height: 100vh;
  125. box-sizing: border-box;
  126. overflow: hidden;
  127. }
  128. .back {
  129. width: 12%;
  130. height: 25%;
  131. margin-left: 5%;
  132. margin-top: -2%;
  133. font-size: 12px;
  134. }
  135. .img {
  136. width: 100%;
  137. height: 100%;
  138. }
  139. .box_left {
  140. width: 40%;
  141. height: 100%;
  142. /* */
  143. /* background: url('https://huli-app.wenlvti.net/app_static/minnanhun/image/fy_img.png') no-repeat center;
  144. background-size: 100% 100%; */
  145. }
  146. .box_right {
  147. flex: 1;
  148. height: 100%;
  149. margin-left: -10%;
  150. z-index: 1;
  151. background: linear-gradient(90deg, rgba(240, 235, 222, 0.1) 0%, #f0ebde 15%, #f0ebde 100%);
  152. }
  153. .top_bg {
  154. width: 100%;
  155. position: absolute;
  156. color: #ffffff;
  157. z-index: 2;
  158. background: linear-gradient(10deg, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0) 30%, rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.2) 100%);
  159. }
  160. .right_tit {
  161. /* line-height: 70px; */
  162. letter-spacing: 0.3em;
  163. font-size: 14px;
  164. color: #aa734d;
  165. }
  166. .banner {
  167. width: 70%;
  168. height: 45%;
  169. margin-left: 25%;
  170. margin-top: 15%;
  171. }
  172. @-webkit-keyframes rowup {
  173. 0% {
  174. -webkit-transform: translate3d(0, 0, 0);
  175. transform: translate3d(0, 0, 0);
  176. }
  177. 100% {
  178. -webkit-transform: translateY(-100%);
  179. transform: translateY(-100%);
  180. }
  181. }
  182. @keyframes rowup {
  183. 0% {
  184. -webkit-transform: translate3d(0, 0, 0);
  185. transform: translate3d(0, 0, 0);
  186. }
  187. 100% {
  188. -webkit-transform: translateY(-100%);
  189. transform: translateY(-100%);
  190. }
  191. }
  192. .right_txt {
  193. width: 95%;
  194. height: 100%;
  195. font-size: 12px;
  196. letter-spacing: 0.2em;
  197. margin-bottom: 8%;
  198. font-weight: 400;
  199. color: rgba(170, 115, 77, 0.5);
  200. overflow: hidden;
  201. }
  202. .jieshao {
  203. -webkit-animation: 25s rowup linear infinite normal;
  204. animation: 25s rowup linear infinite normal;
  205. animation-delay: 3s;
  206. overflow: hidden;
  207. }
  208. /deep/.MsoNormal span {
  209. font-size: 12px !important;
  210. letter-spacing: 0.2em !important;
  211. font-weight: 400 !important;
  212. color: #aa734d !important;
  213. /* line-height: 70rpx !important; */
  214. }
  215. /deep/.MsoNormal {
  216. font-size: 12px !important;
  217. letter-spacing: 0.2em !important;
  218. font-weight: 400 !important;
  219. color: #aa734d !important;
  220. /* line-height: 70rpx !important; */
  221. }
  222. /deep/._undefined span {
  223. font-size: 12px !important;
  224. letter-spacing: 0.2em !important;
  225. font-weight: 400 !important;
  226. color: #aa734d !important;
  227. /* line-height: 70rpx !important; */
  228. }
  229. .btm_box {
  230. width: 100%;
  231. height: 50%;
  232. }
  233. .container {
  234. position: relative;
  235. display: inline-block;
  236. margin-right: 2%;
  237. text-align: center;
  238. }
  239. .mn_box {
  240. width: 18%;
  241. height: 90%;
  242. margin-left: 2%;
  243. box-sizing: border-box;
  244. border: 2px solid #fed57d;
  245. }
  246. </style>