xiangMuXQ.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view class="box">
  3. <view class="top_bg">
  4. <topBox></topBox>
  5. <view @click="backBtn" class="back">⬅返回上一级</view>
  6. </view>
  7. <view class="box_left"><image style="width: 100%; height: 100%" :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%" :src="list.image"></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: 5,
  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. /* background: url('https://huli-app.wenlvti.net/app_static/minnanhun/image/fy_img.png') no-repeat center;
  143. background-size: 100% 100%; */
  144. }
  145. .box_right {
  146. flex: 1;
  147. height: 100%;
  148. margin-left: -10%;
  149. z-index: 1;
  150. background: linear-gradient(90deg, rgba(240, 235, 222, 0.1) 0%, #f0ebde 15%, #f0ebde 100%);
  151. }
  152. .top_bg {
  153. width: 100%;
  154. position: absolute;
  155. color: #ffffff;
  156. z-index: 2;
  157. 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%);
  158. }
  159. .right_tit {
  160. /* line-height: 70px; */
  161. letter-spacing: 0.3em;
  162. font-size: 14px;
  163. color: #aa734d;
  164. }
  165. .banner {
  166. width: 70%;
  167. height: 45%;
  168. margin-left: 25%;
  169. margin-top: 15%;
  170. }
  171. @-webkit-keyframes rowup {
  172. 0% {
  173. -webkit-transform: translate3d(0, 0, 0);
  174. transform: translate3d(0, 0, 0);
  175. }
  176. 100% {
  177. -webkit-transform: translateY(-100%);
  178. transform: translateY(-100%);
  179. }
  180. }
  181. @keyframes rowup {
  182. 0% {
  183. -webkit-transform: translate3d(0, 0, 0);
  184. transform: translate3d(0, 0, 0);
  185. }
  186. 100% {
  187. -webkit-transform: translateY(-100%);
  188. transform: translateY(-100%);
  189. }
  190. }
  191. .right_txt {
  192. width: 95%;
  193. height: 100%;
  194. font-size: 12px;
  195. letter-spacing: 0.2em;
  196. margin-bottom: 8%;
  197. font-weight: 400;
  198. color: rgba(170, 115, 77, 0.5);
  199. overflow: hidden;
  200. }
  201. .jieshao {
  202. -webkit-animation: 25s rowup linear infinite normal;
  203. animation: 25s rowup linear infinite normal;
  204. animation-delay: 3s;
  205. overflow: hidden;
  206. }
  207. /deep/.MsoNormal span {
  208. font-size: 12px !important;
  209. letter-spacing: 0.2em !important;
  210. font-weight: 400 !important;
  211. color: #aa734d !important;
  212. /* line-height: 70rpx !important; */
  213. }
  214. /deep/.MsoNormal {
  215. font-size: 12px !important;
  216. letter-spacing: 0.2em !important;
  217. font-weight: 400 !important;
  218. color: #aa734d !important;
  219. /* line-height: 70rpx !important; */
  220. }
  221. /deep/._undefined span {
  222. font-size: 12px !important;
  223. letter-spacing: 0.2em !important;
  224. font-weight: 400 !important;
  225. color: #aa734d !important;
  226. /* line-height: 70rpx !important; */
  227. }
  228. .btm_box {
  229. width: 100%;
  230. height: 50%;
  231. }
  232. .container {
  233. position: relative;
  234. display: inline-block;
  235. margin-right: 2%;
  236. text-align: center;
  237. }
  238. .mn_box {
  239. width: 18%;
  240. height: 90%;
  241. margin-left: 2%;
  242. box-sizing: border-box;
  243. border: 2px solid #fed57d;
  244. }
  245. </style>