article.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  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;'");
  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;'");
  224. } //小程序商品详情图超出屏幕问题
  225. this.getXgList(res.data.cid)
  226. this.IndexShare()
  227. })
  228. },
  229. getPlList() {
  230. let obj = this
  231. getPlList({}, obj.artId).then(res => {
  232. console.log(res)
  233. obj.plNum = res.data.count
  234. obj.plList = res.data.list
  235. // let arr = []//评论列表
  236. // let brr = []//回复列表
  237. // if (res.data.list.length > 0) {
  238. // res.data.list.forEach(item => {
  239. // if (item.user) {
  240. // arr.push(item)
  241. // } else {
  242. // brr.push(item)
  243. // }
  244. // })
  245. // }
  246. // console.log(arr, brr, 'arr++brr')
  247. })
  248. },
  249. getXgList(cid) {
  250. let obj = this
  251. getXgList({
  252. type: cid
  253. }).then(res => {
  254. console.log(res)
  255. obj.xgList = res.data
  256. })
  257. },
  258. subPl() {
  259. let obj = this
  260. console.log('发布评论')
  261. if (obj.myPl == '') {
  262. return obj.$api.msg('请输入评论内容')
  263. }
  264. subPl({
  265. content: obj.myPl
  266. }, obj.artId).then(res => {
  267. obj.myPl = ''
  268. obj.$api.msg('发布成功!')
  269. this.getPlList()
  270. })
  271. },
  272. // 点赞
  273. dianZan() {
  274. let obj = this
  275. dianZan({}, obj.artId).then(res => {
  276. obj.$api.msg('点赞成功!')
  277. })
  278. }
  279. },
  280. }
  281. </script>
  282. <style lang="scss">
  283. page,
  284. .content {
  285. overflow-x: hidden;
  286. width: 100%;
  287. height: 100%;
  288. }
  289. .text-box {
  290. padding: 30rpx;
  291. border: 1rpx solid #EEEEEE;
  292. width: 100%;
  293. background-color: #fff;
  294. .text-title {
  295. display: flex;
  296. flex-direction: column;
  297. .text-1 {
  298. font-size: 33rpx;
  299. font-weight: bold;
  300. color: #333333;
  301. margin-bottom: 30rpx;
  302. }
  303. .text-2 {
  304. display: flex;
  305. align-items: center;
  306. .name {
  307. font-size: 25rpx;
  308. font-weight: 500;
  309. color: #666666;
  310. }
  311. .gg {
  312. margin: 0 15rpx;
  313. width: 3rpx;
  314. height: 25rpx;
  315. background: #EEEEEE;
  316. }
  317. .time {
  318. flex-shrink: 0;
  319. font-size: 22rpx;
  320. font-weight: 500;
  321. color: #999999;
  322. }
  323. }
  324. }
  325. }
  326. .text-content-title {
  327. margin: 30rpx 0;
  328. display: flex;
  329. justify-content: space-between;
  330. align-items: center;
  331. background: #F5F5F5;
  332. padding: 17rpx 30rpx;
  333. border-radius: 7rpx;
  334. .title-left-box {
  335. display: flex;
  336. justify-content: space-between;
  337. align-items: center;
  338. .image {
  339. width: 85rpx;
  340. height: 85rpx;
  341. overflow: hidden;
  342. border-radius: 50%;
  343. margin-right: 18rpx;
  344. image {
  345. width: 100%;
  346. height: 100%;
  347. }
  348. }
  349. .title-left-box-content {
  350. display: flex;
  351. flex-direction: column;
  352. .title-left-box-name {
  353. display: flex;
  354. justify-content: space-between;
  355. align-items: center;
  356. .name-title {
  357. font-size: 29rpx;
  358. font-weight: bold;
  359. color: #333333;
  360. }
  361. .name-dingyue {
  362. margin-left: 15rpx;
  363. font-size: 24rpx;
  364. font-weight: bold;
  365. color: #F3554F;
  366. width: 92rpx;
  367. height: 34rpx;
  368. border: 1rpx solid #F3554F;
  369. border-radius: 17rpx;
  370. line-height: 34rpx;
  371. text-align: center;
  372. }
  373. }
  374. }
  375. .title-left-box-title {
  376. text {
  377. font-size: 20rpx;
  378. font-weight: 500;
  379. color: #999999;
  380. }
  381. }
  382. }
  383. .tt {
  384. color: #B3B3B3;
  385. }
  386. }
  387. /deep/ .content-content {
  388. p {
  389. text-align: justify;
  390. }
  391. }
  392. .pinglun {
  393. background: #F8F8F8;
  394. padding: 20rpx 0;
  395. }
  396. .pinglun-box {
  397. background: #FFFFFF;
  398. .pinglun-title {
  399. font-size: 30rpx;
  400. font-weight: bold;
  401. color: #333333;
  402. line-height: 80rpx;
  403. margin-left: 30rpx;
  404. }
  405. .pinglun-content {
  406. display: flex;
  407. border-top: 1rpx solid #EEEEEE;
  408. // border-bottom: 1rpx solid #EEEEEE;
  409. padding: 30rpx 0 0 30rpx;
  410. .pinglun-content-left {
  411. width: 66rpx;
  412. height: 66rpx;
  413. border-radius: 50%;
  414. overflow: hidden;
  415. image {
  416. width: 100%;
  417. height: 100%;
  418. }
  419. }
  420. .pinglun-content-right {
  421. display: flex;
  422. justify-content: space-between;
  423. margin-left: 30rpx;
  424. display: flex;
  425. flex-direction: column;
  426. .pinglun-name {
  427. font-size: 26rpx;
  428. font-weight: 500;
  429. color: #333333;
  430. }
  431. .pinglun-tit {
  432. margin: 8rpx 0;
  433. font-size: 30rpx;
  434. font-weight: bold;
  435. color: #333333;
  436. }
  437. .pinglun-time {
  438. font-size: 22rpx;
  439. font-weight: bold;
  440. color: #999999;
  441. margin-bottom: 15rpx;
  442. }
  443. }
  444. }
  445. }
  446. .zhankai {
  447. padding: 10rpx 0;
  448. justify-content: center;
  449. display: flex;
  450. align-items: center;
  451. .all {}
  452. image {
  453. margin-left: 10rpx;
  454. width: 20rpx;
  455. height: 20rpx;
  456. }
  457. }
  458. .look {
  459. background: #FFFFFF;
  460. margin-top: 20rpx;
  461. .look-box {
  462. margin: 0 30rpx;
  463. .look-title {
  464. font-size: 30rpx;
  465. font-weight: bold;
  466. color: #333333;
  467. line-height: 80rpx;
  468. margin-left: 30rpx;
  469. }
  470. .look-content {
  471. display: flex;
  472. justify-content: space-between;
  473. padding: 30rpx 0;
  474. border-top: 1px solid #EEEEEE;
  475. border-bottom: 1px solid #EEEEEE;
  476. .look-content-right {
  477. display: flex;
  478. align-items: center;
  479. .look-name {
  480. width: 37rpx;
  481. height: 37rpx;
  482. background: #EE6231;
  483. border-radius: 50%;
  484. font-size: 27rpx;
  485. font-weight: bold;
  486. color: #FFFFFF;
  487. line-height: 37rpx;
  488. text-align: center;
  489. }
  490. .look-tit {
  491. margin-left: 10rpx;
  492. width: 500rpx;
  493. font-size: 27rpx;
  494. font-weight: 500;
  495. color: #333333;
  496. }
  497. }
  498. .look-time {}
  499. }
  500. }
  501. }
  502. .send-box {
  503. // border-top: 1rpx solid #999999;
  504. background: #FFFFFF;
  505. padding: 30rpx;
  506. width: 100%;
  507. position: fixed;
  508. bottom: 0;
  509. display: flex;
  510. justify-content: space-around;
  511. align-items: center;
  512. .input {
  513. padding-left: 30rpx;
  514. width: 550rpx;
  515. height: 60rpx;
  516. background: #EEEEEE;
  517. border-radius: 31rpx;
  518. }
  519. image {
  520. width: 42rpx;
  521. height: 42rpx;
  522. }
  523. }
  524. .pw {
  525. height: 120rpx;
  526. }
  527. .hf-wrap {
  528. width: 600rpx;
  529. background-color: #f4f4f4;
  530. margin-left: 120rpx;
  531. padding: 10rpx;
  532. padding-bottom: 0;
  533. font-size: 26rpx;
  534. border-radius: 10rpx;
  535. .hf {
  536. padding-bottom: 10rpx;
  537. }
  538. }
  539. </style>