ggDetail.vue 11 KB

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