金诚优选前端代码
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.

483 lines
15 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 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" @click="$url('/pages/user/my/my?user_id='+discover_details.user_id)">
  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"> {{discover_details.comments_count}}条评论</view>
  44. <!-- 评论开始 -->
  45. <view v-for="(commentitem,commentindex) of commentList" :key="commentindex">
  46. <view class="lf-m-t-20" @click="applySub(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.stop="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: this.$cookieStorage.get('user_info').id
  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.ifApply = false;
  251. this.getCommentList();
  252. })
  253. } else {
  254. wx.showModal({
  255. content: res.data.message || '请下拉页面刷新重试',
  256. showCancel: false
  257. });
  258. }
  259. } else {
  260. wx.showModal({
  261. content: res.data.message || '请下拉页面刷新重试',
  262. showCancel: false
  263. });
  264. }
  265. wx.hideLoading();
  266. })
  267. .catch(() => {
  268. wx.hideLoading();
  269. wx.showModal({
  270. content: '请求失败',
  271. showCancel: false
  272. });
  273. });
  274. },
  275. sendComment(id) {
  276. this.$http
  277. .post({
  278. api: 'api/discover/comment',
  279. data: {
  280. discover_id: id,
  281. content: this.comment,
  282. to_user_id: 0,
  283. parent_id: 0
  284. },
  285. header: {
  286. Authorization: this.$cookieStorage.get('user_token')
  287. },
  288. })
  289. .then(res => {
  290. if (res.data.code == 200) {
  291. if (res.data.status) {
  292. this.$msg('评论成功').then(() => {
  293. console.log('更新评论列表')
  294. this.comment = '';
  295. this.getCommentList();
  296. })
  297. } else {
  298. wx.showModal({
  299. content: res.data.message || '请下拉页面刷新重试',
  300. showCancel: false
  301. });
  302. }
  303. } else {
  304. wx.showModal({
  305. content: res.data.message || '请下拉页面刷新重试',
  306. showCancel: false
  307. });
  308. }
  309. wx.hideLoading();
  310. })
  311. .catch(() => {
  312. wx.hideLoading();
  313. wx.showModal({
  314. content: '请求失败',
  315. showCancel: false
  316. });
  317. });
  318. },
  319. addLike(id) {
  320. this.$http
  321. .post({
  322. api: 'api/discover/like',
  323. data: {
  324. discover_id: id
  325. },
  326. header: {
  327. Authorization: this.$cookieStorage.get('user_token')
  328. },
  329. })
  330. .then(res => {
  331. if (res.data.code == 200) {
  332. if (res.data.status) {
  333. this.getCommentList();
  334. this.getDiscoverDetails();
  335. } else {
  336. wx.showModal({
  337. content: res.data.message || '请下拉页面刷新重试',
  338. showCancel: false
  339. });
  340. }
  341. } else {
  342. wx.showModal({
  343. content: res.data.message || '请下拉页面刷新重试',
  344. showCancel: false
  345. });
  346. }
  347. wx.hideLoading();
  348. })
  349. .catch(() => {
  350. wx.hideLoading();
  351. wx.showModal({
  352. content: '请求失败',
  353. showCancel: false
  354. });
  355. });
  356. },
  357. getDiscoverDetails() {
  358. this.$http
  359. .post({
  360. api: 'api/discover/detail',
  361. data: {
  362. id: this.discover_id,
  363. user_id: this.$cookieStorage.get('user_info').id
  364. },
  365. })
  366. .then(res => {
  367. if (res.data.code == 200) {
  368. if (res.data.status) {
  369. this.discover_details = res.data.data;
  370. this.is_like = Boolean(res.data.data.is_like) || false;
  371. console.log(this.is_like);
  372. } else {
  373. wx.showModal({
  374. content: res.data.message || '请下拉页面刷新重试',
  375. showCancel: false
  376. });
  377. }
  378. } else {
  379. wx.showModal({
  380. content: res.data.message || '请下拉页面刷新重试',
  381. showCancel: false
  382. });
  383. }
  384. wx.hideLoading();
  385. })
  386. .catch(() => {
  387. wx.hideLoading();
  388. wx.showModal({
  389. content: '请求失败',
  390. showCancel: false
  391. });
  392. });
  393. }
  394. }
  395. }
  396. </script>
  397. <style scoped lang="scss">
  398. .tag-father {
  399. position: relative;
  400. }
  401. .head-tag {
  402. color: white;
  403. display: flex;
  404. align-items: center;
  405. justify-content: center;
  406. text-align: center;
  407. font-size: 24rpx;
  408. width: 36rpx;
  409. height: 36rpx;
  410. border-radius: 50%;
  411. background-color: #15716E;
  412. border: 1rpx solid #FFFFFF;
  413. position: absolute;
  414. left: 66rpx;
  415. top: 70rpx;
  416. z-index: 99;
  417. }
  418. /deep/.input-placeholder{
  419. color: #aaa;
  420. font-size: 28rpx;
  421. }
  422. .rom-search {
  423. width: 279rpx;
  424. height: 70rpx;
  425. background: #F4F8F8;
  426. border-radius: 35rpx;
  427. padding-left: 30rpx;
  428. font-size: 28rpx;
  429. }
  430. .comment-tab {
  431. padding: 0 0 0 32rpx;
  432. display: flex;
  433. justify-content: space-between;
  434. height: 100rpx;
  435. align-items: center;
  436. width: 100%;
  437. border-top: 1rpx solid rgba(0, 0, 0, 0.1);
  438. position: fixed;
  439. bottom: 0;
  440. z-index: 99;
  441. background-color: white;
  442. }
  443. .comment-replay {
  444. margin-left: 96rpx;
  445. margin-top: 28rpx;
  446. }
  447. .comment-img {
  448. width: 75rpx;
  449. height: 75rpx;
  450. border-radius: 50%;
  451. }
  452. .comment{
  453. width: 100%;
  454. height: max-content;
  455. background-color: white;
  456. border-radius: 5rpx;
  457. box-sizing: border-box;
  458. padding: 32rpx;
  459. font-size: 28rpx;
  460. color: #777777;
  461. padding-bottom: 120rpx;
  462. }
  463. .qzone-img {
  464. position: relative;
  465. width: 220rpx;
  466. height: 220rpx;
  467. border-radius: 10rpx;
  468. margin-right: 12rpx;
  469. &:nth-child(3n) {
  470. margin-right: 0;
  471. }
  472. &:nth-child(n + 4) {
  473. margin-top: 12rpx;
  474. }
  475. }
  476. .head-img {
  477. width: 100rpx;
  478. height: 100rpx;
  479. border-radius: 50%;
  480. }
  481. </style>