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

501 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 v-if="$isRight(discover_details)">
  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" @click.stop="checkPicture(discover_details.attachs,index)" :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. checkPicture(image_list,current) {
  145. if(image_list.length <= 0) return;
  146. let list = [];
  147. image_list.forEach((item,index) => {
  148. list.push(item.url)
  149. })
  150. this.$u.throttle(() => {
  151. uni.previewImage({
  152. urls: list,
  153. current: current
  154. });
  155. }, 500);
  156. },
  157. applySub(userid,commentid) {
  158. this.ifApply = true;
  159. this.apply_userid = userid;
  160. this.apply_commentid = commentid;
  161. },
  162. //点赞评论
  163. giveaLike(comment_id) {
  164. this.$http
  165. .post({
  166. api: 'api/discover/comment/like',
  167. data: {
  168. comment_id: comment_id
  169. },
  170. header: {
  171. Authorization: this.$cookieStorage.get('user_token')
  172. },
  173. })
  174. .then(res => {
  175. if (res.data.code == 200) {
  176. if (res.data.status) {
  177. this.$msg('点赞成功').then(() => {
  178. console.log('更新点赞列表')
  179. this.getCommentList()
  180. })
  181. } else {
  182. wx.showModal({
  183. content: res.data.message || '请下拉页面刷新重试',
  184. showCancel: false
  185. });
  186. }
  187. } else {
  188. wx.showModal({
  189. content: res.data.message || '请下拉页面刷新重试',
  190. showCancel: false
  191. });
  192. }
  193. wx.hideLoading();
  194. })
  195. .catch(() => {
  196. wx.hideLoading();
  197. wx.showModal({
  198. content: '请求失败',
  199. showCancel: false
  200. });
  201. });
  202. },
  203. //获取评论列表
  204. getCommentList() {
  205. this.$http
  206. .post({
  207. api: 'api/discover/comment/list',
  208. data: {
  209. discover_id: this.discover_id,
  210. user_id: this.$cookieStorage.get('user_info').id
  211. },
  212. header: {
  213. Authorization: this.$cookieStorage.get('user_token')
  214. },
  215. })
  216. .then(res => {
  217. if (res.data.code == 200) {
  218. if (res.data.status) {
  219. this.commentList = res.data.data.data;
  220. console.log('当前评论列表',this.commentList)
  221. } else {
  222. wx.showModal({
  223. content: res.data.message || '请下拉页面刷新重试',
  224. showCancel: false
  225. });
  226. }
  227. } else {
  228. wx.showModal({
  229. content: res.data.message || '请下拉页面刷新重试',
  230. showCancel: false
  231. });
  232. }
  233. wx.hideLoading();
  234. })
  235. .catch(() => {
  236. wx.hideLoading();
  237. wx.showModal({
  238. content: '请求失败',
  239. showCancel: false
  240. });
  241. });
  242. },
  243. applyComment(touserid,commentid) {
  244. this.$http
  245. .post({
  246. api: 'api/discover/comment',
  247. data: {
  248. discover_id: this.discover_id,
  249. content: this.comment,
  250. to_user_id: touserid,
  251. parent_id: commentid
  252. },
  253. header: {
  254. Authorization: this.$cookieStorage.get('user_token')
  255. },
  256. })
  257. .then(res => {
  258. if (res.data.code == 200) {
  259. if (res.data.status) {
  260. this.$msg('回复成功').then(() => {
  261. console.log('更新回复列表');
  262. this.comment = '';
  263. this.ifApply = false;
  264. this.getCommentList();
  265. this.getDiscoverDetails();
  266. })
  267. } else {
  268. wx.showModal({
  269. content: res.data.message || '请下拉页面刷新重试',
  270. showCancel: false
  271. });
  272. }
  273. } else {
  274. wx.showModal({
  275. content: res.data.message || '请下拉页面刷新重试',
  276. showCancel: false
  277. });
  278. }
  279. wx.hideLoading();
  280. })
  281. .catch(() => {
  282. wx.hideLoading();
  283. wx.showModal({
  284. content: '请求失败',
  285. showCancel: false
  286. });
  287. });
  288. },
  289. sendComment(id) {
  290. this.$http
  291. .post({
  292. api: 'api/discover/comment',
  293. data: {
  294. discover_id: id,
  295. content: this.comment,
  296. to_user_id: 0,
  297. parent_id: 0
  298. },
  299. header: {
  300. Authorization: this.$cookieStorage.get('user_token')
  301. },
  302. })
  303. .then(res => {
  304. if (res.data.code == 200) {
  305. if (res.data.status) {
  306. this.$msg('评论成功').then(() => {
  307. console.log('更新评论列表')
  308. this.comment = '';
  309. this.getCommentList();
  310. this.getDiscoverDetails();
  311. })
  312. } else {
  313. wx.showModal({
  314. content: res.data.message || '请下拉页面刷新重试',
  315. showCancel: false
  316. });
  317. }
  318. } else {
  319. wx.showModal({
  320. content: res.data.message || '请下拉页面刷新重试',
  321. showCancel: false
  322. });
  323. }
  324. wx.hideLoading();
  325. })
  326. .catch(() => {
  327. wx.hideLoading();
  328. wx.showModal({
  329. content: '请求失败',
  330. showCancel: false
  331. });
  332. });
  333. },
  334. addLike(id) {
  335. this.$http
  336. .post({
  337. api: 'api/discover/like',
  338. data: {
  339. discover_id: id
  340. },
  341. header: {
  342. Authorization: this.$cookieStorage.get('user_token')
  343. },
  344. })
  345. .then(res => {
  346. if (res.data.code == 200) {
  347. if (res.data.status) {
  348. this.getCommentList();
  349. this.getDiscoverDetails();
  350. } else {
  351. wx.showModal({
  352. content: res.data.message || '请下拉页面刷新重试',
  353. showCancel: false
  354. });
  355. }
  356. } else {
  357. wx.showModal({
  358. content: res.data.message || '请下拉页面刷新重试',
  359. showCancel: false
  360. });
  361. }
  362. wx.hideLoading();
  363. })
  364. .catch(() => {
  365. wx.hideLoading();
  366. wx.showModal({
  367. content: '请求失败',
  368. showCancel: false
  369. });
  370. });
  371. },
  372. getDiscoverDetails() {
  373. this.$http
  374. .post({
  375. api: 'api/discover/detail',
  376. data: {
  377. id: this.discover_id,
  378. user_id: this.$cookieStorage.get('user_info').id
  379. },
  380. header: {
  381. Authorization: this.$cookieStorage.get('user_token')
  382. },
  383. })
  384. .then(res => {
  385. if (res.data.code == 200) {
  386. if (res.data.status) {
  387. this.discover_details = res.data.data;
  388. this.is_like = Boolean(res.data.data.is_like) || false;
  389. console.log(this.is_like);
  390. } else {
  391. wx.showModal({
  392. content: res.data.message || '请下拉页面刷新重试',
  393. showCancel: false
  394. });
  395. }
  396. } else {
  397. wx.showModal({
  398. content: res.data.message || '请下拉页面刷新重试',
  399. showCancel: false
  400. });
  401. }
  402. wx.hideLoading();
  403. })
  404. .catch(() => {
  405. wx.hideLoading();
  406. wx.showModal({
  407. content: '请求失败',
  408. showCancel: false
  409. });
  410. });
  411. }
  412. }
  413. }
  414. </script>
  415. <style scoped lang="scss">
  416. .tag-father {
  417. position: relative;
  418. }
  419. .head-tag {
  420. color: white;
  421. display: flex;
  422. align-items: center;
  423. justify-content: center;
  424. text-align: center;
  425. font-size: 24rpx;
  426. width: 36rpx;
  427. height: 36rpx;
  428. border-radius: 50%;
  429. background-color: #15716E;
  430. border: 1rpx solid #FFFFFF;
  431. position: absolute;
  432. left: 66rpx;
  433. top: 70rpx;
  434. z-index: 99;
  435. }
  436. /deep/.input-placeholder{
  437. color: #aaa;
  438. font-size: 28rpx;
  439. }
  440. .rom-search {
  441. width: 279rpx;
  442. height: 70rpx;
  443. background: #F4F8F8;
  444. border-radius: 35rpx;
  445. padding-left: 30rpx;
  446. font-size: 28rpx;
  447. }
  448. .comment-tab {
  449. padding: 0 0 0 32rpx;
  450. display: flex;
  451. justify-content: space-between;
  452. height: 100rpx;
  453. align-items: center;
  454. width: 100%;
  455. border-top: 1rpx solid rgba(0, 0, 0, 0.1);
  456. position: fixed;
  457. bottom: 0;
  458. z-index: 99;
  459. background-color: white;
  460. }
  461. .comment-replay {
  462. margin-left: 96rpx;
  463. margin-top: 28rpx;
  464. }
  465. .comment-img {
  466. width: 75rpx;
  467. height: 75rpx;
  468. border-radius: 50%;
  469. }
  470. .comment{
  471. width: 100%;
  472. height: max-content;
  473. background-color: white;
  474. border-radius: 5rpx;
  475. box-sizing: border-box;
  476. padding: 32rpx;
  477. font-size: 28rpx;
  478. color: #777777;
  479. padding-bottom: 120rpx;
  480. }
  481. .qzone-img {
  482. position: relative;
  483. width: 220rpx;
  484. height: 220rpx;
  485. border-radius: 10rpx;
  486. margin-right: 12rpx;
  487. &:nth-child(3n) {
  488. margin-right: 0;
  489. }
  490. &:nth-child(n + 4) {
  491. margin-top: 12rpx;
  492. }
  493. }
  494. .head-img {
  495. width: 100rpx;
  496. height: 100rpx;
  497. border-radius: 50%;
  498. }
  499. </style>