金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

481 lines
15 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <view>
  3. <lf-nav :spreadOut="true" :showIcon="true" title="详情"></lf-nav>
  4. <view class="lf-p-32">
  5. <view class="lf-flex">
  6. <view class="tag-father">
  7. <image :src="discover_details.user.avatar" mode="aspectFill" class="head-img"></image>
  8. <view class="head-tag">V</view>
  9. </view>
  10. <view class="lf-flex-column lf-m-l-20">
  11. <view>
  12. <text class="lf-font-32 lf-color-black lf-font-bold lf-m-r-15">{{discover_details.user.nick_name}}</text>
  13. <text class="lf-iconfont icon-xiangyou lf-color-777 lf-text-vertical" style="font-size: 18rpx;"></text>
  14. </view>
  15. <view class="lf-font-24 lf-color-777 lf-m-t-15">{{discover_details.updated_at}}</view>
  16. </view>
  17. </view>
  18. <view class="lf-font-28 lf-color-333 lf-m-t-20">
  19. {{discover_details.content}}
  20. </view>
  21. <view class="lf-flex-wrap lf-m-t-20">
  22. <image v-for="(item,index) in discover_details.attachs" :key="index" class="qzone-img" :src="item.url" mode="aspectFill"></image>
  23. </view>
  24. <view class="lf-m-t-30 lf-row-between lf-p-l-50 lf-p-r-50">
  25. <view class="lf-row-center" @click="addLike(discover_details.id)">
  26. <text class="lf-iconfont icon-xihuanlike lf-color-price" v-if="discover_details.is_like"></text>
  27. <text class="lf-iconfont icon-xihuan" v-else></text>
  28. <text class="lf-font-24 lf-color-777 lf-m-l-10">{{discover_details.likes_count}}</text>
  29. </view>
  30. <view class="lf-row-center">
  31. <text class="lf-iconfont icon-chakan"></text>
  32. <text class="lf-font-24 lf-color-777 lf-m-l-10">{{discover_details.view_count}}</text>
  33. </view>
  34. <view class="lf-row-center">
  35. <text class="lf-iconfont icon-pinglun-"></text>
  36. <text class="lf-font-24 lf-color-777 lf-m-l-10">{{discover_details.comments_count}}</text>
  37. </view>
  38. </view>
  39. </view>
  40. <self-line/>
  41. <!-- 评论 -->
  42. <view class="comment" v-if="commentList.length != 0">
  43. <view class="lf-color-555 lf-font-24"> {{commentList.total}}条评论</view>
  44. <!-- 评论开始 -->
  45. <view v-for="(commentitem,commentindex) of commentList" :key="commentindex">
  46. <view class="lf-m-t-20" @click="applyComment(commentitem.user.id,commentitem.id)">
  47. <view class="lf-flex">
  48. <view>
  49. <image class="comment-img" :src="commentitem.user.avatar" mode="aspectFill"></image>
  50. </view>
  51. <view class="lf-flex-column lf-m-l-20">
  52. <view class="lf-color-999 lf-font-24">{{commentitem.user.nick_name}}</view>
  53. <view>
  54. <view class="lf-color-black lf-line-2" style="max-width:550rpx;">{{commentitem.content}}<text class="lf-color-999 lf-font-24 lf-m-l-10">{{commentitem.created_at}}</text></view>
  55. </view>
  56. </view>
  57. <view class="lf-m-l-32" style="position: absolute;right:33rpx;">
  58. <view @click.stop="giveaLike(commentitem.id)">
  59. <text class="lf-iconfont icon-xihuanlike lf-color-price" v-if="commentitem.is_like"></text>
  60. <text class="lf-iconfont icon-xihuan" v-else></text>
  61. </view>
  62. <view class="lf-color-555 lf-font-24 lf-row-center">{{commentitem.likes_count}}</view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="comment-replay" v-if="$isRight(commentitem.sub)" v-for="(subitem,index2) of commentitem.sub" :key="index2">
  67. <view class="lf-flex" @click="applySub(subitem.user.id,subitem.parent_id)">
  68. <view class="lf-flex lf-m-t-30">
  69. <view>
  70. <image class="comment-img" :src="subitem.user.avatar" mode="aspectFill"></image>
  71. </view>
  72. <view class="lf-flex-column lf-m-l-20">
  73. <view class="lf-flex">
  74. <view class="lf-color-999 lf-font-24 lf-m-r-10">{{subitem.user.nick_name}}</view>
  75. <view class="lf-row-center" style="max-width: 446rpx;">
  76. <text class="lf-color-333 lf-m-r-10">回复</text>
  77. <text class="lf-font-24 lf-color-999">{{subitem.to_user.nick_name}}:</text>
  78. </view>
  79. </view>
  80. <view style="max-width: 460rpx;">
  81. <text class="lf-font-26 lf-color-black lf-m-l-10">{{subitem.content}}</text>
  82. <text class="lf-color-999 lf-font-24 lf-m-l-10">{{subitem.created_at}}</text>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="lf-m-t-30" style="position: absolute;right:33rpx;">
  87. <view @click.stop="giveaLike(subitem.id)">
  88. <text class="lf-iconfont icon-xihuanlike lf-color-price" v-if="subitem.is_like"></text>
  89. <text class="lf-iconfont icon-xihuan" v-else></text>
  90. </view>
  91. <view class="lf-color-555 lf-font-24 lf-row-center">{{subitem.likes_count}}</view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="lf-font-24 lf-color-777 lf-row-center lf-m-t-40" style="align-items: center;" v-else>
  98. 暂无评论,友好的评论两句吧~
  99. </view>
  100. <!-- 底部tab -->
  101. <view class="comment-tab">
  102. <view>
  103. <input class="rom-search" type="text" v-if="ifApply" :focus="ifApply" @confirm="applyComment(apply_userid,apply_commentid)" :cursor-spacing="8" v-model="comment" placeholder="说点什么" />
  104. <input class="rom-search" type="text" v-else @confirm="sendComment(discover_details.id)" :cursor-spacing="8" v-model="comment" placeholder="说点什么" />
  105. </view>
  106. <view class="lf-row-center">
  107. <view class="lf-row-center lf-m-r-35" @click="addLike(discover_details.id)">
  108. <text class="lf-iconfont icon-xihuanlike lf-color-price" v-if="discover_details.is_like"></text>
  109. <text class="lf-iconfont icon-xihuan" v-else></text>
  110. <text class="lf-font-24 lf-color-777 lf-m-l-10">{{discover_details.likes_count}}</text>
  111. </view>
  112. <view class="lf-row-center lf-m-r-35">
  113. <text class="lf-iconfont icon-chakan"></text>
  114. <text class="lf-font-24 lf-color-777 lf-m-l-10">{{discover_details.view_count}}</text>
  115. </view>
  116. <view class="lf-row-center lf-m-r-35">
  117. <text class="lf-iconfont icon-pinglun-"></text>
  118. <text class="lf-font-24 lf-color-777 lf-m-l-10">{{discover_details.comments_count}}</text>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. </template>
  124. <script>
  125. export default {
  126. data() {
  127. return {
  128. discover_id: 0,
  129. discover_details: '',
  130. is_like: false,
  131. comment: '',
  132. commentList: [],
  133. ifApply: false,
  134. apply_userid: 0,
  135. apply_commentid: 0
  136. }
  137. },
  138. onLoad(e) {
  139. this.discover_id = e.discover_id;
  140. this.getDiscoverDetails();
  141. this.getCommentList();
  142. },
  143. methods: {
  144. applySub(userid,commentid) {
  145. this.ifApply = true;
  146. this.apply_userid = userid;
  147. this.apply_commentid = commentid;
  148. },
  149. //点赞评论
  150. giveaLike(comment_id) {
  151. this.$http
  152. .post({
  153. api: 'api/discover/comment/like',
  154. data: {
  155. comment_id: comment_id
  156. },
  157. header: {
  158. Authorization: this.$cookieStorage.get('user_token')
  159. },
  160. })
  161. .then(res => {
  162. if (res.data.code == 200) {
  163. if (res.data.status) {
  164. this.$msg('点赞成功').then(() => {
  165. console.log('更新点赞列表')
  166. this.getCommentList()
  167. })
  168. } else {
  169. wx.showModal({
  170. content: res.data.message || '请下拉页面刷新重试',
  171. showCancel: false
  172. });
  173. }
  174. } else {
  175. wx.showModal({
  176. content: res.data.message || '请下拉页面刷新重试',
  177. showCancel: false
  178. });
  179. }
  180. wx.hideLoading();
  181. })
  182. .catch(() => {
  183. wx.hideLoading();
  184. wx.showModal({
  185. content: '请求失败',
  186. showCancel: false
  187. });
  188. });
  189. },
  190. //获取评论列表
  191. getCommentList() {
  192. this.$http
  193. .post({
  194. api: 'api/discover/comment/list',
  195. data: {
  196. discover_id: this.discover_id,
  197. user_id: 6
  198. },
  199. header: {
  200. Authorization: this.$cookieStorage.get('user_token')
  201. },
  202. })
  203. .then(res => {
  204. if (res.data.code == 200) {
  205. if (res.data.status) {
  206. this.commentList = res.data.data.data;
  207. console.log('当前评论列表',this.commentList)
  208. } else {
  209. wx.showModal({
  210. content: res.data.message || '请下拉页面刷新重试',
  211. showCancel: false
  212. });
  213. }
  214. } else {
  215. wx.showModal({
  216. content: res.data.message || '请下拉页面刷新重试',
  217. showCancel: false
  218. });
  219. }
  220. wx.hideLoading();
  221. })
  222. .catch(() => {
  223. wx.hideLoading();
  224. wx.showModal({
  225. content: '请求失败',
  226. showCancel: false
  227. });
  228. });
  229. },
  230. applyComment(touserid,commentid) {
  231. this.$http
  232. .post({
  233. api: 'api/discover/comment',
  234. data: {
  235. discover_id: this.discover_id,
  236. content: this.comment,
  237. to_user_id: touserid,
  238. parent_id: commentid
  239. },
  240. header: {
  241. Authorization: this.$cookieStorage.get('user_token')
  242. },
  243. })
  244. .then(res => {
  245. if (res.data.code == 200) {
  246. if (res.data.status) {
  247. this.$msg('回复成功').then(() => {
  248. console.log('更新回复列表');
  249. this.comment = '';
  250. this.getCommentList();
  251. })
  252. } else {
  253. wx.showModal({
  254. content: res.data.message || '请下拉页面刷新重试',
  255. showCancel: false
  256. });
  257. }
  258. } else {
  259. wx.showModal({
  260. content: res.data.message || '请下拉页面刷新重试',
  261. showCancel: false
  262. });
  263. }
  264. wx.hideLoading();
  265. })
  266. .catch(() => {
  267. wx.hideLoading();
  268. wx.showModal({
  269. content: '请求失败',
  270. showCancel: false
  271. });
  272. });
  273. },
  274. sendComment(id) {
  275. this.$http
  276. .post({
  277. api: 'api/discover/comment',
  278. data: {
  279. discover_id: id,
  280. content: this.comment,
  281. to_user_id: 0,
  282. parent_id: 0
  283. },
  284. header: {
  285. Authorization: this.$cookieStorage.get('user_token')
  286. },
  287. })
  288. .then(res => {
  289. if (res.data.code == 200) {
  290. if (res.data.status) {
  291. this.$msg('评论成功').then(() => {
  292. console.log('更新评论列表')
  293. this.comment = '';
  294. this.getCommentList();
  295. })
  296. } else {
  297. wx.showModal({
  298. content: res.data.message || '请下拉页面刷新重试',
  299. showCancel: false
  300. });
  301. }
  302. } else {
  303. wx.showModal({
  304. content: res.data.message || '请下拉页面刷新重试',
  305. showCancel: false
  306. });
  307. }
  308. wx.hideLoading();
  309. })
  310. .catch(() => {
  311. wx.hideLoading();
  312. wx.showModal({
  313. content: '请求失败',
  314. showCancel: false
  315. });
  316. });
  317. },
  318. addLike(id) {
  319. this.$http
  320. .post({
  321. api: 'api/discover/like',
  322. data: {
  323. discover_id: id
  324. },
  325. header: {
  326. Authorization: this.$cookieStorage.get('user_token')
  327. },
  328. })
  329. .then(res => {
  330. if (res.data.code == 200) {
  331. if (res.data.status) {
  332. this.getCommentList();
  333. } else {
  334. wx.showModal({
  335. content: res.data.message || '请下拉页面刷新重试',
  336. showCancel: false
  337. });
  338. }
  339. } else {
  340. wx.showModal({
  341. content: res.data.message || '请下拉页面刷新重试',
  342. showCancel: false
  343. });
  344. }
  345. wx.hideLoading();
  346. })
  347. .catch(() => {
  348. wx.hideLoading();
  349. wx.showModal({
  350. content: '请求失败',
  351. showCancel: false
  352. });
  353. });
  354. },
  355. getDiscoverDetails() {
  356. this.$http
  357. .post({
  358. api: 'api/discover/detail',
  359. data: {
  360. id: this.discover_id,
  361. user_id: 6
  362. },
  363. })
  364. .then(res => {
  365. if (res.data.code == 200) {
  366. if (res.data.status) {
  367. this.discover_details = res.data.data;
  368. this.is_like = Boolean(res.data.data.is_like) || false;
  369. console.log(this.is_like);
  370. } else {
  371. wx.showModal({
  372. content: res.data.message || '请下拉页面刷新重试',
  373. showCancel: false
  374. });
  375. }
  376. } else {
  377. wx.showModal({
  378. content: res.data.message || '请下拉页面刷新重试',
  379. showCancel: false
  380. });
  381. }
  382. wx.hideLoading();
  383. })
  384. .catch(() => {
  385. wx.hideLoading();
  386. wx.showModal({
  387. content: '请求失败',
  388. showCancel: false
  389. });
  390. });
  391. }
  392. }
  393. }
  394. </script>
  395. <style scoped lang="scss">
  396. .tag-father {
  397. position: relative;
  398. }
  399. .head-tag {
  400. color: white;
  401. display: flex;
  402. align-items: center;
  403. justify-content: center;
  404. text-align: center;
  405. font-size: 24rpx;
  406. width: 36rpx;
  407. height: 36rpx;
  408. border-radius: 50%;
  409. background-color: #15716E;
  410. border: 1rpx solid #FFFFFF;
  411. position: absolute;
  412. left: 66rpx;
  413. top: 70rpx;
  414. z-index: 99;
  415. }
  416. /deep/.input-placeholder{
  417. color: #aaa;
  418. font-size: 28rpx;
  419. }
  420. .rom-search {
  421. width: 279rpx;
  422. height: 70rpx;
  423. background: #F4F8F8;
  424. border-radius: 35rpx;
  425. padding-left: 30rpx;
  426. font-size: 28rpx;
  427. }
  428. .comment-tab {
  429. padding: 0 0 0 32rpx;
  430. display: flex;
  431. justify-content: space-between;
  432. height: 100rpx;
  433. align-items: center;
  434. width: 100%;
  435. border-top: 1rpx solid rgba(0, 0, 0, 0.1);
  436. position: fixed;
  437. bottom: 0;
  438. z-index: 99;
  439. background-color: white;
  440. }
  441. .comment-replay {
  442. margin-left: 96rpx;
  443. margin-top: 28rpx;
  444. }
  445. .comment-img {
  446. width: 75rpx;
  447. height: 75rpx;
  448. border-radius: 50%;
  449. }
  450. .comment{
  451. width: 100%;
  452. height: max-content;
  453. background-color: white;
  454. border-radius: 5rpx;
  455. box-sizing: border-box;
  456. padding: 32rpx;
  457. font-size: 28rpx;
  458. color: #777777;
  459. padding-bottom: 120rpx;
  460. }
  461. .qzone-img {
  462. position: relative;
  463. width: 220rpx;
  464. height: 220rpx;
  465. border-radius: 10rpx;
  466. margin-right: 12rpx;
  467. &:nth-child(3n) {
  468. margin-right: 0;
  469. }
  470. &:nth-child(n + 4) {
  471. margin-top: 12rpx;
  472. }
  473. }
  474. .head-img {
  475. width: 100rpx;
  476. height: 100rpx;
  477. border-radius: 50%;
  478. }
  479. </style>