ms_wenZhang.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <view>
  3. <u-navbar :autoBack="true" title="民俗宗教" bgColor="rgba(255,255,255,0)" :placeholder="true" titleStyle="font-weight:bold;color:#121212"></u-navbar>
  4. <view class="text-group_17">
  5. <text lines="1" class="text_2">{{ list.title }}</text>
  6. <text lines="1" decode="true" class="text_13">{{ formattedCurrentTime }}</text>
  7. </view>
  8. <view class="block_3">
  9. <view class="text_3">
  10. <text class="text_10">
  11. <!-- <u-parse :content="list.content"></u-parse> -->
  12. {{ (list.content || '').replace(/<\/?[^>]*>/g, '') | removeHTMLTag }}
  13. </text>
  14. </view>
  15. <view class="box_3">
  16. <image style="width: 100%; height: 100%" :src="list.image"></image>
  17. </view>
  18. <!-- <view class="text-wrapper_1">
  19. <text class="paragraph_1">一、水神、海神</text>
  20. <p class="paragraph_2">闽南近海,大多以海为田,以海为生,在与海交往的几千年里,闽南人最乐于将海神作为自己营生的保护神。</p>
  21. <p class="paragraph_6">
  22. 闽南的水神、海神大概有四种:一为全国各地普遍存在的海龙王;二为闽南土生土长的海神妈祖;三为主管水的玄天上帝;四为较罕见的水仙尊王。水仙尊王并非独一角色。
  23. 有不同,常见者如西楚霸王项羽(乌江自刎)、屈原(汨罗江投江)、伍子胥(沉尸河底)、李白(醉酒溺亡)、王勃(渡江溺亡)、大禹(治水)等。
  24. </p>
  25. </view> -->
  26. <view class="box_35">
  27. <view class="ms_dianzan">
  28. <view class="box_r" @click="collect">
  29. <uni-icons type="star-filled" color="#4e7198" size="22"></uni-icons>
  30. <text>{{ list.collects }}</text>
  31. </view>
  32. <view class="box_r" @click="likeBtn">
  33. <uni-icons type="heart-filled" color="#ca5642" size="20"></uni-icons>
  34. <text>{{ list.likes }}</text>
  35. </view>
  36. <view class="box_r">
  37. <uni-icons type="redo" size="20"></uni-icons>
  38. <text lines="1" class="text-group_1">分享</text>
  39. </view>
  40. </view>
  41. </view>
  42. <text lines="1" class="text_5">相关推荐</text>
  43. <view class="sh_xs">
  44. <view class="sh_xs_item" v-for="item in shXiShuList" :key="item">
  45. <view @click="detailsBtn" class="" style="width: 325rpx; height: 180rpx; border-radius: 10rpx">
  46. <image style="width: 100%; height: 100%" :src="item.img"></image>
  47. </view>
  48. <view class="">{{ item.title }}</view>
  49. <view class="ms_dianzan">
  50. <view class="">
  51. <uni-icons type="star-filled" color="#4e7198" size="20"></uni-icons>
  52. <text>1.5w</text>
  53. </view>
  54. <view class="">
  55. <uni-icons type="heart-filled" color="#ca5642" size="20"></uni-icons>
  56. <text>1.5w</text>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. let that;
  66. export default {
  67. data() {
  68. return {
  69. formattedCurrentTime: '',
  70. main_body_id: '',
  71. list: {},
  72. shXiShuList: [
  73. {
  74. img: 'https://www.chinanews.com/tp/hd2011/2013/03-11/U508P4T426D182733F16470DT20130311112416.jpg',
  75. title: '闽南民俗浔浦天香日'
  76. },
  77. {
  78. img: 'https://inews.gtimg.com/newsapp_bt/0/11032609926/1000',
  79. title: '闽南冬至丸'
  80. },
  81. {
  82. img: 'https://img1.baidu.com/it/u=1711973128,1321603179&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=333',
  83. title: '闽南习俗拜天公'
  84. },
  85. {
  86. img: 'https://i2.hdslb.com/bfs/archive/24ab948019ae5cc13055113cfcd5321f7c16dc41.jpg',
  87. title: '抬神'
  88. }
  89. ]
  90. };
  91. },
  92. filters: {
  93. removeHTMLTag(str) {
  94. str = str.replace(/<\/?[^>]*>/g, ''); // 去除HTML tag
  95. str = str.replace(/[ | ]*\n/g, '\n'); // 去除行尾空白
  96. str = str.replace(/\n[\s| | ]*\r/g, '\n'); //去除多余空行
  97. // str = str.replace(/ /gi, ''); // 去掉
  98. const arrEntities = {
  99. lt: '<',
  100. gt: '>',
  101. nbsp: ' ',
  102. amp: '&',
  103. quot: '"'
  104. }; // 转义符换成普通字符
  105. str = str.replace(/&(lt|gt|nbsp|amp|quot);/gi, function (all, t) {
  106. return arrEntities[t];
  107. });
  108. return str;
  109. }
  110. },
  111. onLoad(o) {
  112. that = this;
  113. this.main_body_id = this.$db.get('main_body_id');
  114. this.getContentDetails(o.id);
  115. },
  116. mounted() {
  117. this.updateCurrentTime();
  118. },
  119. methods: {
  120. // 详情
  121. getContentDetails(id) {
  122. this.$api.getContentDetails(
  123. {
  124. main_body_id: this.main_body_id,
  125. id: id
  126. },
  127. function (res) {
  128. that.list = res.data;
  129. console.log(that.list, '99999999');
  130. }
  131. );
  132. },
  133. // 收藏
  134. collect() {
  135. if (this.list.is_collect == 0) {
  136. this.$api.collect(
  137. {
  138. main_body_id: this.main_body_id,
  139. content_id: this.list.id
  140. },
  141. function (res) {
  142. that.$nextTick(() => {
  143. that.list.is_collect = 1;
  144. that.list.collects++;
  145. });
  146. that.$common.successToShow('成功收藏');
  147. }
  148. );
  149. } else {
  150. this.$api.uncollect(
  151. {
  152. main_body_id: that.main_body_id,
  153. content_ids: that.list.id
  154. },
  155. function (res) {
  156. that.$nextTick(() => {
  157. that.list.is_collect = 0;
  158. that.list.collects--;
  159. });
  160. that.$common.successToShow('取消收藏');
  161. }
  162. );
  163. }
  164. },
  165. // 点赞
  166. likeBtn() {
  167. if (this.list.is_like == 0) {
  168. this.$api.like(
  169. {
  170. main_body_id: this.main_body_id,
  171. content_id: this.list.id
  172. },
  173. function (res) {
  174. that.$nextTick(() => {
  175. that.list.is_like = 1;
  176. that.list.likes++;
  177. });
  178. that.$common.successToShow('成功点赞');
  179. }
  180. );
  181. } else {
  182. this.$api.unLike(
  183. {
  184. main_body_id: that.main_body_id,
  185. content_ids: that.list.id
  186. },
  187. function (res) {
  188. that.$nextTick(() => {
  189. that.list.is_like = 0;
  190. that.list.likes--;
  191. });
  192. that.$common.successToShow('取消点赞');
  193. }
  194. );
  195. }
  196. },
  197. leftClick() {
  198. uni.navigateBack({
  199. delta: 1
  200. });
  201. },
  202. updateCurrentTime() {
  203. const now = new Date();
  204. const year = now.getFullYear();
  205. const month = ('0' + (now.getMonth() + 1)).slice(-2);
  206. const date = ('0' + now.getDate()).slice(-2);
  207. const hours = ('0' + now.getHours()).slice(-2);
  208. const minutes = ('0' + now.getMinutes()).slice(-2);
  209. this.formattedCurrentTime = `${year}.${month}.${date} ${hours}:${minutes}`;
  210. // 如果需要实时更新时间,可以使用setInterval
  211. setInterval(this.updateCurrentTime, 1000);
  212. }
  213. }
  214. };
  215. </script>
  216. <style>
  217. .ms_dianzan {
  218. display: flex;
  219. justify-content: space-between;
  220. margin-top: 10rpx;
  221. }
  222. .box_r {
  223. display: flex;
  224. align-items: center;
  225. margin-right: 15rpx;
  226. }
  227. .sh_xs {
  228. margin: 32rpx;
  229. display: flex;
  230. flex-flow: wrap;
  231. justify-content: space-between;
  232. }
  233. .sh_xs_item {
  234. border-radius: 10rpx;
  235. background: #ffffff;
  236. margin-bottom: 35rpx;
  237. }
  238. .text-group_17 {
  239. width: 668rpx;
  240. /* height: 163rpx; */
  241. display: flex;
  242. flex-direction: column;
  243. justify-content: space-between;
  244. margin: 0 0 0 35rpx;
  245. }
  246. .text_2 {
  247. width: 668rpx;
  248. /* height: 121rpx; */
  249. overflow-wrap: break-word;
  250. color: rgba(49, 37, 32, 1);
  251. font-size: 48rpx;
  252. font-family: SourceHanSansCN-Bold;
  253. font-weight: 700;
  254. line-height: 72rpx;
  255. }
  256. .text_13 {
  257. width: 214rpx;
  258. height: 18rpx;
  259. overflow-wrap: break-word;
  260. color: rgba(153, 153, 153, 1);
  261. font-size: 24rpx;
  262. font-family: SourceHanSansCN-Regular;
  263. font-weight: normal;
  264. white-space: nowrap;
  265. line-height: 72rpx;
  266. /* margin-top: 80rpx; */
  267. }
  268. .block_3 {
  269. background-color: rgba(255, 255, 255, 1);
  270. width: 749rpx;
  271. margin-top: 60rpx;
  272. display: flex;
  273. flex-direction: column;
  274. }
  275. .text_3 {
  276. width: 685rpx;
  277. height: 400rpx;
  278. text-indent: 2rem;
  279. font-size: 0rpx;
  280. overflow: scroll;
  281. line-height: 48rpx;
  282. margin: 38rpx 0 0 42rpx;
  283. }
  284. .text_10 {
  285. width: 685rpx;
  286. height: 300rpx;
  287. /* overflow-wrap: break-word; */
  288. color: rgba(49, 37, 32, 1);
  289. font-size: 30rpx;
  290. line-height: 48rpx;
  291. }
  292. .box_3 {
  293. background-color: rgba(232, 242, 217, 1);
  294. height: 422rpx;
  295. margin-top: 46rpx;
  296. display: flex;
  297. flex-direction: column;
  298. width: 750rpx;
  299. }
  300. .box_4 {
  301. background-color: rgba(0, 0, 0, 0.15);
  302. width: 750rpx;
  303. height: 422rpx;
  304. display: flex;
  305. flex-direction: column;
  306. }
  307. .text-wrapper_1 {
  308. width: 684rpx;
  309. height: 378rpx;
  310. overflow-wrap: break-word;
  311. font-size: 0rpx;
  312. font-family: SourceHanSansCN-Bold;
  313. font-weight: 700;
  314. text-align: justifyLeft;
  315. line-height: 48rpx;
  316. margin: 42rpx 0 32rpx 42rpx;
  317. }
  318. .paragraph_1 {
  319. width: 684rpx;
  320. overflow-wrap: break-word;
  321. color: rgba(49, 37, 32, 1);
  322. font-size: 30rpx;
  323. font-family: SourceHanSansCN-Bold;
  324. font-weight: 700;
  325. text-align: left;
  326. line-height: 48rpx;
  327. }
  328. .paragraph_2 {
  329. width: 684rpx;
  330. margin-bottom: 10rpx;
  331. text-indent: 2rem;
  332. overflow-wrap: break-word;
  333. color: rgba(49, 37, 32, 1);
  334. font-size: 30rpx;
  335. font-family: SourceHanSansCN-Regular;
  336. font-weight: normal;
  337. line-height: 48rpx;
  338. }
  339. .paragraph_5 {
  340. width: 684rpx;
  341. height: 378rpx;
  342. overflow-wrap: break-word;
  343. color: rgba(49, 37, 32, 1);
  344. font-size: 30rpx;
  345. font-family: SourceHanSansCN-Regular;
  346. font-weight: normal;
  347. line-height: 14rpx;
  348. }
  349. .paragraph_6 {
  350. width: 684rpx;
  351. text-indent: 2rem;
  352. overflow-wrap: break-word;
  353. color: rgba(49, 37, 32, 1);
  354. font-size: 30rpx;
  355. font-family: SourceHanSansCN-Regular;
  356. font-weight: normal;
  357. line-height: 48rpx;
  358. }
  359. .text_5 {
  360. width: 111rpx;
  361. height: 28rpx;
  362. overflow-wrap: break-word;
  363. color: rgba(49, 37, 32, 1);
  364. font-size: 28rpx;
  365. font-weight: 700;
  366. margin-bottom: 20rpx;
  367. white-space: nowrap;
  368. line-height: 28rpx;
  369. margin: 50rpx 0 0 48rpx;
  370. }
  371. .box_35 {
  372. height: 32rpx;
  373. flex-direction: row;
  374. display: flex;
  375. margin: 50rpx 0 32rpx 380rpx;
  376. }
  377. </style>