article.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <template>
  2. <view class="content">
  3. <view class="status_bar" :style="{height: statusBarHeight}"></view>
  4. <view class="top-block">
  5. <view class="left">
  6. <image class="w64 h64 " src="/static/images/back_black.png"></image>
  7. <image class="head" src="/static/images/img.png"></image>
  8. <text class="name">芳华悦选</text>
  9. </view>
  10. <view class="right">
  11. <view class="icon-bg">
  12. <image class="w40 h40" src="/static/images/share-icon.png"></image>
  13. </view>
  14. <view class="icon-bg">
  15. <image class="w40 h40" src="/static/images/shopping_car.png"></image>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 文章 -->
  20. <view class="article">
  21. <image class="photo" src="/static/images/img.png"></image>
  22. <view class="article-main">
  23. <view class="title">秋季常见问题儿科专家直播</view>
  24. <view class="txt">
  25. <text>秋意渐浓,凉爽的秋风不仅带来了宜人的景色,也悄然引发了儿童鼻炎的高发期。鼻塞、流涕、打喷嚏……这些看似不起眼的症状,却可能严重影响孩子们的日常生活和学习。#儿童鼻炎的高发期</text>
  26. <text class="lable">#儿童鼻炎的高发期</text>
  27. </view>
  28. <view class="card">
  29. <view class="card-item">
  30. <image class="card-icon" src="/static/images/jinbang_font.png"></image>
  31. <text class="ranking">24小时热门榜</text>
  32. <text class="top">TOP.3</text>
  33. </view>
  34. <image class="go" src="/static/images/jb_arrow_right_icon.png"></image>
  35. </view>
  36. <view class="place">5天前 重庆</view>
  37. </view>
  38. </view>
  39. <view class="line"></view>
  40. <!-- 评论 -->
  41. <view class="comment">
  42. <view class="comment-num">
  43. <text>共 124 条评论</text>
  44. <image class="w24 h24 ml10" src="/static/images/comment-icon.png"></image>
  45. </view>
  46. <!--可评论输入框 -->
  47. <view class="my-input">
  48. <image class="head" src="/static/images/img.png"></image>
  49. <view class="input-item">
  50. <input class="input" placeholder="说点什么..." />
  51. <image class="w40 h40" src="/static/images/emoticon_icon.png"></image>
  52. </view>
  53. </view>
  54. <!-- 消息 -->
  55. <view class="message">
  56. <view class="message-item">
  57. <view class="left">
  58. <image class="head" src="/static/images/img.png"></image>
  59. <view class="column">
  60. <view class="chat">
  61. <view class="name">
  62. <text>爱吃土豆</text>
  63. </view>
  64. <view class="flex-wrap">
  65. <view class="txt">孩子鼻炎很严重,能不能治好呀?</view>
  66. <view class="info">
  67. <text class="time">1小时前 重庆</text>
  68. <view class="reply">回复</view>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="left mt26">
  73. <image class="head-little" src="/static/images/img.png"></image>
  74. <view class="chat">
  75. <view class="name">
  76. <text>爱吃土豆</text>
  77. <view class="author-lable">作者</view>
  78. </view>
  79. <view class="flex-wrap">
  80. <view class="txt">请告诉一下具体症状</view>
  81. <view class="info">
  82. <text class="time">1小时前 重庆</text>
  83. <view class="reply">回复</view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="expand">展开 2 条回复</view>
  89. </view>
  90. </view>
  91. <view class="right">
  92. <image v-if="isLike" class="w40 h40" src="/static/images/like_red_icon.png" @click="onLike">
  93. </image>
  94. <image v-else class="w40 h40" src="/static/images/like_icon.png" @click="onLike"></image>
  95. <view class="">20</view>
  96. </view>
  97. </view>
  98. <view class="message-item">
  99. <view class="left">
  100. <image class="head" src="/static/images/img.png"></image>
  101. <view class="column">
  102. <view class="chat">
  103. <view class="name">
  104. <text>爱吃土豆</text>
  105. </view>
  106. <view class="flex-wrap">
  107. <view class="txt">孩子鼻炎很严重,能不能治好呀?</view>
  108. <view class="info">
  109. <text class="time">1小时前 重庆</text>
  110. <view class="reply">回复</view>
  111. </view>
  112. </view>
  113. </view>
  114. <view class="left mt26">
  115. <image class="head-little" src="/static/images/img.png"></image>
  116. <view class="chat">
  117. <view class="name">
  118. <text>爱吃土豆</text>
  119. <view class="author-lable">作者</view>
  120. </view>
  121. <view class="flex-wrap">
  122. <view class="txt">请告诉一下具体症状</view>
  123. <view class="info">
  124. <text class="time">1小时前 重庆</text>
  125. <view class="reply">回复</view>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. <view class="expand">展开 2 条回复</view>
  131. </view>
  132. </view>
  133. <view class="right">
  134. <image v-if="isLike" class="w40 h40" src="/static/images/like_red_icon.png" @click="onLike">
  135. </image>
  136. <image v-else class="w40 h40" src="/static/images/like_icon.png" @click="onLike"></image>
  137. <view class="">20</view>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. <!-- 输入框 -->
  143. <view class="chat-input-container">
  144. <view class=" input-container">
  145. <input id="txgMsg" placeholder="说点什么..." v-model="inputValue" placeholder-style="color:#999999;"
  146. class="ml20 input-native input-field" cursor-spacing="100" :adjust-position="false" />
  147. </view>
  148. <view class="icon-container">
  149. <view class="icon-item">
  150. <image v-if="isLike" class="icon" src="/static/images/like_red_icon.png" />
  151. <image v-else class="icon" src="/static/images/like_icon.png" />
  152. <text>8</text>
  153. </view>
  154. <view class="icon-item">
  155. <image v-if="isLike" class="icon" src="/static/images/collection_yellow.png" />
  156. <image v-else class="icon" src="/static/images/collection.png" />
  157. <text>10</text>
  158. </view>
  159. <view class="icon-item">
  160. <image class="icon" src="/static/images/comment.png" />
  161. <text>200</text>
  162. </view>
  163. </view>
  164. </view>
  165. </view>
  166. </template>
  167. <script>
  168. import Task from '@/components/task.vue'
  169. import {
  170. listRootComments, // 一级评论列表
  171. listSubComments, //二级评论列表
  172. toggleLike, //内容点赞/取消点赞
  173. toggleLikeComments, //评论点赞
  174. share //内容分享
  175. } from '@/api/life.js'
  176. export default {
  177. data() {
  178. return {
  179. resourceId: null,
  180. // 状态栏的高度
  181. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  182. isLike: false
  183. }
  184. },
  185. onLoad() {
  186. this.getListRootComments();
  187. },
  188. onUnload() {
  189. },
  190. methods: {
  191. onLike() {
  192. this.isLike = !this.isLike;
  193. },
  194. // 一级评论列表
  195. getListRootComments() {
  196. if (!this.resourceId) return;
  197. let data = {
  198. page: 1,
  199. pageSize: 10,
  200. resourceId: this.resourceId
  201. }
  202. listRootComments(data).then(res => {
  203. if (res.code == 200) {
  204. console.log("一级评论列表", res)
  205. } else {
  206. uni.showToast({
  207. title: res.msg,
  208. icon: 'none'
  209. });
  210. }
  211. }).catch(err => {});
  212. },
  213. // 二级评论列表
  214. getListSubComments() {
  215. if (!this.resourceId) return;
  216. let data = {
  217. page: 1,
  218. pageSize: 10,
  219. resourceId: this.resourceId
  220. }
  221. listSubComments(data).then(res => {
  222. if (res.code == 200) {
  223. console.log("二级评论列表", res)
  224. } else {
  225. uni.showToast({
  226. title: res.msg,
  227. icon: 'none'
  228. });
  229. }
  230. }).catch(err => {});
  231. },
  232. // 内容点赞/取消点赞
  233. toggleLike() {
  234. if (!this.resourceId) return;
  235. let data = {
  236. action: LIKE, //LIKE / UNLIKE
  237. resourceId: this.resourceId
  238. }
  239. toggleLike(data).then(res => {
  240. if (res.code == 200) {
  241. console.log("内容点赞/取消点赞", res)
  242. } else {
  243. uni.showToast({
  244. title: res.msg,
  245. icon: 'none'
  246. });
  247. }
  248. }).catch(err => {});
  249. },
  250. // 内容分享
  251. share() {
  252. if (!this.resourceId) return;
  253. let data = {
  254. resourceId: this.resourceId
  255. }
  256. share(data).then(res => {
  257. if (res.code == 200) {
  258. console.log("内容分享", res)
  259. } else {
  260. uni.showToast({
  261. title: res.msg,
  262. icon: 'none'
  263. });
  264. }
  265. }).catch(err => {});
  266. },
  267. // 评论点赞
  268. toggleLikeComments() {
  269. if (!this.resourceId) return;
  270. let data = {
  271. resourceId: this.resourceId
  272. }
  273. toggleLikeComments(data).then(res => {
  274. if (res.code == 200) {
  275. console.log("内容分享", res)
  276. } else {
  277. uni.showToast({
  278. title: res.msg,
  279. icon: 'none'
  280. });
  281. }
  282. }).catch(err => {});
  283. },
  284. // 发表评论
  285. getPostComment() {
  286. let data = {
  287. content: this.content,
  288. parentId: this.parentId || '', //父评论ID(回复必填,一级不填)
  289. resourceId: this.resourceId //业务ID (文章ID / 视频ID )
  290. }
  291. postComment(data).then(res => {
  292. if (res.code == 200) {
  293. console.log("发表评论", res)
  294. } else {
  295. uni.showToast({
  296. title: res.msg,
  297. icon: 'none'
  298. });
  299. }
  300. }).catch(err => {});
  301. },
  302. }
  303. }
  304. </script>
  305. <style lang="scss" scoped>
  306. .content {
  307. min-height: 100vh;
  308. background: #ffffff;
  309. position: relative;
  310. .top-block {
  311. padding-left: 24rpx;
  312. display: flex;
  313. justify-content: space-between;
  314. align-items: center;
  315. .left {
  316. display: flex;
  317. align-items: center;
  318. .head {
  319. width: 68rpx;
  320. height: 68rpx;
  321. border-radius: 34rpx 34rpx 34rpx 34rpx;
  322. margin: 0 16rpx;
  323. }
  324. .name {
  325. font-weight: 500;
  326. font-size: 32rpx;
  327. color: #333333;
  328. }
  329. }
  330. .right {
  331. display: flex;
  332. align-items: center;
  333. margin-right: 210rpx;
  334. .icon-bg {
  335. width: 64rpx;
  336. height: 64rpx;
  337. padding: 12rpx;
  338. border-radius: 32rpx 32rpx 32rpx 32rpx;
  339. border: 1rpx solid #E9E9E9;
  340. box-sizing: border-box;
  341. background: #FFFFFF;
  342. margin-left: 24rpx;
  343. }
  344. }
  345. .title-box {
  346. position: relative;
  347. .title {
  348. font-weight: 600;
  349. font-size: 40rpx;
  350. color: #333333;
  351. }
  352. }
  353. }
  354. // 文章
  355. .article {
  356. display: flex;
  357. flex-direction: column;
  358. margin-top: 30rpx;
  359. .photo {
  360. width: 100%;
  361. height: 416rpx;
  362. }
  363. .article-main {
  364. padding: 0 24rpx;
  365. .title {
  366. margin: 18rpx 0 32rpx;
  367. font-weight: 500;
  368. font-size: 36rpx;
  369. color: #333333;
  370. }
  371. .txt {
  372. font-size: 30rpx;
  373. color: #333333;
  374. .lable {
  375. color: #153868;
  376. margin-left: 8rpx;
  377. }
  378. }
  379. .card {
  380. display: flex;
  381. justify-content: space-between;
  382. align-items: center;
  383. background: #FFF5EB;
  384. width: 100%;
  385. height: 64rpx;
  386. border-radius: 8rpx;
  387. border: 1rpx solid #F3E2D0;
  388. padding: 16rpx;
  389. box-sizing: border-box;
  390. margin: 22rpx 0 32rpx; // 添加边距
  391. .card-item {
  392. display: flex;
  393. align-items: center;
  394. color: #D46C0D;
  395. .card-icon {
  396. width: 60rpx;
  397. height: 32rpx;
  398. margin-right: 24rpx;
  399. }
  400. .ranking {
  401. font-size: 24rpx;
  402. }
  403. .top {
  404. font-family: Roboto Flex, Roboto Flex;
  405. font-weight: normal;
  406. font-size: 24rpx;
  407. transform: skewX(-8deg);
  408. display: inline-block;
  409. margin-left: 8rpx;
  410. }
  411. }
  412. .go {
  413. width: 16rpx;
  414. height: 16rpx;
  415. }
  416. }
  417. .place {
  418. font-size: 24rpx;
  419. color: #999999;
  420. }
  421. }
  422. }
  423. .line {
  424. margin: 32rpx 0;
  425. width: 100%;
  426. height: 0rpx;
  427. border: 1rpx solid #EEEEEE;
  428. }
  429. // 评论
  430. .comment {
  431. display: flex;
  432. flex-direction: column;
  433. padding: 0 24rpx 120rpx;
  434. .comment-num {
  435. display: flex;
  436. align-items: center;
  437. font-weight: 500;
  438. font-size: 28rpx;
  439. color: #333333;
  440. margin-bottom: 30rpx;
  441. }
  442. .my-input {
  443. display: flex;
  444. margin-bottom: 40rpx;
  445. .head {
  446. width: 68rpx;
  447. height: 68rpx;
  448. margin-right: 24rpx;
  449. border-radius: 50%;
  450. flex-shrink: 0;
  451. }
  452. .input-item {
  453. flex: 1;
  454. display: flex;
  455. align-items: center;
  456. background: #F5F7FA;
  457. padding: 0 24rpx;
  458. border-radius: 34rpx;
  459. .input {
  460. flex: 1;
  461. }
  462. }
  463. }
  464. .message {
  465. display: flex;
  466. flex-direction: column;
  467. .message-item {
  468. display: flex;
  469. justify-content: space-between;
  470. margin-bottom: 40rpx;
  471. .left {
  472. display: flex;
  473. .head {
  474. width: 68rpx;
  475. height: 68rpx;
  476. margin-right: 24rpx;
  477. border-radius: 50%;
  478. flex-shrink: 0;
  479. }
  480. .head-little {
  481. width: 48rpx;
  482. height: 48rpx;
  483. margin-right: 16rpx;
  484. border-radius: 50%;
  485. flex-shrink: 0;
  486. }
  487. .chat {
  488. .name {
  489. font-size: 26rpx;
  490. color: #999999;
  491. display: flex;
  492. .author-lable {
  493. width: 62rpx;
  494. height: 32rpx;
  495. background: #E0FFF4;
  496. border-radius: 16rpx;
  497. text-align: center;
  498. line-height: 32rpx;
  499. font-weight: 500;
  500. font-size: 18rpx;
  501. color: #02B176;
  502. margin-left: 14rpx;
  503. }
  504. }
  505. .flex-wrap {
  506. display: flex;
  507. flex-wrap: wrap;
  508. align-items: center;
  509. .txt {
  510. font-size: 28rpx;
  511. color: #333333;
  512. margin: 12rpx 24rpx 12rpx 0;
  513. }
  514. .info {
  515. font-size: 24rpx;
  516. display: flex;
  517. .time {
  518. color: #999999;
  519. }
  520. .reply {
  521. color: #666666;
  522. margin-left: 22rpx;
  523. }
  524. }
  525. }
  526. }
  527. }
  528. .expand {
  529. font-size: 26rpx;
  530. color: #153868;
  531. padding: 0 64rpx;
  532. }
  533. .right {
  534. display: flex;
  535. flex-direction: column;
  536. align-items: center;
  537. font-size: 24rpx;
  538. color: #666666;
  539. }
  540. }
  541. }
  542. }
  543. // 输入框
  544. .chat-input-container {
  545. display: flex;
  546. justify-content: space-between;
  547. align-items: center;
  548. height: 100rpx;
  549. box-sizing: border-box;
  550. padding: 20rpx 24rpx;
  551. width: 100%;
  552. box-sizing: border-box;
  553. position: fixed;
  554. bottom: 0;
  555. background-color: #ffffff;
  556. border-top: 1rpx solid #EEEEEE;
  557. .input-container {
  558. background: #F5F7FA;
  559. height: 68rpx;
  560. box-sizing: border-box;
  561. border-radius: 36rpx;
  562. display: flex;
  563. align-items: center;
  564. overflow: hidden;
  565. margin-right: 20rpx;
  566. }
  567. .icon-container {
  568. display: flex;
  569. align-items: center;
  570. .icon-item {
  571. display: flex;
  572. align-items: center;
  573. margin-right: 42rpx;
  574. &:last-child {
  575. margin-right: 0rpx;
  576. }
  577. .icon {
  578. width: 48rpx;
  579. height: 48rpx;
  580. margin-right: 8rpx;
  581. }
  582. }
  583. }
  584. }
  585. }
  586. </style>