dydetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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. console.log(this.info.introduce,'this.info.introduce');
  216. }
  217. if (this.info.is_sub == 1) {
  218. this.isDy = true;
  219. }
  220. console.log(this.info);
  221. // data.list.forEach(e => {
  222. // let time = timeComputed(e.add_time * 1000);
  223. // e.day = time.day;
  224. // e.hour = time.hours;
  225. // e.minutes = time.minutes;
  226. // e.seconds = time.seconds;
  227. // });
  228. this.list = this.list.concat(data.list);
  229. if (data.list.length === obj.limit) {
  230. obj.page++
  231. obj.loadingType = 'more'
  232. } else {
  233. obj.loadingType = 'noMore'
  234. }
  235. this.$set(obj.list, 'loaded', true);
  236. });
  237. },
  238. dingYue() {
  239. let obj = this;
  240. if (this.isDy) {
  241. uni.showModal({
  242. title: '提示',
  243. content: '是否取消关注?',
  244. complete(e) {
  245. if (e.confirm) {
  246. obj.isDy = !obj.isDy;
  247. dingYue({
  248. id: obj.id
  249. }).then(res => {
  250. obj.$api.msg('已取消关注');
  251. });
  252. }
  253. }
  254. });
  255. } else {
  256. obj.isDy = !obj.isDy;
  257. dingYue({
  258. id: obj.id
  259. }).then(res => {
  260. obj.$api.msg('关注成功');
  261. });
  262. }
  263. }
  264. }
  265. };
  266. </script>
  267. <style lang="scss" scoped>
  268. .jj {
  269. margin: 20rpx 30rpx;
  270. display: flex;
  271. flex-direction: column;
  272. .jj-title {
  273. font-size: 28rpx;
  274. font-weight: 500;
  275. }
  276. .jj-content {
  277. // overflow: hidden;
  278. // text-overflow: ellipsis;
  279. // display: -webkit-box;
  280. // -webkit-line-clamp: 4; // 控制多行的行数
  281. // -webkit-box-orient: vertical;
  282. margin-left: 20rpx;
  283. font-size: 24rpx;
  284. font-weight: 500;
  285. line-height: 36rpx;
  286. .jj-xq {
  287. text {
  288. color: #03A9F4;
  289. }
  290. }
  291. }
  292. }
  293. .dy-info {
  294. width: 750rpx;
  295. height: 197rpx;
  296. background-color: #ff6d6e;
  297. padding: 0 30rpx;
  298. color: #fff;
  299. .user-logo {
  300. flex-shrink: 0;
  301. height: 100rpx;
  302. width: 100rpx;
  303. border-radius: 50%;
  304. image {
  305. width: 100%;
  306. height: 100%;
  307. border-radius: 50%;
  308. }
  309. }
  310. .user-num {
  311. flex-grow: 1;
  312. padding-left: 10rpx;
  313. font-size: 24rpx;
  314. font-weight: 500;
  315. // color: #999999;
  316. .user-name {
  317. font-size: 34rpx;
  318. font-weight: 600;
  319. // color: #333333;
  320. padding-right: 20rpx;
  321. padding: 0 20rpx 10rpx 0;
  322. }
  323. }
  324. .dy-btn {
  325. flex-shrink: 0;
  326. text-align: center;
  327. width: 136rpx;
  328. line-height: 66rpx;
  329. background: #fff;
  330. border-radius: 10rpx;
  331. font-size: 28rpx;
  332. font-weight: 500;
  333. color: #ff6061;
  334. }
  335. }
  336. .art-list {
  337. background-color: #fff;
  338. width: 750rpx;
  339. font-size: 31rpx;
  340. font-weight: 500;
  341. color: #323232;
  342. // font-weight: bold;
  343. }
  344. .art-item {
  345. width: 691rpx;
  346. border-bottom: #e1e1e1 1px solid;
  347. margin: auto;
  348. &:last-of-type {
  349. border-bottom: none;
  350. }
  351. }
  352. .art-item-zero {
  353. height: 153rpx;
  354. flex-direction: column;
  355. justify-content: space-between;
  356. align-items: flex-start;
  357. padding: 20rpx 0;
  358. border-bottom: #e1e1e1 1px solid;
  359. }
  360. .art-item-one {
  361. height: 195rpx;
  362. margin: auto;
  363. padding: 30rpx 0 20rpx;
  364. .art-left {
  365. height: 100%;
  366. flex-direction: column;
  367. justify-content: space-between;
  368. align-items: flex-start;
  369. padding-right: 40rpx;
  370. }
  371. .art-right {
  372. width: 227rpx;
  373. height: 145rpx;
  374. border-radius: 10rpx;
  375. flex-shrink: 0;
  376. image {
  377. width: 100%;
  378. height: 100%;
  379. border-radius: 10rpx;
  380. }
  381. }
  382. }
  383. .art-item-three {
  384. height: 345rpx;
  385. flex-direction: column;
  386. justify-content: space-between;
  387. align-items: flex-start;
  388. padding: 30rpx 0;
  389. .art-img-list {
  390. width: 100%;
  391. height: 145rpx;
  392. // background-color: #bfa;
  393. // border-radius: 10px;
  394. image {
  395. width: 220rpx;
  396. height: 145rpx;
  397. border-radius: 10rpx;
  398. margin-right: 15rpx;
  399. &:last-child {
  400. margin-right: 0;
  401. }
  402. }
  403. }
  404. }
  405. .hot {
  406. width: 22rpx;
  407. height: 22rpx;
  408. margin-right: 10rpx;
  409. }
  410. .art-tit {
  411. font-size: 28rpx;
  412. line-height: 1.2;
  413. }
  414. .art-time {
  415. display: inline-block;
  416. font-size: 24rpx;
  417. font-weight: 500;
  418. color: #7f8699;
  419. text {
  420. margin-right: 10rpx;
  421. }
  422. }
  423. .jj-top {
  424. margin-top: 20rpx;
  425. line-height: 55rpx;
  426. background-color: #fff;
  427. padding-left: 20rpx;
  428. .sh {
  429. display: inline-block;
  430. width: 6rpx;
  431. height: 26rpx;
  432. background-color: #e50112;
  433. margin: 18rpx 12rpx 0 0;
  434. border-radius: 3rpx;
  435. font-size: 26rpx;
  436. }
  437. }
  438. .jj-content {
  439. .menban {
  440. background: #fff;
  441. line-height: 50rpx;
  442. width: 100%;
  443. z-index: 9;
  444. position: absolute;
  445. bottom: 0;
  446. text-align: center;
  447. background:linear-gradient(to bottom,rgba(255,255,255,0.8),rgba(255,255,255,1))
  448. }
  449. }
  450. </style>