article.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. <template>
  2. <view class="content">
  3. <view class="text-box">
  4. <view class="text-title">
  5. <view class="text-1">{{artData.title}}</view>
  6. <view class="text-2" v-if="artData.mer && artData.mer.name">
  7. <view class="name clamp">
  8. {{artData.mer.name}}
  9. </view>
  10. <view class="gg"></view>
  11. <view class="time">
  12. {{artData.add_time | getTime}}
  13. </view>
  14. <!-- <view class="gg"></view>
  15. <view class="time">
  16. 已阅读 {{artData.visit}}
  17. </view> -->
  18. </view>
  19. </view>
  20. <view class="text-content-title" @click="navTo('/pages/user/dydetail?id=' + artData.mer.id)" v-if="artData.mer">
  21. <view class="title-left-box">
  22. <view class="image" >
  23. <image :src="artData.mer.headimg" mode=""></image>
  24. </view>
  25. <view class="title-left-box-content">
  26. <view class="title-left-box-name">
  27. <view class="name-title" v-if="artData.mer && artData.mer.name">
  28. {{artData.mer.name}}
  29. </view>
  30. <view class="name-dingyue" v-if="artData.mer.is_sub==1">
  31. 已订阅
  32. </view>
  33. <view class="name-dingyue" v-else>
  34. +订阅
  35. </view>
  36. </view>
  37. <!-- <view class="title-left-box-title">
  38. <text>发表文章:{{artData.mer.count}}</text><text
  39. style="margin-left: 20rpx;">订阅:{{artData.mer.sub}}</text>
  40. </view> -->
  41. </view>
  42. </view>
  43. <view class="tt">
  44. >
  45. </view>
  46. </view>
  47. <view class="content-content" v-html="artData.content"></view>
  48. </view>
  49. <view class="pinglun" v-if="plList.length > 0">
  50. <view class=" pinglun-box ">
  51. <view class="pinglun-title">
  52. 评论交流({{plNum}})
  53. </view>
  54. <view class="" v-if="isZhankai==true && plIemt.user" v-for="plIemt in plList">
  55. <view class="pinglun-content" >
  56. <view class="pinglun-content-left">
  57. <image :src="plIemt.user.avatar" mode=""></image>
  58. </view>
  59. <view class="pinglun-content-right">
  60. <view class="pinglun-name">
  61. {{plIemt.user.nickname }}
  62. </view>
  63. <view class="pinglun-tit">
  64. {{plIemt.content}}
  65. </view>
  66. <view class="pinglun-time">
  67. {{plIemt.add_time | getTime}}
  68. </view>
  69. </view>
  70. </view>
  71. <view class="hf-wrap" v-if="plIemt.to.length > 0">
  72. <view class="hf" v-for="hfitem in plIemt.to">
  73. <!-- <text style="color: #3ea8cb;">作者</text> -->
  74. <text style="color: #3ea8cb;">回复</text>:<text>{{hfitem.content}}</text>
  75. </view>
  76. </view>
  77. <view class="" style="height: 10rpx;" v-if="plIemt.to.length > 0">
  78. </view>
  79. </view>
  80. <view class="zhankai" @click="zhankai()">
  81. <view class="all" v-if="isZhankai==true">
  82. 收起
  83. </view>
  84. <view class="all" v-else>
  85. 展开全部
  86. </view>
  87. <image src="../../static/img/top.png" mode="" v-if="isZhankai==true"></image>
  88. <image src="../../static/img/bottom.png" mode="" v-else></image>
  89. </view>
  90. </view>
  91. </view>
  92. <view class="look">
  93. <view class=" look-box ">
  94. <view class="look-title">
  95. 相关阅读
  96. </view>
  97. <view class="look-content" v-for="(xgItem,index) in xgList"
  98. @click="navTo('/pages/user/article?id=' + xgItem.id)">
  99. <view class="look-content-right">
  100. <view class="look-name">
  101. {{index + 1}}
  102. </view>
  103. <view class="look-tit clamp">
  104. {{xgItem.title}}
  105. </view>
  106. </view>
  107. <view class="look-time">
  108. <!-- {{xgItem.visit}}次 -->
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. <view class="pw">
  114. </view>
  115. <view class="send-box" @click="buy()">
  116. <input type="text" class="input" value="" placeholder="我来聊两句..." confirm-type="发布" v-model="myPl"
  117. @confirm="subPl" />
  118. <image src="../../static/img/dianzan.png" mode="" @click="dianZan"></image>
  119. <!-- <image src="../../static/img/share1.png" mode=""></image> -->
  120. <text style="color: #999;font-weight: bold;font-size: 28rpx;" @click="subPl">发布</text>
  121. </view>
  122. </view>
  123. </template>
  124. <script>
  125. import {
  126. mapState
  127. } from 'vuex';
  128. import {
  129. weixindata,
  130. shareLoad
  131. } from '@/utils/wxAuthorized.js';
  132. import {
  133. getArtDetail,
  134. getPlList,
  135. getXgList,
  136. dianZan,
  137. subPl,
  138. getnoArtDetail
  139. } from '@/api/art.js'
  140. import {
  141. getTime
  142. } from '@/utils/rocessor.js'
  143. export default {
  144. data() {
  145. return {
  146. isDingyue: false, //是否订阅
  147. plNum: 10, //评论数量
  148. dyNumber: 10, //订阅人数
  149. isZhankai: false, //是否展开
  150. artId: 0,
  151. artData: {},
  152. plList: [],
  153. xgList: [], //相关阅读
  154. myPl: '', //我的评论
  155. };
  156. },
  157. filters: {
  158. getTime
  159. },
  160. computed: {
  161. ...mapState('user', ['hasLogin', 'userInfo']),
  162. },
  163. onLoad(opt) {
  164. if (opt.id) {
  165. this.artId = opt.id
  166. }
  167. if(this.hasLogin) {
  168. this.getArtDetail()
  169. this.getPlList()
  170. }else {
  171. this.getPlList()
  172. this.getnoArtDetail()
  173. }
  174. },
  175. methods: {
  176. // 分享
  177. IndexShare() {
  178. let obj = this;
  179. // let money = obj.money;
  180. let item = {
  181. link: obj.$store.state.baseURL + '/index/#/pages/user/article?id=' + obj.artId, // 分享链接
  182. imgUrl: obj.artData.image_input[0],
  183. desc: obj.artData.synopsis,
  184. title: obj.artData.title,
  185. success: console.log('分享加载成功')
  186. };
  187. shareLoad(item);
  188. },
  189. navTo(url) {
  190. uni.navigateTo({
  191. url
  192. })
  193. },
  194. //展开全部
  195. zhankai() {
  196. if (this.isZhankai == false) {
  197. this.isZhankai = true
  198. } else if (this.isZhankai == true) {
  199. this.isZhankai = false
  200. }
  201. },
  202. // 获取详情
  203. getArtDetail() {
  204. let obj = this
  205. getArtDetail({}, obj.artId).then(res => {
  206. console.log(res)
  207. obj.artData = res.data
  208. if (obj.artData.content != null) {
  209. obj.artData.content = obj.artData.content.replace(/<img/g,
  210. "<img style='max-width:100%;height:auto;'").replace(/<video/g,"<video style='max-width:100%;height:auto;'");
  211. } //小程序商品详情图超出屏幕问题
  212. this.getXgList(res.data.cid)
  213. this.IndexShare()
  214. })
  215. },
  216. //
  217. getnoArtDetail() {
  218. let obj = this
  219. getnoArtDetail({},obj.artId).then(res => {
  220. obj.artData = res.data
  221. if (obj.artData.content != null) {
  222. obj.artData.content = obj.artData.content.replace(/<img/g,
  223. "<img style='max-width:100%;height:auto;'").replace(/<video/g,'"<video :custom-cache="false""').replace(/<video/g,"<video style='max-width:100%;height:auto;'");
  224. console.log(obj.artData.content,'obj.artData.content');
  225. } //小程序商品详情图超出屏幕问题
  226. this.getXgList(res.data.cid)
  227. this.IndexShare()
  228. })
  229. },
  230. getPlList() {
  231. let obj = this
  232. getPlList({}, obj.artId).then(res => {
  233. console.log(res)
  234. obj.plNum = res.data.count
  235. obj.plList = res.data.list
  236. // let arr = []//评论列表
  237. // let brr = []//回复列表
  238. // if (res.data.list.length > 0) {
  239. // res.data.list.forEach(item => {
  240. // if (item.user) {
  241. // arr.push(item)
  242. // } else {
  243. // brr.push(item)
  244. // }
  245. // })
  246. // }
  247. // console.log(arr, brr, 'arr++brr')
  248. })
  249. },
  250. getXgList(cid) {
  251. let obj = this
  252. getXgList({
  253. type: cid
  254. }).then(res => {
  255. console.log(res)
  256. obj.xgList = res.data
  257. })
  258. },
  259. subPl() {
  260. let obj = this
  261. console.log('发布评论')
  262. if (obj.myPl == '') {
  263. return obj.$api.msg('请输入评论内容')
  264. }
  265. subPl({
  266. content: obj.myPl
  267. }, obj.artId).then(res => {
  268. obj.myPl = ''
  269. obj.$api.msg('发布成功!')
  270. this.getPlList()
  271. })
  272. },
  273. // 点赞
  274. dianZan() {
  275. let obj = this
  276. dianZan({}, obj.artId).then(res => {
  277. obj.$api.msg('点赞成功!')
  278. })
  279. }
  280. },
  281. }
  282. </script>
  283. <style lang="scss">
  284. page,
  285. .content {
  286. overflow-x: hidden;
  287. width: 100%;
  288. height: 100%;
  289. }
  290. .text-box {
  291. padding: 30rpx;
  292. border: 1rpx solid #EEEEEE;
  293. width: 100%;
  294. background-color: #fff;
  295. .text-title {
  296. display: flex;
  297. flex-direction: column;
  298. .text-1 {
  299. font-size: 40rpx;
  300. font-weight: bold;
  301. color: #333333;
  302. margin-bottom: 30rpx;
  303. }
  304. .text-2 {
  305. display: flex;
  306. align-items: center;
  307. .name {
  308. font-size: 25rpx;
  309. font-weight: 500;
  310. color: #666666;
  311. }
  312. .gg {
  313. margin: 0 15rpx;
  314. width: 3rpx;
  315. height: 25rpx;
  316. background: #EEEEEE;
  317. }
  318. .time {
  319. flex-shrink: 0;
  320. font-size: 22rpx;
  321. font-weight: 500;
  322. color: #999999;
  323. }
  324. }
  325. }
  326. }
  327. .text-content-title {
  328. margin: 30rpx 0;
  329. display: flex;
  330. justify-content: space-between;
  331. align-items: center;
  332. background: #F5F5F5;
  333. padding: 17rpx 30rpx;
  334. border-radius: 7rpx;
  335. .title-left-box {
  336. display: flex;
  337. justify-content: space-between;
  338. align-items: center;
  339. .image {
  340. width: 85rpx;
  341. height: 85rpx;
  342. overflow: hidden;
  343. border-radius: 50%;
  344. margin-right: 18rpx;
  345. image {
  346. width: 100%;
  347. height: 100%;
  348. }
  349. }
  350. .title-left-box-content {
  351. display: flex;
  352. flex-direction: column;
  353. .title-left-box-name {
  354. display: flex;
  355. justify-content: space-between;
  356. align-items: center;
  357. .name-title {
  358. font-size: 29rpx;
  359. font-weight: bold;
  360. color: #333333;
  361. }
  362. .name-dingyue {
  363. margin-left: 15rpx;
  364. font-size: 24rpx;
  365. font-weight: bold;
  366. color: #F3554F;
  367. width: 92rpx;
  368. height: 34rpx;
  369. border: 1rpx solid #F3554F;
  370. border-radius: 17rpx;
  371. line-height: 34rpx;
  372. text-align: center;
  373. }
  374. }
  375. }
  376. .title-left-box-title {
  377. text {
  378. font-size: 20rpx;
  379. font-weight: 500;
  380. color: #999999;
  381. }
  382. }
  383. }
  384. .tt {
  385. color: #B3B3B3;
  386. }
  387. }
  388. /deep/ .content-content {
  389. p {
  390. text-align: justify;
  391. }
  392. }
  393. .pinglun {
  394. background: #F8F8F8;
  395. padding: 20rpx 0;
  396. }
  397. .pinglun-box {
  398. background: #FFFFFF;
  399. .pinglun-title {
  400. font-size: 30rpx;
  401. font-weight: bold;
  402. color: #333333;
  403. line-height: 80rpx;
  404. margin-left: 30rpx;
  405. }
  406. .pinglun-content {
  407. display: flex;
  408. border-top: 1rpx solid #EEEEEE;
  409. // border-bottom: 1rpx solid #EEEEEE;
  410. padding: 30rpx 0 0 30rpx;
  411. .pinglun-content-left {
  412. width: 66rpx;
  413. height: 66rpx;
  414. border-radius: 50%;
  415. overflow: hidden;
  416. image {
  417. width: 100%;
  418. height: 100%;
  419. }
  420. }
  421. .pinglun-content-right {
  422. display: flex;
  423. justify-content: space-between;
  424. margin-left: 30rpx;
  425. display: flex;
  426. flex-direction: column;
  427. .pinglun-name {
  428. font-size: 26rpx;
  429. font-weight: 500;
  430. color: #333333;
  431. }
  432. .pinglun-tit {
  433. margin: 8rpx 0;
  434. font-size: 30rpx;
  435. font-weight: bold;
  436. color: #333333;
  437. }
  438. .pinglun-time {
  439. font-size: 22rpx;
  440. font-weight: bold;
  441. color: #999999;
  442. margin-bottom: 15rpx;
  443. }
  444. }
  445. }
  446. }
  447. .zhankai {
  448. padding: 10rpx 0;
  449. justify-content: center;
  450. display: flex;
  451. align-items: center;
  452. .all {}
  453. image {
  454. margin-left: 10rpx;
  455. width: 20rpx;
  456. height: 20rpx;
  457. }
  458. }
  459. .look {
  460. background: #FFFFFF;
  461. margin-top: 20rpx;
  462. .look-box {
  463. margin: 0 30rpx;
  464. .look-title {
  465. font-size: 30rpx;
  466. font-weight: bold;
  467. color: #333333;
  468. line-height: 80rpx;
  469. margin-left: 30rpx;
  470. }
  471. .look-content {
  472. display: flex;
  473. justify-content: space-between;
  474. padding: 30rpx 0;
  475. border-top: 1px solid #EEEEEE;
  476. border-bottom: 1px solid #EEEEEE;
  477. .look-content-right {
  478. display: flex;
  479. align-items: center;
  480. .look-name {
  481. width: 37rpx;
  482. height: 37rpx;
  483. background: #EE6231;
  484. border-radius: 50%;
  485. font-size: 27rpx;
  486. font-weight: bold;
  487. color: #FFFFFF;
  488. line-height: 37rpx;
  489. text-align: center;
  490. }
  491. .look-tit {
  492. margin-left: 10rpx;
  493. width: 500rpx;
  494. font-size: 27rpx;
  495. font-weight: 500;
  496. color: #333333;
  497. }
  498. }
  499. .look-time {}
  500. }
  501. }
  502. }
  503. .send-box {
  504. // border-top: 1rpx solid #999999;
  505. background: #FFFFFF;
  506. padding: 30rpx;
  507. width: 100%;
  508. position: fixed;
  509. bottom: 0;
  510. display: flex;
  511. justify-content: space-around;
  512. align-items: center;
  513. .input {
  514. padding-left: 30rpx;
  515. width: 550rpx;
  516. height: 60rpx;
  517. background: #EEEEEE;
  518. border-radius: 31rpx;
  519. }
  520. image {
  521. width: 42rpx;
  522. height: 42rpx;
  523. }
  524. }
  525. .pw {
  526. height: 120rpx;
  527. }
  528. .hf-wrap {
  529. width: 600rpx;
  530. background-color: #f4f4f4;
  531. margin-left: 120rpx;
  532. padding: 10rpx;
  533. padding-bottom: 0;
  534. font-size: 26rpx;
  535. border-radius: 10rpx;
  536. .hf {
  537. padding-bottom: 10rpx;
  538. }
  539. }
  540. </style>