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

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