article.vue 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021
  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="https://cdn.his.cdwjyyh.com/images/back_black.png" @click="goBack"></image>
  7. <image class="head" :src="lifeDetail.userInfo.avatar||'https://cdn.his.cdwjyyh.com/images/avatar.png'" @click="gotoExpertPage"></image>
  8. <text class="name">{{lifeDetail.userInfo.nickname}}</text>
  9. </view>
  10. <view class="right">
  11. <view class="icon-bg" @click="handleShareClick">
  12. <image class="w40 h40" src="https://cdn.his.cdwjyyh.com/images/share-icon.png"></image>
  13. </view>
  14. <view class="icon-bg">
  15. <image class="w40 h40" src="https://cdn.his.cdwjyyh.com/images/shopping_car.png"></image>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 文章 -->
  20. <view class="article">
  21. <image class="photo" :src="lifeDetail.imgsUrl"></image>
  22. <view class="article-main">
  23. <view class="title">{{lifeDetail.title}}</view>
  24. <view class="txt">
  25. <text>{{lifeDetail.content}}</text>
  26. <text class="lable">#儿童鼻炎的高发期</text>
  27. </view>
  28. <view class="card">
  29. <view class="card-item">
  30. <image class="card-icon" src="https://cdn.his.cdwjyyh.com/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="https://cdn.his.cdwjyyh.com/images/jb_arrow_right_icon.png"></image>
  35. </view>
  36. <view class="place">{{date}} {{lifeDetail.userInfo.addrIp}}</view>
  37. </view>
  38. </view>
  39. <view class="line"></view>
  40. <!-- 评论 -->
  41. <view class="comment">
  42. <view class="comment-num">
  43. <text>共 {{lifeDetail.commentsCount}}条评论</text>
  44. <image class="w24 h24 ml10" src="https://cdn.his.cdwjyyh.com/images/comment-icon.png"></image>
  45. </view>
  46. <!--可评论输入框 -->
  47. <view class="my-input">
  48. <image class="head" :src="userData.avatar||'https://cdn.his.cdwjyyh.com/images/avatar.png'"></image>
  49. <view class="input-item">
  50. <input class="input" placeholder="说点什么..." v-model="commentInput"
  51. @focus="showKeyboardInput = true" />
  52. <image class="w40 h40" src="https://cdn.his.cdwjyyh.com/images/emoticon_icon.png" @click="showEmojiPicker = true"></image>
  53. </view>
  54. </view>
  55. <!-- 消息 -->
  56. <view class="message">
  57. <view v-for="comment in rootComments" :key="comment.commentId" class="message-item">
  58. <view class="left">
  59. <image class="head" :src="comment.userInfo.avatar||'https://cdn.his.cdwjyyh.com/images/avatar.png'"></image>
  60. <view class="column">
  61. <view class="chat">
  62. <view class="name">
  63. <text>{{comment.userInfo.nickname}}</text>
  64. <view v-if="comment.userInfo.userId === lifeDetail.userInfo.userId" class="author-lable">作者</view>
  65. </view>
  66. <view class="flex-wrap">
  67. <view class="txt">{{comment.content}}</view>
  68. <view class="info">
  69. <text class="time">{{calculateTimeDiff(comment.createAt)}}</text>
  70. <view class="reply" @click="handleReply(comment)">回复</view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 二级评论 -->
  75. <view v-if="comment.children && comment.children.length > 0" class="left mt26">
  76. <image class="head-little" :src="comment.children[0].userInfo.avatar||'https://cdn.his.cdwjyyh.com/images/avatar.png'"></image>
  77. <view class="chat">
  78. <view class="name">
  79. <text>{{comment.children[0].userInfo.nickname}}</text>
  80. <view v-if="comment.children[0].userInfo.userId === lifeDetail.userInfo.userId" class="author-lable">作者</view>
  81. </view>
  82. <view class="flex-wrap">
  83. <view class="txt">{{comment.children[0].content}}</view>
  84. <view class="info">
  85. <text class="time">{{calculateTimeDiff(comment.children[0].createAt)}}</text>
  86. <view class="reply" @click="handleReply(comment.children[0])">回复</view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. <!-- 展开的二级评论 -->
  92. <view v-if="expandedComments[comment.commentId] && comment.children && comment.children.length > 1" class="mt26">
  93. <view v-for="(child, index) in comment.children.slice(1)" :key="child.commentId" class="left mt26">
  94. <image class="head-little" :src="child.userInfo.avatar||'https://cdn.his.cdwjyyh.com/images/avatar.png'"></image>
  95. <view class="chat">
  96. <view class="name">
  97. <text>{{child.userInfo.nickname}}</text>
  98. <view v-if="child.userInfo.userId === lifeDetail.userInfo.userId" class="author-lable">作者</view>
  99. </view>
  100. <view class="flex-wrap">
  101. <view class="txt">{{child.content}}</view>
  102. <view class="info">
  103. <text class="time">{{calculateTimeDiff(child.createAt)}}</text>
  104. <view class="reply" @click="handleReply(child)">回复</view>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. <view v-if="comment.children && comment.children.length > 1" class="expand" @click="toggleExpand(comment)">
  111. {{expandedComments[comment.commentId] ? '收起' : '展开 ' + (comment.children.length - 1) + ' 条回复'}}
  112. </view>
  113. </view>
  114. </view>
  115. <view class="right">
  116. <image v-if="comment.isLiked" class="w40 h40" src="https://cdn.his.cdwjyyh.com/images/like_red_icon.png" @click="toggleLikeComments(comment.commentId)">
  117. </image>
  118. <image v-else class="w40 h40" src="https://cdn.his.cdwjyyh.com/images/like_icon.png" @click="toggleLikeComments(comment.commentId,!comment.isLiked)"></image>
  119. <view class="">{{comment.likeCount}}</view>
  120. </view>
  121. </view>
  122. </view>
  123. </view>
  124. <!-- 输入框 -->
  125. <view class="chat-input-container">
  126. <view class=" input-container">
  127. <input id="txgMsg" placeholder="说点什么..." v-model="inputValue" placeholder-style="color:#999999;"
  128. class="ml20 input-native input-field" cursor-spacing="100" :adjust-position="false"
  129. @focus="showKeyboardInput = true" />
  130. </view>
  131. <view class="icon-container">
  132. <view class="icon-item" @click="handleContentLike">
  133. <image v-if="isLiked" class="icon" src="https://cdn.his.cdwjyyh.com/images/like_red_icon.png" />
  134. <image v-else class="icon" src="https://cdn.his.cdwjyyh.com/images/like_icon.png" />
  135. <text>{{lifeDetail.likeCount}}</text>
  136. </view>
  137. <view class="icon-item" @click="handleContentCollection">
  138. <image v-if="isCollected" class="icon" src="https://cdn.his.cdwjyyh.com/images/collection_yellow.png" />
  139. <image v-else class="icon" src="https://cdn.his.cdwjyyh.com/images/collection.png" />
  140. <text>{{lifeDetail.collectionCount}}</text>
  141. </view>
  142. <view class="icon-item" @click="handleCommentClick">
  143. <image class="icon" src="https://cdn.his.cdwjyyh.com/images/comment.png" />
  144. <text>{{lifeDetail.commentsCount}}</text>
  145. </view>
  146. </view>
  147. </view>
  148. <!-- 键盘上方的输入框 -->
  149. <view v-if="showKeyboardInput" class="keyboard-input-container">
  150. <view class="keyboard-input-item">
  151. <input placeholder="说点什么..." v-model="keyboardInput" placeholder-style="color:#999999;"
  152. class="keyboard-input" />
  153. <image class="w40 h40" src="https://cdn.his.cdwjyyh.com/images/emoticon_icon.png" @click="showEmojiPicker = true"></image>
  154. <view class="send-btn" @click="sendKeyboardComment">发送</view>
  155. </view>
  156. </view>
  157. <!-- 表情选择器 -->
  158. <EmojiPicker
  159. v-if="showEmojiPicker"
  160. @select="handleEmojiSelect"
  161. @close="showEmojiPicker = false"
  162. />
  163. </view>
  164. </template>
  165. <script>
  166. import Task from '@/components/task.vue'
  167. import EmojiPicker from '@/components/emoji-picker.vue'
  168. import {
  169. lifeDetail,
  170. listRootComments, // 一级评论列表
  171. listSubComments, //二级评论列表
  172. toggleLikeComments as apiToggleLikeComments, //评论点赞
  173. toggleLike, //内容点赞/取消点赞
  174. share, //内容分享
  175. toggleCollection,//内容收藏/取消收藏点赞
  176. postComment //发表评论
  177. } from '@/api/life.js'
  178. import {
  179. getUserInfo
  180. } from '@/api/user.js'
  181. // 点赞/取消点赞常量
  182. const LIKE = 'LIKE';
  183. const UNLIKE = 'UNLIKE';
  184. export default {
  185. components: {
  186. Task,
  187. EmojiPicker
  188. },
  189. data() {
  190. return {
  191. userData:{},
  192. isCollected:false,
  193. isLiked:false,
  194. date:null,
  195. lifeDetail: {},
  196. resourceId:9,
  197. // 状态栏的高度
  198. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  199. isLike: false,
  200. isCollection: false,
  201. // 评论输入框
  202. commentInput: '',
  203. // 底部输入框
  204. inputValue: '',
  205. // 表情选择器显示状态
  206. showEmojiPicker: false,
  207. // 一级评论列表
  208. rootComments: [],
  209. // 二级评论列表
  210. subComments: [],
  211. // 键盘上方输入框显示状态
  212. showKeyboardInput: false,
  213. // 键盘上方输入框内容
  214. keyboardInput: '',
  215. // 父评论ID(用于回复)
  216. parentId: '',
  217. // 评论展开状态
  218. expandedComments: {}
  219. }
  220. },
  221. onLoad(option) {
  222. this.resourceId = option.resourceId;
  223. this.getLifeDetail();
  224. this.getListRootComments();
  225. const userData = uni.getStorageSync('userData');
  226. if(userData){
  227. this.userData=userData;
  228. }else{
  229. this.getUserInfo();
  230. }
  231. },
  232. onUnload() {
  233. },
  234. methods: {
  235. getUserInfo(){
  236. getUserInfo().then(res => {
  237. if (res.code == 200) {
  238. this.userInfo=res.data;
  239. } else {
  240. uni.showToast({
  241. title: res.msg,
  242. icon: 'none'
  243. });
  244. }
  245. }).catch(err => { });
  246. },
  247. // 内容详情
  248. getLifeDetail() {
  249. if (!this.resourceId) return;
  250. let data = {
  251. resourceId: this.resourceId
  252. }
  253. lifeDetail(data).then(res => {
  254. if (res.code == 200) {
  255. this.lifeDetail=res.data;
  256. // 计算时间差并赋值给date
  257. this.date = this.calculateTimeDiff(res.data.createAt);
  258. // 更新点赞和收藏状态
  259. this.isLiked = res.data.isLiked || false;
  260. this.isCollected = res.data.isCollected || false;
  261. console.log("内容详情", res)
  262. } else {
  263. uni.showToast({
  264. title: res.msg,
  265. icon: 'none'
  266. });
  267. }
  268. }).catch(err => { });
  269. },
  270. onLike() {
  271. this.isLike = !this.isLike;
  272. },
  273. // 一级评论列表
  274. getListRootComments() {
  275. if (!this.resourceId) return;
  276. let data = {
  277. page: 1,
  278. pageSize: 10,
  279. resourceId: this.resourceId
  280. }
  281. listRootComments(data).then(res => {
  282. if (res.code == 200) {
  283. this.rootComments = res.data.list;
  284. console.log("一级评论列表", res)
  285. } else {
  286. uni.showToast({
  287. title: res.msg,
  288. icon: 'none'
  289. });
  290. }
  291. }).catch(err => { });
  292. },
  293. // 二级评论列表
  294. getListSubComments(rootId) {
  295. if (!rootId) return;
  296. let data = {
  297. page: 1,
  298. pageSize: 10,
  299. rootId: rootId
  300. }
  301. listSubComments(data).then(res => {
  302. if (res.code == 200) {
  303. // 查找对应的一级评论并更新其子评论
  304. const rootComment = this.rootComments.find(comment => comment.commentId === rootId);
  305. if (rootComment) {
  306. rootComment.children = res.data.list;
  307. }
  308. console.log("二级评论列表", res)
  309. } else {
  310. uni.showToast({
  311. title: res.msg,
  312. icon: 'none'
  313. });
  314. }
  315. }).catch(err => { });
  316. },
  317. // 内容点赞/取消点赞
  318. toggleLike() {
  319. this.isLiked=!this.isLiked;
  320. if (!this.resourceId) return;
  321. let data = {
  322. action: this.isLike ? UNLIKE : LIKE, //LIKE / UNLIKE
  323. resourceId: this.resourceId
  324. }
  325. toggleLike(data).then(res => {
  326. if (res.code == 200) {
  327. console.log("内容点赞/取消点赞", res)
  328. // 切换点赞状态
  329. this.isLike = !this.isLike;
  330. // 重新获取内容详情,更新点赞数
  331. this.getLifeDetail();
  332. } else {
  333. uni.showToast({
  334. title: res.msg,
  335. icon: 'none'
  336. });
  337. }
  338. }).catch(err => { });
  339. },//内容收藏/取消收藏
  340. toggleCollection() {
  341. this.isCollected=!this.isCollected;
  342. if (!this.resourceId) return;
  343. let data = {
  344. action: this.isCollection ? UNLIKE : LIKE, //LIKE / UNLIKE
  345. resourceId: this.resourceId
  346. }
  347. toggleCollection(data).then(res => {
  348. if (res.code == 200) {
  349. console.log("内容收藏/取消收藏", res)
  350. // 切换收藏状态
  351. this.isCollection = !this.isCollection;
  352. // 重新获取内容详情,更新收藏数
  353. this.getLifeDetail();
  354. } else {
  355. uni.showToast({
  356. title: res.msg,
  357. icon: 'none'
  358. });
  359. }
  360. }).catch(err => { });
  361. },
  362. // 处理内容点赞按钮点击事件
  363. handleContentLike() {
  364. this.toggleLike();
  365. },
  366. // 处理内容收藏按钮点击事件
  367. handleContentCollection() {
  368. this.toggleCollection();
  369. },
  370. // 处理评论图标点击事件
  371. handleCommentClick() {
  372. // 显示键盘输入框
  373. this.showKeyboardInput = true;
  374. // 自动聚焦到键盘输入框
  375. setTimeout(() => {
  376. const input = uni.createSelectorQuery().select('.keyboard-input');
  377. input.focus();
  378. }, 100);
  379. },
  380. // 处理分享图标点击事件
  381. handleShareClick() {
  382. this.share();
  383. },
  384. // 跳转到达人页面
  385. gotoExpertPage() {
  386. console.log("跳转达人页面", this.lifeDetail)
  387. if (this.lifeDetail.userInfo.expertId) {
  388. console.log("跳转达人页面", this.lifeDetail)
  389. uni.navigateTo({
  390. url: '/pages_shopping/live/expert?expertId=' + this.lifeDetail.userInfo.expertId
  391. });
  392. }
  393. },
  394. // 内容分享
  395. share() {
  396. if (!this.resourceId) return;
  397. let data = {
  398. resourceId: this.resourceId
  399. }
  400. share(data).then(res => {
  401. if (res.code == 200) {
  402. console.log("内容分享", res)
  403. } else {
  404. uni.showToast({
  405. title: res.msg,
  406. icon: 'none'
  407. });
  408. }
  409. }).catch(err => { });
  410. },
  411. // 评论点赞
  412. toggleLikeComments(commentId) {
  413. if (!commentId) return;
  414. // 查找评论对象,获取isLiked状态
  415. let isLiked = false;
  416. let found = false;
  417. // 先在一级评论中查找
  418. for (let comment of this.rootComments) {
  419. if (comment.commentId === commentId) {
  420. isLiked = comment.isLiked;
  421. found = true;
  422. break;
  423. }
  424. // 再在二级评论中查找
  425. if (comment.children && comment.children.length > 0) {
  426. for (let child of comment.children) {
  427. if (child.commentId === commentId) {
  428. isLiked = child.isLiked;
  429. found = true;
  430. break;
  431. }
  432. }
  433. if (found) break;
  434. }
  435. }
  436. let data = {
  437. action: isLiked ? UNLIKE : LIKE,// UNLIKE
  438. commentId: commentId
  439. }
  440. console.log("评论点赞参数:", data);
  441. apiToggleLikeComments(data).then(res => {
  442. if (res.code == 200) {
  443. console.log("评论点赞", res)
  444. // 重新获取评论列表
  445. this.getListRootComments();
  446. } else {
  447. uni.showToast({
  448. title: res.msg,
  449. icon: 'none'
  450. });
  451. }
  452. }).catch(err => {
  453. console.log("评论点赞错误:", err);
  454. });
  455. },
  456. // 发表评论
  457. getPostComment() {
  458. // 检查哪个输入框有内容
  459. let content = this.commentInput || this.inputValue;
  460. if (!content.trim()) {
  461. uni.showToast({
  462. title: '请输入评论内容',
  463. icon: 'none'
  464. });
  465. return;
  466. }
  467. let data = {
  468. content: content,
  469. parentId: '', //父评论ID(回复必填,一级不填)
  470. resourceId: this.resourceId //业务ID (文章ID / 视频ID )
  471. }
  472. postComment(data).then(res => {
  473. if (res.code == 200) {
  474. console.log("发表评论", res)
  475. // 发表成功后清空输入框
  476. this.commentInput = '';
  477. this.inputValue = '';
  478. // 重新获取评论列表
  479. this.getListRootComments();
  480. } else {
  481. uni.showToast({
  482. title: res.msg,
  483. icon: 'none'
  484. });
  485. }
  486. }).catch(err => { });
  487. },
  488. // 表情选择事件
  489. handleEmojiSelect(emoji) {
  490. // 优先添加到键盘上方输入框
  491. if (this.showKeyboardInput) {
  492. this.keyboardInput += emoji;
  493. } else if (this.commentInput) {
  494. this.commentInput += emoji;
  495. } else {
  496. this.inputValue += emoji;
  497. }
  498. this.showEmojiPicker = false;
  499. },
  500. // 处理回复按钮点击事件
  501. handleReply(comment) {
  502. console.log("点击回复",comment)
  503. this.parentId = comment.commentId;
  504. this.showKeyboardInput = true;
  505. // 自动聚焦到键盘输入框
  506. setTimeout(() => {
  507. const input = uni.createSelectorQuery().select('.keyboard-input');
  508. input.focus();
  509. }, 100);
  510. },
  511. // 切换评论展开/收起状态
  512. toggleExpand(comment) {
  513. // 切换展开状态
  514. const isExpanded = this.expandedComments[comment.commentId];
  515. this.$set(this.expandedComments, comment.commentId, !isExpanded);
  516. // 如果展开,获取二级评论
  517. if (!isExpanded) {
  518. this.getListSubComments(comment.commentId);
  519. }
  520. },
  521. // 获取二级评论列表
  522. getListSubComments(rootId) {
  523. if (!rootId) return;
  524. let data = {
  525. page: 1,
  526. pageSize: 10,
  527. rootId: rootId
  528. }
  529. listSubComments(data).then(res => {
  530. if (res.code == 200) {
  531. console.log("二级评论列表", res)
  532. // 这里可以将二级评论存储到对应的一级评论中
  533. } else {
  534. uni.showToast({
  535. title: res.msg,
  536. icon: 'none'
  537. });
  538. }
  539. }).catch(err => { });
  540. },
  541. // 发送键盘输入框的评论
  542. sendKeyboardComment() {
  543. if (!this.keyboardInput.trim()) {
  544. uni.showToast({
  545. title: '请输入评论内容',
  546. icon: 'none'
  547. });
  548. return;
  549. }
  550. let data = {
  551. content: this.keyboardInput,
  552. parentId: this.parentId || 0, //父评论ID(回复必填,一级不填,没有传0)
  553. resourceId: this.resourceId //业务ID (文章ID / 视频ID )
  554. }
  555. postComment(data).then(res => {
  556. if (res.code == 200) {
  557. console.log("发表评论", res)
  558. // 发表成功后清空输入框
  559. this.keyboardInput = '';
  560. this.showKeyboardInput = false;
  561. this.parentId = '';
  562. // 重新获取评论列表
  563. this.getListRootComments();
  564. } else {
  565. uni.showToast({
  566. title: res.msg,
  567. icon: 'none'
  568. });
  569. }
  570. }).catch(err => { });
  571. },
  572. // 计算时间差
  573. calculateTimeDiff(createAt) {
  574. if (!createAt) return '';
  575. const createTime = new Date(createAt).getTime();
  576. const now = new Date().getTime();
  577. const diff = now - createTime;
  578. // 时间单位(毫秒)
  579. const minute = 60 * 1000;
  580. const hour = 60 * minute;
  581. const day = 24 * hour;
  582. const month = 30 * day;
  583. const year = 365 * day;
  584. // 计算时间差
  585. if (diff < minute) {
  586. return '刚刚';
  587. } else if (diff < hour) {
  588. const minutes = Math.floor(diff / minute);
  589. return `${minutes}分钟前`;
  590. } else if (diff < day) {
  591. const hours = Math.floor(diff / hour);
  592. return `${hours}小时前`;
  593. } else if (diff < month) {
  594. const days = Math.floor(diff / day);
  595. return `${days}天前`;
  596. } else if (diff < year) {
  597. const months = Math.floor(diff / month);
  598. return `${months}个月前`;
  599. } else {
  600. const years = Math.floor(diff / year);
  601. return `${years}年前`;
  602. }
  603. },
  604. // 返回上一页,无则返回首页
  605. goBack() {
  606. // 获取页面栈
  607. const pages = getCurrentPages();
  608. // 如果页面栈长度大于1,说明有上一页
  609. if (pages.length > 1) {
  610. // 返回上一页
  611. uni.navigateBack({
  612. delta: 1
  613. });
  614. } else {
  615. // 否则返回首页
  616. uni.reLaunch({
  617. url: '/pages/home/index'
  618. });
  619. }
  620. },
  621. },
  622. }
  623. </script>
  624. <style lang="scss" scoped>
  625. .content {
  626. min-height: 100vh;
  627. background: #ffffff;
  628. position: relative;
  629. .top-block {
  630. padding-left: 24rpx;
  631. display: flex;
  632. justify-content: space-between;
  633. align-items: center;
  634. .left {
  635. display: flex;
  636. align-items: center;
  637. .head {
  638. width: 68rpx;
  639. height: 68rpx;
  640. border-radius: 34rpx 34rpx 34rpx 34rpx;
  641. margin: 0 16rpx;
  642. }
  643. .name {
  644. font-weight: 500;
  645. font-size: 32rpx;
  646. color: #333333;
  647. }
  648. }
  649. .right {
  650. display: flex;
  651. align-items: center;
  652. margin-right: 210rpx;
  653. .icon-bg {
  654. width: 64rpx;
  655. height: 64rpx;
  656. padding: 12rpx;
  657. border-radius: 32rpx 32rpx 32rpx 32rpx;
  658. border: 1rpx solid #E9E9E9;
  659. box-sizing: border-box;
  660. background: #FFFFFF;
  661. margin-left: 24rpx;
  662. }
  663. }
  664. .title-box {
  665. position: relative;
  666. .title {
  667. font-weight: 600;
  668. font-size: 40rpx;
  669. color: #333333;
  670. }
  671. }
  672. }
  673. // 文章
  674. .article {
  675. display: flex;
  676. flex-direction: column;
  677. margin-top: 30rpx;
  678. .photo {
  679. width: 100%;
  680. height: 416rpx;
  681. }
  682. .article-main {
  683. padding: 0 24rpx;
  684. .title {
  685. margin: 18rpx 0 32rpx;
  686. font-weight: 500;
  687. font-size: 36rpx;
  688. color: #333333;
  689. }
  690. .txt {
  691. font-size: 30rpx;
  692. color: #333333;
  693. .lable {
  694. color: #153868;
  695. margin-left: 8rpx;
  696. }
  697. }
  698. .card {
  699. display: flex;
  700. justify-content: space-between;
  701. align-items: center;
  702. background: #FFF5EB;
  703. width: 100%;
  704. height: 64rpx;
  705. border-radius: 8rpx;
  706. border: 1rpx solid #F3E2D0;
  707. padding: 16rpx;
  708. box-sizing: border-box;
  709. margin: 22rpx 0 32rpx; // 添加边距
  710. .card-item {
  711. display: flex;
  712. align-items: center;
  713. color: #D46C0D;
  714. .card-icon {
  715. width: 60rpx;
  716. height: 32rpx;
  717. margin-right: 24rpx;
  718. }
  719. .ranking {
  720. font-size: 24rpx;
  721. }
  722. .top {
  723. font-family: Roboto Flex, Roboto Flex;
  724. font-weight: normal;
  725. font-size: 24rpx;
  726. transform: skewX(-8deg);
  727. display: inline-block;
  728. margin-left: 8rpx;
  729. }
  730. }
  731. .go {
  732. width: 16rpx;
  733. height: 16rpx;
  734. }
  735. }
  736. .place {
  737. font-size: 24rpx;
  738. color: #999999;
  739. }
  740. }
  741. }
  742. .line {
  743. margin: 32rpx 24rpx;
  744. width:calc(100% - 48rpx) ;
  745. height: 0rpx;
  746. border: 1rpx solid #EEEEEE;
  747. }
  748. // 评论
  749. .comment {
  750. display: flex;
  751. flex-direction: column;
  752. padding: 0 24rpx 120rpx;
  753. .comment-num {
  754. display: flex;
  755. align-items: center;
  756. font-weight: 500;
  757. font-size: 28rpx;
  758. color: #333333;
  759. margin-bottom: 30rpx;
  760. }
  761. .my-input {
  762. display: flex;
  763. margin-bottom: 40rpx;
  764. .head {
  765. width: 68rpx;
  766. height: 68rpx;
  767. margin-right: 24rpx;
  768. border-radius: 50%;
  769. flex-shrink: 0;
  770. }
  771. .input-item {
  772. flex: 1;
  773. display: flex;
  774. align-items: center;
  775. background: #F5F7FA;
  776. padding: 0 24rpx;
  777. border-radius: 34rpx;
  778. .input {
  779. flex: 1;
  780. }
  781. }
  782. }
  783. .message {
  784. display: flex;
  785. flex-direction: column;
  786. .message-item {
  787. display: flex;
  788. justify-content: space-between;
  789. margin-bottom: 40rpx;
  790. .left {
  791. display: flex;
  792. .head {
  793. width: 68rpx;
  794. height: 68rpx;
  795. margin-right: 24rpx;
  796. border-radius: 50%;
  797. flex-shrink: 0;
  798. }
  799. .head-little {
  800. width: 48rpx;
  801. height: 48rpx;
  802. margin-right: 16rpx;
  803. border-radius: 50%;
  804. flex-shrink: 0;
  805. }
  806. .chat {
  807. .name {
  808. font-size: 26rpx;
  809. color: #999999;
  810. display: flex;
  811. .author-lable {
  812. width: 62rpx;
  813. height: 32rpx;
  814. background: #E0FFF4;
  815. border-radius: 16rpx;
  816. text-align: center;
  817. line-height: 32rpx;
  818. font-weight: 500;
  819. font-size: 18rpx;
  820. color: #02B176;
  821. margin-left: 14rpx;
  822. }
  823. }
  824. .flex-wrap {
  825. display: flex;
  826. flex-wrap: wrap;
  827. align-items: center;
  828. .txt {
  829. font-size: 28rpx;
  830. color: #333333;
  831. margin: 12rpx 24rpx 12rpx 0;
  832. }
  833. .info {
  834. font-size: 24rpx;
  835. display: flex;
  836. .time {
  837. color: #999999;
  838. }
  839. .reply {
  840. color: #666666;
  841. margin-left: 22rpx;
  842. }
  843. }
  844. }
  845. }
  846. }
  847. .expand {
  848. font-size: 26rpx;
  849. color: #153868;
  850. padding: 0 64rpx;
  851. }
  852. .right {
  853. display: flex;
  854. flex-direction: column;
  855. align-items: center;
  856. font-size: 24rpx;
  857. color: #666666;
  858. }
  859. }
  860. }
  861. }
  862. // 输入框
  863. .chat-input-container {
  864. display: flex;
  865. justify-content: space-between;
  866. align-items: center;
  867. height: 100rpx;
  868. box-sizing: border-box;
  869. padding: 20rpx 24rpx;
  870. width: 100%;
  871. box-sizing: border-box;
  872. position: fixed;
  873. bottom: 0;
  874. background-color: #ffffff;
  875. border-top: 1rpx solid #EEEEEE;
  876. .input-container {
  877. background: #F5F7FA;
  878. height: 68rpx;
  879. box-sizing: border-box;
  880. border-radius: 36rpx;
  881. display: flex;
  882. align-items: center;
  883. overflow: hidden;
  884. margin-right: 20rpx;
  885. .send-btn {
  886. margin-left: 20rpx;
  887. padding: 8rpx 20rpx;
  888. background-color: #FF6B6B;
  889. color: white;
  890. font-size: 24rpx;
  891. border-radius: 15rpx;
  892. margin-right: 20rpx;
  893. }
  894. }
  895. .icon-container {
  896. display: flex;
  897. align-items: center;
  898. .icon-item {
  899. display: flex;
  900. align-items: center;
  901. margin-right: 42rpx;
  902. &:last-child {
  903. margin-right: 0rpx;
  904. }
  905. .icon {
  906. width: 48rpx;
  907. height: 48rpx;
  908. margin-right: 8rpx;
  909. }
  910. }
  911. }
  912. }
  913. // 键盘上方的输入框
  914. .keyboard-input-container {
  915. position: fixed;
  916. bottom: 0;
  917. left: 0;
  918. right: 0;
  919. background-color: #ffffff;
  920. border-top: 1rpx solid #EEEEEE;
  921. padding: 20rpx 24rpx;
  922. z-index: 999;
  923. .keyboard-input-item {
  924. display: flex;
  925. align-items: center;
  926. background: #F5F7FA;
  927. padding: 0 24rpx;
  928. border-radius: 34rpx;
  929. height: 68rpx;
  930. .keyboard-input {
  931. flex: 1;
  932. height: 100%;
  933. font-size: 26rpx;
  934. }
  935. .send-btn {
  936. margin-left: 20rpx;
  937. padding: 8rpx 20rpx;
  938. background-color: #FF6B6B;
  939. color: white;
  940. font-size: 24rpx;
  941. border-radius: 15rpx;
  942. }
  943. }
  944. }
  945. }
  946. </style>