newDetail.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <template>
  2. <view class="content">
  3. <view class="tile">{{pageData.title}}</view>
  4. <view class="hflex acenter " style="box-sizing: border-box;padding: 0 30rpx;">
  5. <view class="img_box">
  6. <image :src="pageData.user.avatar" mode="aspectFill" class="avatar"></image>
  7. <view class="type">V</view>
  8. </view>
  9. <view class="text_style1">{{pageData.user.username}}</view>
  10. </view>
  11. <!-- <image :src="pageData.img" class="img" v-if="pageData.image"></image> -->
  12. <u-parse :content="pageData.content" style="box-sizing: border-box;padding: 0 30rpx;"></u-parse>
  13. <!-- <video :src="pageData.video" play-btn-position="center" class="video" v-if="pageData.video"></video> -->
  14. <view class="date">发布于{{pageData.create_time}}</view>
  15. <view class="comment">
  16. <view class="comment_title">评论{{comment.total?comment.total:''}}</view>
  17. <view v-if="comment.total == 0" class="hflex acenter jcenter comment_none">暂无评论</view>
  18. <view v-else>
  19. <block v-for="(item,index) in comment.data" :key="index">
  20. <view class="hflex">
  21. <image :src="item.user.headimg" class="headimg"></image>
  22. <view class="comment_right">
  23. <view class="comment_name">{{item.user.nickname}}</view>
  24. <view class="comment_content">{{item.content}}</view>
  25. <view class="comment_date">{{item.create_time}}</view>
  26. </view>
  27. </view>
  28. </block>
  29. </view>
  30. </view>
  31. <view class="bottom hflex acenter jbetween">
  32. <view class="hflex acenter" @click="getLike">
  33. <image src="https://ship-expert.zhousi.hdlkeji.com/common/dianzan1.png" class="dianzan" v-if="!pageData.is_liked"></image>
  34. <image src="https://ship-expert.zhousi.hdlkeji.com/common/dianzan2.png" class="dianzan" v-else></image>
  35. <view class="dz_text">{{!pageData.is_liked?'点赞':pageData.likes_count}}</view>
  36. </view>
  37. <view class="hflex acenter ">
  38. <u-input v-model="message" border="none" placeholder="我来说两句" shape="circle"></u-input>
  39. <image src="https://ship-expert.zhousi.hdlkeji.com/common/comment.png" class="comment_icon" @click="send"></image>
  40. <view class="dz_text">{{comment.total == 0?'评论':comment.total}}</view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. import $api from '@/static/js/api.js'
  47. var that = ''
  48. export default {
  49. data() {
  50. return {
  51. pageData: {
  52. },
  53. message: '',
  54. name: '船百知官方账号',
  55. comment: [],
  56. id: '',
  57. page: 1,
  58. limit: 10,
  59. total: 10
  60. }
  61. },
  62. onLoad(options) {
  63. that = this
  64. that.id = options.id
  65. that.getData()
  66. },
  67. methods: {
  68. getData() {
  69. $api.req({
  70. url: '/data/api.Xw/show',
  71. data: {
  72. id: that.id
  73. }
  74. }, function(res) {
  75. if(res.code == 1) {
  76. that.pageData = res.data
  77. that.getComment()
  78. }
  79. })
  80. },
  81. getComment() {
  82. $api.req({
  83. url: '/data/api.Xw/comments',
  84. data: {
  85. id: that.id,
  86. page: that.page,
  87. limit: that.limit
  88. }
  89. }, function(res) {
  90. if(res.code == 1) {
  91. that.comment = res.data
  92. that.total = res.data.total
  93. }
  94. })
  95. },
  96. getLike() {
  97. var token = uni.getStorageSync('token')
  98. if(!token) {
  99. $api.info('请先登录')
  100. return
  101. }
  102. if(that.pageData.is_liked) {
  103. that.pageData.is_liked = 0
  104. that.pageData.likes_count -=1
  105. } else {
  106. that.pageData.is_liked = 1
  107. that.pageData.likes_count +=1
  108. }
  109. $api.req({
  110. url: '/data/api.Xw/like',
  111. data: {
  112. id: that.id
  113. }
  114. }, function(res) {
  115. if(res.code == 1) {
  116. $api.info(res.info)
  117. }
  118. })
  119. },
  120. send() {
  121. $api.req({
  122. url: '/data/api.Xw/comment',
  123. method: 'POST',
  124. data: {
  125. id: that.id,
  126. content: that.message
  127. }
  128. }, function(res) {
  129. if(res.code == 1) {
  130. that.message = ""
  131. $api.info(res.info)
  132. that.getComment()
  133. } else if(res.code == 0) {
  134. $api.info('请先登录')
  135. setTimeout(() => {
  136. $api.jump('/pages/login/code_login')
  137. }, 1000)
  138. }
  139. })
  140. },
  141. onReachBottom() {
  142. if (Number(that.page) * Number(that.limit) >= Number(that.total)) {
  143. $api.info("没有更多了")
  144. } else {
  145. that.page++
  146. that.getComment()
  147. }
  148. }
  149. },
  150. }
  151. </script>
  152. <style lang="scss" scoped>
  153. .content::v-deep {
  154. position: relative;
  155. background: url('https://ship-expert.zhousi.hdlkeji.com/common/background.png') no-repeat;
  156. background-size: 100%;
  157. .tile {
  158. box-sizing: border-box;
  159. padding: 24rpx 30rpx;
  160. font-size: 40rpx;
  161. font-weight: 500;
  162. color: #333333;
  163. line-height: 56rpx;
  164. }
  165. .img_box {
  166. width: 56rpx;
  167. height: 56rpx;
  168. position: relative;
  169. .avatar {
  170. width: 56rpx;
  171. height: 56rpx;
  172. border-radius: 50%;
  173. }
  174. .type {
  175. position: absolute;
  176. right: 0rpx;
  177. bottom: 0rpx;
  178. width: 28rpx;
  179. height: 28rpx;
  180. background: #506DFF;
  181. border-radius: 12rpx 4rpx 12rpx 4rpx;
  182. font-size: 20rpx;
  183. color: #fff;
  184. text-align: center;
  185. line-height: 28rpx;
  186. }
  187. }
  188. .text_style1 {
  189. margin-left: 16rpx;
  190. font-size: 26rpx;
  191. font-weight: 400;
  192. color: #222222;
  193. line-height: 36rpx;
  194. }
  195. .box {
  196. margin: 24rpx 30rpx;
  197. height: 116rpx;
  198. background: #F4F4F4;
  199. border-radius: 16rpx;
  200. box-sizing: border-box;
  201. padding: 24rpx 28rpx;
  202. .box_icon {
  203. width: 56rpx;
  204. height: 68rpx;
  205. }
  206. .down {
  207. width: 48rpx;
  208. height: 48rpx;
  209. border-radius: 50%;
  210. background: #506DFF;
  211. }
  212. }
  213. .date {
  214. // margin-bottom: 186rpx;
  215. box-sizing: border-box;
  216. padding: 0 30rpx 40rpx;
  217. border-bottom: 1rpx solid #F5F5F5;
  218. font-size: 26rpx;
  219. font-weight: 400;
  220. color: #989898;
  221. line-height: 18px;
  222. }
  223. .comment {
  224. width: 100%;
  225. box-sizing: border-box;
  226. padding: 40rpx 30rpx;
  227. margin-bottom: 186rpx;
  228. .comment_title {
  229. font-size: 32rpx;
  230. font-weight: 500;
  231. color: #222222;
  232. line-height: 44rpx;
  233. padding-bottom: 24rpx;
  234. }
  235. .comment_none {
  236. width: 100%;
  237. font-size: 32rpx;
  238. font-weight: 400;
  239. color: #AFAFAF;
  240. line-height: 44rpx;
  241. // padding-top: 24rpx;
  242. }
  243. .headimg {
  244. width: 68rpx;
  245. height: 68rpx;
  246. border-radius: 50%;
  247. }
  248. .comment_right {
  249. width: calc(100% - 88rpx);
  250. margin-left: 20rpx;
  251. padding: 0 0 20rpx;
  252. border-bottom: 1rpx solid #F2F2F2;
  253. }
  254. .comment_name {
  255. font-size: 24rpx;
  256. font-weight: 500;
  257. color: #222222;
  258. line-height: 34rpx;
  259. }
  260. .comment_content {
  261. font-size: 24rpx;
  262. font-weight: 400;
  263. color: #222222;
  264. line-height: 34rpx;
  265. padding: 16rpx 0 12rpx;
  266. }
  267. .comment_date {
  268. font-size: 20rpx;
  269. font-weight: 400;
  270. color: #999999;
  271. line-height: 28rpx;
  272. }
  273. }
  274. .bottom {
  275. width: 100%;
  276. z-index: 9;
  277. position: fixed;
  278. bottom: 0;
  279. height: 166rpx;
  280. background: #FFFFFF;
  281. box-sizing: border-box;
  282. padding: 8rpx 20rpx 74rpx;
  283. .dianzan {
  284. width: 48rpx;
  285. height: 48rpx;
  286. }
  287. .u-input {
  288. background: #F4F4F4 !important;
  289. width: 410rpx;
  290. height: 72rpx;
  291. margin-right: 16rpx;
  292. padding: 0 32rpx !important;
  293. }
  294. .dz_text {
  295. font-size: 26rpx;
  296. font-weight: 400;
  297. color: #333333;
  298. line-height: 36rpx;
  299. padding-left: 8rpx;
  300. }
  301. .comment_icon {
  302. width: 48rpx;
  303. height: 48rpx;
  304. }
  305. .btn {
  306. width: 510rpx;
  307. height: 80rpx;
  308. background: #506DFF;
  309. border-radius: 42rpx;
  310. font-size: 32rpx;
  311. font-weight: 500;
  312. color: #FFFFFF;
  313. line-height: 80rpx;
  314. text-align: center;
  315. }
  316. }
  317. .cCanvas {
  318. position: absolute;
  319. top: 188rpx;
  320. left: 50rpx;
  321. background-color: #fff;
  322. z-index: 100;
  323. border-radius: 20rpx;
  324. }
  325. .share_content {
  326. position: absolute;
  327. top: 0;
  328. left: 0;
  329. z-index: 99;
  330. width: 100vw;
  331. height: 100vh;
  332. background: rgba(0,0,0,0.5);
  333. backdrop-filter: blur(5px);
  334. .share_box {
  335. margin: 148rpx auto;
  336. width: 650rpx;
  337. background: #FFFFFF;
  338. border-radius: 20rpx;
  339. box-sizing: border-box;
  340. padding: 0 40rpx;
  341. .box_bottom {
  342. width: 100%;
  343. padding: 34rpx 0 16rpx;
  344. border-top: 1rpx dashed #C3C3C3;
  345. .bottom_left1 {
  346. font-size: 32rpx;
  347. font-weight: 500;
  348. color: #222222;
  349. line-height: 44rpx;
  350. padding-bottom: 20rpx;
  351. }
  352. .bottom_left2 {
  353. font-size: 22rpx;
  354. font-weight: 400;
  355. color: #999999;
  356. line-height: 32rpx;
  357. }
  358. .bottom_right {
  359. width: 136rpx;
  360. height: 136rpx;
  361. }
  362. }
  363. }
  364. .canvas {
  365. position: absolute;
  366. top: 188rpx;
  367. left: 50rpx;
  368. width: 650rpx;
  369. min-height: 494rpx;
  370. background: #FFFFFF;
  371. border-radius: 20rpx;
  372. }
  373. .share_bottom {
  374. position: fixed;
  375. bottom: 0;
  376. width: 100%;
  377. height: 388rpx;
  378. background: #F5F7FF;
  379. border-radius: 40rpx 40rpx 0px 0px;
  380. .bottom_item {
  381. width: 33%;
  382. margin: 50rpx 0 90rpx;
  383. border: none !important;
  384. background-color: #F5F7FF !important;
  385. .item_icon {
  386. width: 76rpx;
  387. height: 76rpx;
  388. }
  389. .item_text {
  390. font-size: 26rpx;
  391. font-weight: 400;
  392. color: #333333;
  393. line-height: 36rpx;
  394. margin-top: 12rpx;
  395. }
  396. }
  397. button::after {
  398. border: none !important;
  399. }
  400. .share_cancel {
  401. width: 100%;
  402. text-align: center;
  403. font-size: 32rpx;
  404. font-weight: 400;
  405. color: #333333;
  406. line-height: 44rpx;
  407. }
  408. }
  409. }
  410. .img {
  411. width: 100%;
  412. height: 320rpx;
  413. border-radius: 24rpx;
  414. margin: 40rpx 0 32rpx;
  415. }
  416. .video {
  417. width: 100%;
  418. height: 400rpx;
  419. border-radius: 28rpx;
  420. margin: 20rpx 0;
  421. }
  422. }
  423. </style>