newDetail.vue 11 KB

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