dydetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <view class="content">
  3. <!-- 订阅号详情头部 start-->
  4. <view class="dy-info flex">
  5. <view class="user-logo">
  6. <image :src="info.headimg" mode=""></image>
  7. </view>
  8. <view class="user-num">
  9. <view class="user-name">{{ info.name }}</view>
  10. <view class="sub-num">发表文章:{{ info.count }}</view>
  11. </view>
  12. <view class="dy-btn" @click="dingYue()" :class="{ dyue: isDy }">{{ isDy ? '已订阅' : '+订阅' }}</view>
  13. </view>
  14. <!-- 订阅号详情头部 end-->
  15. <!-- 简介 -->
  16. <template v-if="info.introduce">
  17. <view class="jj-top">
  18. <text class="sh"></text>订阅号简介
  19. </view>
  20. <view class="jj-content" style="position: relative;margin-bottom: 20rpx;" @click="navto('/pages/user/dyjj?id=' + info.id)">
  21. <view class="" v-html="info.introduce"
  22. style="height: 195rpx;overflow: hidden;width: 100%;background-color: #fff;text-align: justify;padding: 20rpx;">
  23. </view>
  24. <view class="menban" style="">查看全部</view>
  25. </view>
  26. </template>
  27. <!-- 订阅号详情文章列表 start-->
  28. <!-- <empty v-if="list.loaded === true && list.length === 0"></empty> -->
  29. <view class="jj-top" v-if="list.length > 0">
  30. <text class="sh"></text>文章资讯
  31. </view>
  32. <view>
  33. <view class="art-list" v-for="(item, index) in list" :key="index">
  34. <!-- 文章图片为一 -->
  35. <view class="art-item-one flex art-item" v-if="item.image_input.length == 1"
  36. @click="goToDetail(item.id)">
  37. <view class="art-left flex">
  38. <view class="art-tit clamp2">{{ item.title }}</view>
  39. <view class="art-time">
  40. <!-- <image :src="item.image" mode="" class="hot"></image> -->
  41. <!-- <text class="store-name">{{ info.name }}</text> -->
  42. <text class="pl" v-if="item.comment !=0">{{ item.comment }}评论</text>
  43. <text class="creat-time">
  44. {{item.add_time | showTime}}
  45. </text>
  46. </view>
  47. </view>
  48. <view class="art-right">
  49. <image :src="item.image_input" mode=""></image>
  50. </image>
  51. </view>
  52. </view>
  53. <!-- 文章图片为零 -->
  54. <view class="art-item-zero flex art-item" v-if="item.image_input.length == 0"
  55. @click="goToDetail(item.id)">
  56. <view class="art-tit clamp2">{{ item.title }}</view>
  57. <view class="art-time">
  58. <!-- <image src="../../static/icon/hot.png" mode="" class="hot"></image> -->
  59. <!-- <text class="store-name">{{ info.name }}</text> -->
  60. <text class="pl" v-if="item.comment !=0">{{ item.comment }}评论</text>
  61. <text class="creat-time">
  62. {{item.add_time | showTime}}
  63. </text>
  64. </view>
  65. </view>
  66. <!-- 文章图片大于一 -->
  67. <view class="art-item-three art-item flex" v-if="item.image_input.length > 1"
  68. @click="goToDetail(item.id)">
  69. <view class="art-tit clamp2">{{ item.title }}</view>
  70. <view class="art-img-list">
  71. <image :src="iem" mode="" v-for="(iem, ind) in item.image_input"></image>
  72. </view>
  73. <view class="art-time">
  74. <!-- <image src="../../static/icon/hot.png" mode="" class="hot"></image> -->
  75. <!-- <text class="store-name">{{ info.name }}</text> -->
  76. <text class="pl" v-if="item.comment !=0">{{ item.comment }}评论</text>
  77. <text class="creat-time">
  78. {{item.add_time | showTime}}
  79. </text>
  80. </view>
  81. </view>
  82. </view>
  83. <uni-load-more :status="loadingType"></uni-load-more>
  84. </view>
  85. <!-- 订阅号详情文章列表 end-->
  86. </view>
  87. </template>
  88. <script>
  89. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  90. import empty from '@/components/empty';
  91. import {
  92. enDetails
  93. } from '@/api/user.js';
  94. import {
  95. timeComputed
  96. } from '@/utils/rocessor.js';
  97. import {
  98. dingYue
  99. } from '@/api/art.js';
  100. export default {
  101. components: {
  102. empty,
  103. uniLoadMore
  104. },
  105. data() {
  106. return {
  107. isDy: false,
  108. id: '',
  109. page: 1,
  110. limit: 10,
  111. list: [],
  112. loadingType: 'more',
  113. info: ''
  114. };
  115. },
  116. filters: {
  117. showTime(dateTime) {
  118. //dateTimeStamp是一个时间毫秒,注意时间戳是秒的形式,在这个毫秒的基础上除以1000,就是十位数的时间戳。13位数的都是时间毫秒。
  119. dateTime = dateTime*1000
  120. var minute = 1000 * 60 //把分,时,天,周,半个月,一个月用毫秒表示
  121. var hour = minute * 60
  122. var day = hour * 24
  123. var week = day * 7
  124. var halfamonth = day * 15
  125. var month = day * 30
  126. var now = new Date().getTime() //获取当前时间毫秒
  127. var dateTimeStamp = new Date(dateTime)
  128. var diffValue = now - dateTimeStamp //时间差
  129. if (diffValue < 0) {
  130. return
  131. }
  132. var minC = diffValue / minute //计算时间差的分,时,天,周,月
  133. var hourC = diffValue / hour
  134. var dayC = diffValue / day
  135. var weekC = diffValue / week
  136. var monthC = diffValue / month
  137. var result = ''
  138. console.log(monthC,weekC,dayC,hourC,minC)
  139. if (monthC >= 1 && monthC <= 3) {
  140. result = ' ' + parseInt(monthC) + '月前'
  141. } else if (weekC >= 1 && weekC <= 4) {
  142. result = ' ' + parseInt(weekC) + '周前'
  143. } else if (dayC >= 1 && dayC <= 7) {
  144. result = ' ' + parseInt(dayC) + '天前'
  145. } else if (hourC >= 1 && hourC <= 24) {
  146. result = ' ' + parseInt(hourC) + '小时前'
  147. } else if (minC >= 1 && minC <= 60) {
  148. result = ' ' + parseInt(minC) + '分钟前'
  149. } else if (diffValue >= 0 && diffValue <= minute) {
  150. result = '刚刚'
  151. } else {
  152. var datetime = new Date()
  153. datetime.setTime(dateTimeStamp)
  154. var Nyear = datetime.getFullYear()
  155. var Nmonth =
  156. datetime.getMonth() + 1 < 10 ?
  157. '0' + (datetime.getMonth() + 1) :
  158. datetime.getMonth() + 1
  159. var Ndate =
  160. datetime.getDate() < 10 ?
  161. '0' + datetime.getDate() :
  162. datetime.getDate()
  163. var Nhour =
  164. datetime.getHours() < 10 ?
  165. '0' + datetime.getHours() :
  166. datetime.getHours()
  167. var Nminute =
  168. datetime.getMinutes() < 10 ?
  169. '0' + datetime.getMinutes() :
  170. datetime.getMinutes()
  171. var Nsecond =
  172. datetime.getSeconds() < 10 ?
  173. '0' + datetime.getSeconds() :
  174. datetime.getSeconds()
  175. result = Nyear + '-' + Nmonth + '-' + Ndate
  176. }
  177. return result
  178. },
  179. },
  180. onLoad(option) {
  181. this.id = option.id;
  182. this.loadData();
  183. },
  184. onReachBottom() {
  185. this.loadData()
  186. },
  187. methods: {
  188. goToDetail(id) {
  189. uni.navigateTo({
  190. url: '/pages/user/article?id=' + id
  191. })
  192. },
  193. navto(url) {
  194. uni.navigateTo({
  195. url
  196. })
  197. },
  198. loadData() {
  199. const obj = this
  200. if (this.loadingType == 'noMore' || this.loadingType == 'loading') {
  201. return
  202. }
  203. this.loadingType = 'loading'
  204. enDetails({
  205. id: this.id,
  206. page: this.page,
  207. rows: this.limit
  208. }).then(({
  209. data
  210. }) => {
  211. this.info = data.content.list[0];
  212. if (this.info.introduce) {
  213. this.info.introduce = this.info.introduce.replace(/<img/g,
  214. "<img style='max-width:100%;height:auto;'")
  215. }
  216. if (this.info.is_sub == 1) {
  217. this.isDy = true;
  218. }
  219. console.log(this.info);
  220. // data.list.forEach(e => {
  221. // let time = timeComputed(e.add_time * 1000);
  222. // e.day = time.day;
  223. // e.hour = time.hours;
  224. // e.minutes = time.minutes;
  225. // e.seconds = time.seconds;
  226. // });
  227. this.list = this.list.concat(data.list);
  228. if (data.list.length === obj.limit) {
  229. obj.page++
  230. obj.loadingType = 'more'
  231. } else {
  232. obj.loadingType = 'noMore'
  233. }
  234. this.$set(obj.list, 'loaded', true);
  235. });
  236. },
  237. dingYue() {
  238. let obj = this;
  239. if (this.isDy) {
  240. uni.showModal({
  241. title: '提示',
  242. content: '是否取消关注?',
  243. complete(e) {
  244. if (e.confirm) {
  245. obj.isDy = !obj.isDy;
  246. dingYue({
  247. id: obj.id
  248. }).then(res => {
  249. obj.$api.msg('已取消关注');
  250. });
  251. }
  252. }
  253. });
  254. } else {
  255. obj.isDy = !obj.isDy;
  256. dingYue({
  257. id: obj.id
  258. }).then(res => {
  259. obj.$api.msg('关注成功');
  260. });
  261. }
  262. }
  263. }
  264. };
  265. </script>
  266. <style lang="scss" scoped>
  267. .jj {
  268. margin: 20rpx 30rpx;
  269. display: flex;
  270. flex-direction: column;
  271. .jj-title {
  272. font-size: 28rpx;
  273. font-weight: 500;
  274. }
  275. .jj-content {
  276. // overflow: hidden;
  277. // text-overflow: ellipsis;
  278. // display: -webkit-box;
  279. // -webkit-line-clamp: 4; // 控制多行的行数
  280. // -webkit-box-orient: vertical;
  281. margin-left: 20rpx;
  282. font-size: 24rpx;
  283. font-weight: 500;
  284. line-height: 36rpx;
  285. .jj-xq {
  286. text {
  287. color: #03A9F4;
  288. }
  289. }
  290. }
  291. }
  292. .dy-info {
  293. width: 750rpx;
  294. height: 197rpx;
  295. background-color: #ff6d6e;
  296. padding: 0 30rpx;
  297. color: #fff;
  298. .user-logo {
  299. flex-shrink: 0;
  300. height: 100rpx;
  301. width: 100rpx;
  302. border-radius: 50%;
  303. image {
  304. width: 100%;
  305. height: 100%;
  306. border-radius: 50%;
  307. }
  308. }
  309. .user-num {
  310. flex-grow: 1;
  311. padding-left: 10rpx;
  312. font-size: 24rpx;
  313. font-weight: 500;
  314. // color: #999999;
  315. .user-name {
  316. font-size: 34rpx;
  317. font-weight: 600;
  318. // color: #333333;
  319. padding-right: 20rpx;
  320. padding: 0 20rpx 10rpx 0;
  321. }
  322. }
  323. .dy-btn {
  324. flex-shrink: 0;
  325. text-align: center;
  326. width: 136rpx;
  327. line-height: 66rpx;
  328. background: #fff;
  329. border-radius: 10rpx;
  330. font-size: 28rpx;
  331. font-weight: 500;
  332. color: #ff6061;
  333. }
  334. }
  335. .art-list {
  336. background-color: #fff;
  337. width: 750rpx;
  338. font-size: 31rpx;
  339. font-weight: 500;
  340. color: #323232;
  341. // font-weight: bold;
  342. }
  343. .art-item {
  344. width: 691rpx;
  345. border-bottom: #e1e1e1 1px solid;
  346. margin: auto;
  347. &:last-of-type {
  348. border-bottom: none;
  349. }
  350. }
  351. .art-item-zero {
  352. height: 153rpx;
  353. flex-direction: column;
  354. justify-content: space-between;
  355. align-items: flex-start;
  356. padding: 20rpx 0;
  357. border-bottom: #e1e1e1 1px solid;
  358. }
  359. .art-item-one {
  360. height: 195rpx;
  361. margin: auto;
  362. padding: 30rpx 0 20rpx;
  363. .art-left {
  364. height: 100%;
  365. flex-direction: column;
  366. justify-content: space-between;
  367. align-items: flex-start;
  368. padding-right: 40rpx;
  369. }
  370. .art-right {
  371. width: 227rpx;
  372. height: 145rpx;
  373. border-radius: 10rpx;
  374. flex-shrink: 0;
  375. image {
  376. width: 100%;
  377. height: 100%;
  378. border-radius: 10rpx;
  379. }
  380. }
  381. }
  382. .art-item-three {
  383. height: 345rpx;
  384. flex-direction: column;
  385. justify-content: space-between;
  386. align-items: flex-start;
  387. padding: 30rpx 0;
  388. .art-img-list {
  389. width: 100%;
  390. height: 145rpx;
  391. // background-color: #bfa;
  392. // border-radius: 10px;
  393. image {
  394. width: 220rpx;
  395. height: 145rpx;
  396. border-radius: 10rpx;
  397. margin-right: 15rpx;
  398. &:last-child {
  399. margin-right: 0;
  400. }
  401. }
  402. }
  403. }
  404. .hot {
  405. width: 22rpx;
  406. height: 22rpx;
  407. margin-right: 10rpx;
  408. }
  409. .art-tit {
  410. font-size: 28rpx;
  411. line-height: 1.2;
  412. }
  413. .art-time {
  414. display: inline-block;
  415. font-size: 24rpx;
  416. font-weight: 500;
  417. color: #7f8699;
  418. text {
  419. margin-right: 10rpx;
  420. }
  421. }
  422. .jj-top {
  423. margin-top: 20rpx;
  424. line-height: 55rpx;
  425. background-color: #fff;
  426. padding-left: 20rpx;
  427. .sh {
  428. display: inline-block;
  429. width: 6rpx;
  430. height: 26rpx;
  431. background-color: #e50112;
  432. margin: 18rpx 12rpx 0 0;
  433. border-radius: 3rpx;
  434. font-size: 26rpx;
  435. }
  436. }
  437. .jj-content {
  438. .menban {
  439. background: #fff;
  440. line-height: 50rpx;
  441. width: 100%;
  442. z-index: 9;
  443. position: absolute;
  444. bottom: 0;
  445. text-align: center;
  446. background:linear-gradient(to bottom,rgba(255,255,255,0.8),rgba(255,255,255,1))
  447. }
  448. }
  449. </style>