article.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div class="community-u" ref="container" style="width:100%;" @scroll="containerScroll">
  3. <vuescroll :ops="ops">
  4. <template v-for="item in ad">
  5. <div class="live margin-0-auto">
  6. <div class="live-top align-center">
  7. <a :href="item.url" target="_blank">
  8. <div class="live-title inline-block">{{item.title}}</div>
  9. </a>
  10. </div>
  11. <div class="live-bottom align-center justify-between">
  12. <div class="align-center">
  13. <div class="live-statu align-center">
  14. <img src="~@/assets/quan/icon/live-in.png" />
  15. <div>活动直播</div>
  16. </div>
  17. <div class="live-source align-center">
  18. <img class="avatar" :src="item.icon_url" />
  19. <div>{{ item.nickname }}</div>
  20. </div>
  21. <div class="live-time gray-153">{{item.updated_at}}</div>
  22. </div>
  23. <div class="live-people gray-51 align-center">
  24. <img class="see icon" src="~@/assets/quan/icon/see.png" />
  25. <div>{{item.view_count}}人在看</div>
  26. </div>
  27. </div>
  28. <img
  29. class="close icon"
  30. src="~@/assets/quan/icon/close.png"
  31. onclick="$(this).parent().slideUp();"
  32. />
  33. </div>
  34. </template>
  35. <template v-for="article in list" v-if="active == 'default'">
  36. <template v-if="article.image">
  37. <!-- 有图 -->
  38. <div class="article-box">
  39. <div class="flex">
  40. <div class="justify-between">
  41. <div class="article-title">
  42. <a :href="'/p/'+ article.hash_id ">{{article.title}}</a>
  43. </div>
  44. <div class="article-info lign-center">
  45. <div class="live-source align-center">
  46. <img class="avatar" :src="article.user.avatar" />
  47. <div>{{article.user?article.user.name:'匿名'}}</div>
  48. </div>
  49. <div class="live-time gray-153">{{article.updated_at}}</div>
  50. <div class="live-people gray-51 align-center">
  51. <img class="see icon" src="~@/assets/quan/icon/see.png" />
  52. <div>{{article.like_count}}</div>
  53. </div>
  54. <div class="live-people gray-51 align-center">
  55. <img class="see icon" src="~@/assets/quan/icon/common.png" />
  56. <div>{{article.reply_count}}</div>
  57. </div>
  58. </div>
  59. </div>
  60. <img class="article-img" :src="article.cover_url" />
  61. </div>
  62. </div>
  63. </template>
  64. <template v-else>
  65. <!-- 无图 -->
  66. <div class="article-box">
  67. <div class="flex">
  68. <div class="justify-between">
  69. <div class="article-title">
  70. <a :href="'/p/'+ article.hash_id ">{{article.title}}</a>
  71. </div>
  72. <div class="article-info align-center">
  73. <div class="live-source align-center">
  74. <img class="avatar" :src="article.user.avatar" />
  75. <div>{{article.user?article.user.name:'匿名'}}</div>
  76. </div>
  77. <div class="live-time gray-153">{{article.updated_at}}</div>
  78. <div class="live-people gray-51 align-center">
  79. <img class="see icon" src="~@/assets/quan/icon/see.png" />
  80. <div>{{article.like_count}}</div>
  81. </div>
  82. <div class="live-people gray-51 align-center">
  83. <img class="see icon" src="~@/assets/quan/icon/common.png" />
  84. <div>{{article.reply_count}}</div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </template>
  91. </template>
  92. <p class="loading">{{ loadingText}}</p>
  93. </vuescroll>
  94. <router-view />
  95. <van-tabbar route>
  96. <van-tabbar-item replace badge="3" to="/user/index/article">
  97. <span>文章</span>
  98. <template #icon="props">
  99. <img :src="props.active ? icon.article.active : icon.article.inactive" />
  100. </template>
  101. </van-tabbar-item>
  102. <van-tabbar-item replace to="/user/index/video" icon="search">
  103. <span>视频</span>
  104. <template #icon="props">
  105. <img :src="props.active ? icon.video.active : icon.video.inactive" />
  106. </template>
  107. </van-tabbar-item>
  108. <van-tabbar-item
  109. replace
  110. :to="`/u/`+$store.state.userinfo.uid"
  111. icon="search"
  112. v-if="$store.state.userinfo.uid"
  113. >
  114. <span>我的</span>
  115. <template #icon="props">
  116. <img :src="props.active ? icon.my.active : icon.my.inactive" />
  117. </template>
  118. </van-tabbar-item>
  119. <van-tabbar-item replace @click="goLogin()" icon="search" v-else>
  120. <span>我的</span>
  121. <template #icon="props">
  122. <img :src="props.active ? icon.my.active : icon.my.inactive" />
  123. </template>
  124. </van-tabbar-item>
  125. </van-tabbar>
  126. </div>
  127. </template>
  128. <script>
  129. import { Tabbar, TabbarItem } from "vant";
  130. import vuescroll from "vuescroll";
  131. let container;
  132. export default {
  133. layout: "opacity_header",
  134. async asyncData() {
  135. return {
  136. title: `选择新建类型-程序员客栈`
  137. };
  138. },
  139. components: {
  140. vuescroll
  141. },
  142. data() {
  143. return {
  144. ops: {
  145. mode: "native",
  146. sizeStrategy: "percent",
  147. detectResize: true
  148. },
  149. active: "default",
  150. list: [],
  151. page: {
  152. page: 1,
  153. noMore: 0
  154. },
  155. ad: {},
  156. icon: {
  157. article: {
  158. active: require("../../../assets/quan/icon/book_s.png"),
  159. inactive: require("../../../assets/quan/icon/book.png")
  160. },
  161. video: {
  162. active: require("../../../assets/quan/icon/video_s.png"),
  163. inactive: require("../../../assets/quan/icon/video.png")
  164. },
  165. my: {
  166. active: require("../../../assets/quan/icon/my_s.png"),
  167. inactive: require("../../../assets/quan/icon/my.png")
  168. }
  169. }
  170. };
  171. },
  172. mounted() {
  173. container = this.$refs.container;
  174. },
  175. created() {
  176. this.needLogin();
  177. this.getAD();
  178. this.getList();
  179. },
  180. methods: {
  181. getAD() {
  182. let that = this;
  183. this.$axios.$get("/api/jishuquan/get_ads").then(res => {
  184. that.ad = res.data;
  185. });
  186. },
  187. getList() {
  188. let that = this;
  189. let page = that.page;
  190. this.$axios
  191. .$get(
  192. this.$store.state.domainConfig.jishuinUrl +
  193. "/list/" +
  194. this.active +
  195. "/" +
  196. page.page
  197. )
  198. .then(res => {
  199. if (res.topics.length > 0) {
  200. let list = that.list;
  201. that.list = list.concat(res.topics);
  202. page++;
  203. } else {
  204. page.noMore = 1;
  205. }
  206. that.page = page;
  207. });
  208. },
  209. /**
  210. * 监听滚动
  211. */
  212. containerScroll() {
  213. console.log("999");
  214. if (this.isLoading || this.noMore) return;
  215. // PC不监听
  216. if (this.$store.state.isPC) return;
  217. if (
  218. container.scrollHeight - container.scrollTop - container.clientHeight <
  219. 50
  220. ) {
  221. this.getList();
  222. }
  223. }
  224. }
  225. };
  226. </script>
  227. <style scoped>
  228. @import "@/assets/css/user/mui.min.css";
  229. body {
  230. background-color: white;
  231. }
  232. html {
  233. font-size: 16px !important;
  234. }
  235. </style>
  236. <style lang='less' scoped>
  237. .community-u {
  238. position: absolute;
  239. top: 0;
  240. left: 0;
  241. right: 0;
  242. bottom: 20px;
  243. }
  244. .avatar {
  245. border-radius: 50%;
  246. }
  247. .add-con {
  248. width: 3rem;
  249. height: 3rem;
  250. background: rgba(48, 142, 255, 1);
  251. box-shadow: 0rem 0.12rem 0.54rem 0rem rgba(48, 142, 255, 0.63);
  252. color: white;
  253. position: fixed;
  254. right: 1rem;
  255. bottom: 4rem;
  256. line-height: 3rem;
  257. text-align: center;
  258. z-index: 1000;
  259. border-radius: 50%;
  260. font-size: 2rem;
  261. }
  262. .live,
  263. .article-box {
  264. margin: 0 0.63rem;
  265. padding: 1.25rem 0 1.1rem 0;
  266. position: relative;
  267. }
  268. .live-title {
  269. width: 20.31rem;
  270. font-size: 0.94rem;
  271. font-family: PingFangSC-Medium;
  272. font-weight: 500;
  273. color: rgba(17, 17, 17, 1);
  274. line-height: 1.31rem;
  275. }
  276. .live-statu {
  277. height: 1.13rem;
  278. background: rgba(255, 153, 0, 1);
  279. border-radius: 0.14rem;
  280. font-size: 0.56rem;
  281. font-family: PingFangSC-Semibold, PingFang SC;
  282. font-weight: 600;
  283. color: rgba(255, 255, 255, 1);
  284. line-height: 0.81rem;
  285. padding: 0.13rem 0.18rem;
  286. margin-right: 0.63rem;
  287. }
  288. .live-statu > img {
  289. width: 0.61rem !important;
  290. height: 0.47rem;
  291. margin-right: 0.25rem;
  292. }
  293. .live-source {
  294. font-size: 0.69rem;
  295. font-family: PingFangSC-Medium, PingFang SC;
  296. font-weight: 500;
  297. color: rgba(34, 34, 34, 1);
  298. line-height: 1rem;
  299. margin-right: 0.38rem;
  300. }
  301. .live-source > img {
  302. width: 1.13rem !important;
  303. height: 1.13rem;
  304. }
  305. .live-time {
  306. font-size: 0.69rem;
  307. font-family: PingFangSC-Regular, PingFang SC;
  308. font-weight: 400;
  309. color: rgba(153, 153, 153, 1);
  310. line-height: 1rem;
  311. margin-right: 0.7rem;
  312. }
  313. .live-people {
  314. font-size: 0.69rem;
  315. font-family: PingFangSC-Medium, PingFang SC;
  316. font-weight: 500;
  317. color: rgba(51, 51, 51, 1);
  318. line-height: 1rem;
  319. margin-right: 0.3rem;
  320. }
  321. .live-bottom {
  322. margin-top: 0.44rem;
  323. position: relative;
  324. }
  325. .live .close {
  326. position: absolute;
  327. top: 1.35rem;
  328. right: 0px;
  329. width: 0.75rem !important;
  330. height: 0.75rem;
  331. }
  332. .see {
  333. width: 1rem !important;
  334. height: 1rem;
  335. margin-right: 0.13rem;
  336. }
  337. .mui-table-view > li {
  338. }
  339. .article-title {
  340. font-size: 0.94rem;
  341. font-family: PingFangSC-Regular, PingFang SC;
  342. font-weight: 400;
  343. color: rgba(17, 17, 17, 1);
  344. line-height: 1.31rem;
  345. }
  346. .article-box .justify-between {
  347. flex-direction: column;
  348. min-height: 4.5rem;
  349. }
  350. .article-img {
  351. width: 6.75rem !important;
  352. height: 5rem;
  353. border-radius: 0.13rem;
  354. object-fit: cover;
  355. }
  356. li {
  357. box-shadow: 0rem -0.03rem 0rem 0rem rgba(243, 243, 243, 1);
  358. }
  359. .mui-active .img-no {
  360. display: none;
  361. }
  362. .mui-active .img-select {
  363. display: inline-block;
  364. }
  365. .img-select {
  366. display: none;
  367. }
  368. .mui-slider-indicator.mui-segmented-control {
  369. height: 2.81rem;
  370. background: white;
  371. }
  372. .mui-segmented-control .mui-control-item {
  373. line-height: 2.81rem;
  374. }
  375. /*.mui-slider-progress-bar {
  376. width:1rem;
  377. margin-left: 5.45rem;
  378. }*/
  379. .mui-slider
  380. .mui-segmented-control.mui-segmented-control-inverted
  381. ~ .mui-slider-group
  382. .mui-slider-item {
  383. border: none;
  384. }
  385. .video2 {
  386. margin: 0.63rem;
  387. box-shadow: 0rem 0.06rem 0.24rem 0rem rgba(8, 27, 50, 0.05);
  388. border-radius: 0.08rem;
  389. overflow: hidden;
  390. }
  391. .video-box {
  392. box-shadow: 0rem 0.06rem 0.24rem 0rem rgba(8, 27, 50, 0.05);
  393. border-radius: 0.08rem;
  394. overflow: hidden;
  395. }
  396. .video-img {
  397. position: relative;
  398. width: 100%;
  399. height: 12.13rem;
  400. }
  401. .video-img .img {
  402. width: 100%;
  403. height: 100%;
  404. object-fit: cover;
  405. border-radius: 0.25rem 0.25rem 0rem 0rem;
  406. }
  407. .video-des {
  408. font-size: 0.94rem;
  409. font-family: PingFangSC-Regular, PingFang SC;
  410. color: rgba(51, 51, 51, 1);
  411. line-height: 1.31rem;
  412. margin: 0.63rem 0 0.88rem 0;
  413. }
  414. .video-detail {
  415. padding: 0.63rem 0.94rem;
  416. box-shadow: 0rem 0.19rem 0.75rem 0rem rgba(8, 27, 50, 0.05);
  417. border-radius: 0rem 0rem 0.25rem 0.25rem;
  418. }
  419. .length {
  420. position: absolute;
  421. right: 10px;
  422. bottom: 10px;
  423. line-height: 22px;
  424. background: rgba(0, 0, 0, 0.3);
  425. border-radius: 11px;
  426. border: 1px solid rgba(255, 255, 255, 0.08);
  427. padding: 0 22px;
  428. color: white;
  429. }
  430. .play {
  431. position: absolute;
  432. width: 2.88rem !important;
  433. height: 2.88rem;
  434. top: 4.6rem;
  435. left: 9.7rem;
  436. }
  437. .live-zan {
  438. margin-left: 0.75rem;
  439. }
  440. </style>