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

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