article.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  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">
  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)">
  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">
  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. weixindata,
  127. shareLoad
  128. } from '@/utils/wxAuthorized.js';
  129. import {
  130. getArtDetail,
  131. getPlList,
  132. getXgList,
  133. dianZan,
  134. subPl
  135. } from '@/api/art.js'
  136. import {
  137. getTime
  138. } from '@/utils/rocessor.js'
  139. export default {
  140. data() {
  141. return {
  142. isDingyue: false, //是否订阅
  143. plNum: 10, //评论数量
  144. dyNumber: 10, //订阅人数
  145. isZhankai: false, //是否展开
  146. artId: 0,
  147. artData: {},
  148. plList: [],
  149. xgList: [], //相关阅读
  150. myPl: '', //我的评论
  151. };
  152. },
  153. filters: {
  154. getTime
  155. },
  156. onLoad(opt) {
  157. if (opt.id) {
  158. this.artId = opt.id
  159. }
  160. this.getArtDetail()
  161. this.getPlList()
  162. },
  163. methods: {
  164. // 分享
  165. IndexShare() {
  166. let obj = this;
  167. // let money = obj.money;
  168. let item = {
  169. link: obj.$store.state.baseURL + '/index/#/pages/user/article?id=' + obj.artId, // 分享链接
  170. imgUrl: obj.artData.image_input[0],
  171. desc: obj.artData.synopsis,
  172. title: obj.artData.title,
  173. success: console.log('分享加载成功')
  174. };
  175. shareLoad(item);
  176. },
  177. navTo(url) {
  178. uni.navigateTo({
  179. url
  180. })
  181. },
  182. //展开全部
  183. zhankai() {
  184. if (this.isZhankai == false) {
  185. this.isZhankai = true
  186. } else if (this.isZhankai == true) {
  187. this.isZhankai = false
  188. }
  189. },
  190. // 获取详情
  191. getArtDetail() {
  192. let obj = this
  193. getArtDetail({}, obj.artId).then(res => {
  194. console.log(res)
  195. obj.artData = res.data
  196. if (obj.artData.content != null) {
  197. obj.artData.content = obj.artData.content.replace(/<img/g,
  198. "<img style='max-width:100%;height:auto;'");
  199. // obj.artData.content = obj.artData.content.replace(/<p style="text-indent:28px/g," <p style='text-indent:28px;text-align: justify;");
  200. } //小程序商品详情图超出屏幕问题
  201. this.getXgList(res.data.cid)
  202. this.IndexShare()
  203. })
  204. },
  205. getPlList() {
  206. let obj = this
  207. getPlList({}, obj.artId).then(res => {
  208. console.log(res)
  209. obj.plNum = res.data.count
  210. obj.plList = res.data.list
  211. // let arr = []//评论列表
  212. // let brr = []//回复列表
  213. // if (res.data.list.length > 0) {
  214. // res.data.list.forEach(item => {
  215. // if (item.user) {
  216. // arr.push(item)
  217. // } else {
  218. // brr.push(item)
  219. // }
  220. // })
  221. // }
  222. // console.log(arr, brr, 'arr++brr')
  223. })
  224. },
  225. getXgList(cid) {
  226. let obj = this
  227. getXgList({
  228. type: cid
  229. }).then(res => {
  230. console.log(res)
  231. obj.xgList = res.data
  232. })
  233. },
  234. subPl() {
  235. let obj = this
  236. console.log('发布评论')
  237. if (obj.myPl == '') {
  238. return obj.$api.msg('请输入评论内容')
  239. }
  240. subPl({
  241. content: obj.myPl
  242. }, obj.artId).then(res => {
  243. obj.myPl = ''
  244. obj.$api.msg('发布成功!')
  245. this.getPlList()
  246. })
  247. },
  248. // 点赞
  249. dianZan() {
  250. let obj = this
  251. dianZan({}, obj.artId).then(res => {
  252. obj.$api.msg('点赞成功!')
  253. })
  254. }
  255. },
  256. }
  257. </script>
  258. <style lang="scss">
  259. page,
  260. .content {
  261. overflow-x: hidden;
  262. width: 100%;
  263. height: 100%;
  264. }
  265. .text-box {
  266. padding: 30rpx;
  267. border: 1rpx solid #EEEEEE;
  268. width: 100%;
  269. background-color: #fff;
  270. .text-title {
  271. display: flex;
  272. flex-direction: column;
  273. .text-1 {
  274. font-size: 33rpx;
  275. font-weight: bold;
  276. color: #333333;
  277. margin-bottom: 30rpx;
  278. }
  279. .text-2 {
  280. display: flex;
  281. align-items: center;
  282. .name {
  283. font-size: 25rpx;
  284. font-weight: 500;
  285. color: #666666;
  286. }
  287. .gg {
  288. margin: 0 15rpx;
  289. width: 3rpx;
  290. height: 25rpx;
  291. background: #EEEEEE;
  292. }
  293. .time {
  294. flex-shrink: 0;
  295. font-size: 22rpx;
  296. font-weight: 500;
  297. color: #999999;
  298. }
  299. }
  300. }
  301. }
  302. .text-content-title {
  303. margin: 30rpx 0;
  304. display: flex;
  305. justify-content: space-between;
  306. align-items: center;
  307. background: #F5F5F5;
  308. padding: 17rpx 30rpx;
  309. border-radius: 7rpx;
  310. .title-left-box {
  311. display: flex;
  312. justify-content: space-between;
  313. align-items: center;
  314. .image {
  315. width: 85rpx;
  316. height: 85rpx;
  317. overflow: hidden;
  318. border-radius: 50%;
  319. margin-right: 18rpx;
  320. image {
  321. width: 100%;
  322. height: 100%;
  323. }
  324. }
  325. .title-left-box-content {
  326. display: flex;
  327. flex-direction: column;
  328. .title-left-box-name {
  329. display: flex;
  330. justify-content: space-between;
  331. align-items: center;
  332. .name-title {
  333. font-size: 29rpx;
  334. font-weight: bold;
  335. color: #333333;
  336. }
  337. .name-dingyue {
  338. margin-left: 15rpx;
  339. font-size: 24rpx;
  340. font-weight: bold;
  341. color: #F3554F;
  342. width: 92rpx;
  343. height: 34rpx;
  344. border: 1rpx solid #F3554F;
  345. border-radius: 17rpx;
  346. line-height: 34rpx;
  347. text-align: center;
  348. }
  349. }
  350. }
  351. .title-left-box-title {
  352. text {
  353. font-size: 20rpx;
  354. font-weight: 500;
  355. color: #999999;
  356. }
  357. }
  358. }
  359. .tt {
  360. color: #B3B3B3;
  361. }
  362. }
  363. /deep/ .content-content {
  364. p {
  365. text-align: justify;
  366. }
  367. }
  368. .pinglun {
  369. background: #F8F8F8;
  370. padding: 20rpx 0;
  371. }
  372. .pinglun-box {
  373. background: #FFFFFF;
  374. .pinglun-title {
  375. font-size: 30rpx;
  376. font-weight: bold;
  377. color: #333333;
  378. line-height: 80rpx;
  379. margin-left: 30rpx;
  380. }
  381. .pinglun-content {
  382. display: flex;
  383. border-top: 1rpx solid #EEEEEE;
  384. // border-bottom: 1rpx solid #EEEEEE;
  385. padding: 30rpx 0 0 30rpx;
  386. .pinglun-content-left {
  387. width: 66rpx;
  388. height: 66rpx;
  389. border-radius: 50%;
  390. overflow: hidden;
  391. image {
  392. width: 100%;
  393. height: 100%;
  394. }
  395. }
  396. .pinglun-content-right {
  397. display: flex;
  398. justify-content: space-between;
  399. margin-left: 30rpx;
  400. display: flex;
  401. flex-direction: column;
  402. .pinglun-name {
  403. font-size: 26rpx;
  404. font-weight: 500;
  405. color: #333333;
  406. }
  407. .pinglun-tit {
  408. margin: 8rpx 0;
  409. font-size: 30rpx;
  410. font-weight: bold;
  411. color: #333333;
  412. }
  413. .pinglun-time {
  414. font-size: 22rpx;
  415. font-weight: bold;
  416. color: #999999;
  417. margin-bottom: 15rpx;
  418. }
  419. }
  420. }
  421. }
  422. .zhankai {
  423. padding: 10rpx 0;
  424. justify-content: center;
  425. display: flex;
  426. align-items: center;
  427. .all {}
  428. image {
  429. margin-left: 10rpx;
  430. width: 20rpx;
  431. height: 20rpx;
  432. }
  433. }
  434. .look {
  435. background: #FFFFFF;
  436. margin-top: 20rpx;
  437. .look-box {
  438. margin: 0 30rpx;
  439. .look-title {
  440. font-size: 30rpx;
  441. font-weight: bold;
  442. color: #333333;
  443. line-height: 80rpx;
  444. margin-left: 30rpx;
  445. }
  446. .look-content {
  447. display: flex;
  448. justify-content: space-between;
  449. padding: 30rpx 0;
  450. border-top: 1px solid #EEEEEE;
  451. border-bottom: 1px solid #EEEEEE;
  452. .look-content-right {
  453. display: flex;
  454. align-items: center;
  455. .look-name {
  456. width: 37rpx;
  457. height: 37rpx;
  458. background: #EE6231;
  459. border-radius: 50%;
  460. font-size: 27rpx;
  461. font-weight: bold;
  462. color: #FFFFFF;
  463. line-height: 37rpx;
  464. text-align: center;
  465. }
  466. .look-tit {
  467. margin-left: 10rpx;
  468. width: 500rpx;
  469. font-size: 27rpx;
  470. font-weight: 500;
  471. color: #333333;
  472. }
  473. }
  474. .look-time {}
  475. }
  476. }
  477. }
  478. .send-box {
  479. // border-top: 1rpx solid #999999;
  480. background: #FFFFFF;
  481. padding: 30rpx;
  482. width: 100%;
  483. position: fixed;
  484. bottom: 0;
  485. display: flex;
  486. justify-content: space-around;
  487. align-items: center;
  488. .input {
  489. padding-left: 30rpx;
  490. width: 550rpx;
  491. height: 60rpx;
  492. background: #EEEEEE;
  493. border-radius: 31rpx;
  494. }
  495. image {
  496. width: 42rpx;
  497. height: 42rpx;
  498. }
  499. }
  500. .pw {
  501. height: 120rpx;
  502. }
  503. .hf-wrap {
  504. width: 600rpx;
  505. background-color: #f4f4f4;
  506. margin-left: 120rpx;
  507. padding: 10rpx;
  508. padding-bottom: 0;
  509. font-size: 26rpx;
  510. border-radius: 10rpx;
  511. .hf {
  512. padding-bottom: 10rpx;
  513. }
  514. }
  515. </style>