detail.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <view class="detail">
  3. <view class="zs-header" :style="{height:statusBarHeight+navBareight +'px'}" @click="back">
  4. <image class="back" src="@/static/back-btn.png" mode=""></image>
  5. <view class="author-info">
  6. <image class="head" :src="info.head" mode=""></image>
  7. <view class="user-name">
  8. {{info.userName}}
  9. </view>
  10. </view>
  11. </view>
  12. <!-- <image class="banner" :class="[tall?'tall':'']" :src="info.src" mode=""></image> -->
  13. <view class="container" :style="{paddingTop:statusBarHeight+navBareight +'px'}">
  14. <view class="content">
  15. <view class="title">
  16. {{info.communityTitle}}
  17. </view>
  18. <rich-text class="rich-text" :nodes="info.communityDetail"></rich-text>
  19. <!-- <view class="text">
  20. “跨过这片海,我们终究会相遇”
  21. 这个季节,澜洲岛的海风很舒服
  22. 既不热,也不太凉,穿连衣裙只刚刚好
  23. 和朋友一起从重庆自驾。到涸洲岛
  24. 自由省愚,自驾的感觉太棒啦!
  25. 给姐妹疆们分享一下
  26. 我的涸洲岛自驾6 日行程
  27. 就这样玩,绝绝子~
  28. </view> -->
  29. <view class="time-box">
  30. <view class="time">
  31. {{info.createTime}}
  32. </view>
  33. <view class="address">
  34. 四川
  35. </view>
  36. </view>
  37. </view>
  38. <!-- 评论列表 -->
  39. <view class="comment">
  40. <view class="title">
  41. 共3条评论
  42. </view>
  43. <zs-list mt="0" @load="loadMore" :status="status">
  44. <view class="comment-item" v-for="(item,index) in list" :key="index">
  45. <image class="head" :src="item.head" mode=""></image>
  46. <view class="info">
  47. <view class="user-name">
  48. {{item.userName}}
  49. </view>
  50. <view class="comment-text">
  51. {{item.content}}
  52. </view>
  53. <view class="time-box">
  54. <view class="time">
  55. {{item.createTime}}
  56. </view>
  57. <view class="address">
  58. {{item.ip}}
  59. </view>
  60. </view>
  61. </view>
  62. <view class="reply">
  63. 回复
  64. </view>
  65. </view>
  66. </zs-list>
  67. </view>
  68. </view>
  69. <view class="operate-box">
  70. <view class="input-box">
  71. <image class="write" src="../../static/write.png" mode=""></image>
  72. <input confirm-type="send" class="input" type="text" placeholder="说点什么吧..." v-model="text" @confirm="send" />
  73. </view>
  74. <view class="box">
  75. <view class="icon-box">
  76. <image class="icon" @click="handleLike" :src="info.isLike?require('../../static/like.png'):require('../../static/unLike.png')" mode=""></image>
  77. <view class="num">
  78. 999
  79. </view>
  80. </view>
  81. <view class="icon-box">
  82. <image class="icon" src="../../static/comment.png" mode=""></image>
  83. <view class="num">
  84. 999
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </template>
  91. <script>
  92. import {detail,likes,getLikes} from '@/api/study.js';
  93. export default {
  94. data() {
  95. return {
  96. id:0,
  97. text:'',
  98. info:{
  99. communityTitle:'',
  100. createTime:'',
  101. head:'',
  102. userName:'',
  103. communityDetail:'',
  104. likeCount:'',
  105. viewedCount:'',
  106. isLike:false,
  107. },
  108. tall:false,
  109. statusBarHeight:20,//顶部状态栏高度
  110. navBareight: 45,//导航栏高度
  111. status: 'noMore',
  112. list:[
  113. {
  114. head:require('../../static/logo.png'),
  115. userName:'李老师',
  116. content:'继续加油哦,看好你!',
  117. createTime:'2023-08-29 21:13:56 ',
  118. ip:'成都市',
  119. }
  120. ]
  121. }
  122. },
  123. methods: {
  124. getLikes(){
  125. let userInfo = JSON.parse(uni.getStorageSync('userInfo'))
  126. if(!userInfo) return this.info.isLike = false
  127. let userId = userInfo.userId
  128. getLikes({communityItemId:this.id,userId}).then(res=>{
  129. if(res.state == 'Success'){
  130. }
  131. })
  132. },
  133. handleLike(){
  134. // if(uni.getStorageSync('token')){
  135. // likes({communityItemId:this.id,}).then(res=>{
  136. // if(res.state == 'Success'){
  137. // }
  138. // })
  139. // }else{
  140. // }
  141. },
  142. send(val){
  143. console.log(val);
  144. this.list.push({
  145. head:require('../../static/logo.png'),
  146. userName:'李老师',
  147. content:val.detail.value,
  148. createTime:uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss'),
  149. ip:'成都市',
  150. })
  151. },
  152. back(){
  153. var pages = getCurrentPages();
  154. if(pages.length == 1){
  155. uni.switchTab({
  156. url:'/pages/index/index'
  157. })
  158. }else{
  159. uni.navigateBack();
  160. }
  161. },
  162. loadMore() {
  163. },
  164. detail(tabId){
  165. detail({tabId}).then(res=>{
  166. if(res.state == 'Success'){
  167. this.info.communityTitle = res.content.communityTitle
  168. this.info.createTime = res.content.createTime
  169. this.info.likeCount = res.content.likeCount
  170. this.info.viewedCount = res.content.viewedCount
  171. this.info.communityDetail = res.content.communityDetail.replace(/<img/gi, '<img class="img_class" ')
  172. console.log(this.info);
  173. }
  174. })
  175. }
  176. },
  177. onLoad(options) {
  178. this.id = options.id
  179. this.detail(options.id)
  180. let that = this
  181. const eventChannel = this.getOpenerEventChannel();
  182. if(JSON.stringify(eventChannel) !=='{}'){
  183. eventChannel.on('detail', function(data) {
  184. that.info.userName = '官方'
  185. that.info.head = data.publishLogo || require('../../static/logo.png')
  186. })
  187. }
  188. },
  189. created() {
  190. //获取手机系统信息 -- 状态栏高度
  191. let {
  192. statusBarHeight,
  193. } = uni.getSystemInfoSync()
  194. this.statusBarHeight = statusBarHeight
  195. //去除
  196. //#ifndef H5 || MP-ALIPAY ||APP-PLUS
  197. //获取小程序胶囊的高度
  198. let {
  199. top,
  200. bottom,
  201. left
  202. } = uni.getMenuButtonBoundingClientRect()
  203. //高度 =(胶囊底部高低-状态栏高度)+(胶囊顶部高度-状态栏内的高度)
  204. this.navBareight = (bottom - statusBarHeight) + (top - statusBarHeight)
  205. //#endif
  206. }
  207. }
  208. </script>
  209. <style lang="scss" >
  210. .detail{
  211. .zs-header{
  212. position: fixed;
  213. width: 100%;
  214. top: 0;
  215. left: 0;
  216. background: #fff;
  217. z-index: 999;
  218. display: flex;
  219. align-items: flex-end;
  220. box-sizing: border-box;
  221. padding: 6px 6px 0 20rpx;
  222. transition: background .3s ease-in-out;
  223. .back {
  224. width: 30rpx;
  225. height: 30rpx;
  226. position: absolute;
  227. bottom: 10px;
  228. left: 20rpx;
  229. }
  230. .author-info{
  231. display: flex;
  232. align-items: center;
  233. margin-left: 40rpx;
  234. .head{
  235. width: 64rpx;
  236. height: 64rpx;
  237. border-radius: 50%;
  238. }
  239. .user-name{
  240. font-weight: bold;
  241. color: #222222;
  242. font-size: 28rpx;
  243. margin-left: 12rpx;
  244. }
  245. }
  246. }
  247. .banner{
  248. width: 100%;
  249. height: 750rpx;
  250. }
  251. .banner.tall{
  252. height: 1000rpx;
  253. }
  254. .container{
  255. padding: 0 30rpx;
  256. .content{
  257. border-bottom: 1rpx solid #F0F0F0;
  258. .title{
  259. font-size: 32rpx;
  260. font-weight: bold;
  261. color: #222222;
  262. margin: 28rpx 0;
  263. }
  264. .rich-text{
  265. color: #222222;
  266. .img_class{
  267. max-width: 100%!important;
  268. }
  269. }
  270. .text{
  271. color: #222222;
  272. font-size: 28rpx;
  273. line-height: 40rpx;
  274. }
  275. .time-box{
  276. display: flex;
  277. align-items: center;
  278. font-size: 20rpx;
  279. color: #AAAAAA;
  280. margin: 28rpx 0;
  281. .address{
  282. margin-left: 16rpx;
  283. }
  284. }
  285. }
  286. .comment{
  287. .title{
  288. font-weight: bold;
  289. color: #222222;
  290. font-size: 24rpx;
  291. margin: 28rpx 0 20rpx;
  292. }
  293. .comment-item{
  294. display: flex;
  295. padding: 20rpx 0;
  296. border-bottom: 1rpx solid #F0F0F0;
  297. .head{
  298. width: 64rpx;
  299. height: 64rpx;
  300. border-radius: 50%;
  301. align-self: flex-start;
  302. }
  303. .info{
  304. flex: 1;
  305. margin-left: 22rpx ;
  306. .user-name{
  307. color: #AAAAAA;
  308. font-size: 24rpx;
  309. }
  310. .comment-text{
  311. color: #222222;
  312. font-size: 24rpx;
  313. margin-top: 12rpx;
  314. }
  315. .time-box{
  316. display: flex;
  317. align-items: center;
  318. font-size: 24rpx;
  319. color: #AAAAAA;
  320. margin: 12rpx 0;
  321. .address{
  322. margin-left: 16rpx;
  323. }
  324. }
  325. }
  326. .reply{
  327. color: #CCCCCC;
  328. font-size: 24rpx;
  329. }
  330. }
  331. }
  332. }
  333. .operate-box{
  334. position: fixed;
  335. bottom: 0%;
  336. left: 0%;
  337. padding: 30rpx 30rpx 60rpx;
  338. background: #fff;
  339. width: 100%;
  340. border-top: 1rpx solid #F0F0F0;
  341. display: flex;
  342. align-items: center;
  343. .input-box{
  344. width: 376rpx;
  345. height: 60rpx;
  346. background: #F6F6F6;
  347. border-radius: 30rpx;
  348. position: relative;
  349. .write{
  350. width: 40rpx;
  351. height: 40rpx;
  352. position: absolute;
  353. top: 50%;
  354. left: 24rpx;
  355. transform: translateY(-50%);
  356. }
  357. .input{
  358. width: 100%;
  359. height: 60rpx;
  360. line-height: 60rpx;
  361. padding-left: 80rpx;
  362. box-sizing: border-box;
  363. color: #AAAAAA;
  364. font-size: 28rpx;
  365. }
  366. }
  367. .box{
  368. flex: 1;
  369. display: flex;
  370. align-items: center;
  371. margin-left: 26rpx;
  372. .icon-box{
  373. display: flex;
  374. align-items: center;
  375. flex: 1;
  376. .icon{
  377. width: 40rpx;
  378. height: 40rpx;
  379. }
  380. .num{
  381. color: #222222;
  382. font-size: 28rpx;
  383. margin-left: 10rpx;
  384. }
  385. }
  386. }
  387. }
  388. }
  389. </style>