list.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="">
  3. <view class="head">
  4. <u-navbar bgColor="transparent" leftIconColor="#fff" :titleStyle="{color:'#fff'}" :fixed="false" leftIconSize="48" :autoBack="true">
  5. <view slot="center" class="navbar-center">
  6. <!-- lineWidth="124" -->
  7. <u-tabs
  8. :list="tabList"
  9. :current="current"
  10. lineWidth="126rpx"
  11. @click="changeTab"
  12. lineHeight="2"
  13. lineColor="#DC3C23"
  14. :scrollable="false"
  15. :activeStyle="{color:'#DC3C23',fontSize:'34rpx'}"
  16. :inactiveStyle="{color:'#fff',fontSize:'34rpx'}
  17. "></u-tabs>
  18. </view>
  19. </u-navbar>
  20. </view>
  21. <!-- 社区 -->
  22. <view class="" v-show="current == 0">
  23. <!-- :style="{marginTop:show1?'204rpx':'100rpx'}" -->
  24. <view class="topic-list">
  25. <view class="list-li flex" v-for="(item,index) in Headlist.data" :key="index"
  26. @click="$toUrl('./news-detail?id=' + item.circle_id)">
  27. <view class="list-li-left flex-wrap">
  28. <view class="list-li-left-nav text-clamp2">{{item.title}}</view>
  29. <view class="list-li-left-bot flex-start">
  30. <!-- <text :style="{color:index == 0?'#CC374A':'#999'}">置顶</text> -->
  31. <view class="flex">
  32. <image src="/static/image/news/topic11.png" mode="aspectFill"></image>
  33. <text>{{item.comment_count}}</text>
  34. </view>
  35. </view>
  36. </view>
  37. <u--image :showLoading="true" class="list-li-logo" radius="12" :src="item.img" width="240rpx" height="136rpx" @click="click"></u--image>
  38. <!-- <image class="list-li-logo" :src="item.img ?item.img:require('../../static/image/common/none-img.png')" mode="aspectFill"></image> -->
  39. </view>
  40. </view>
  41. </view>
  42. <!-- 圈子 -->
  43. <view class="Community" v-if="current == 1">
  44. <view class="u-demo-block__content">
  45. <view class="album" @click="$toUrl('./community-detail?id=' + item.circle_id)" v-for="(item,index) in luntanList.data" :key="index">
  46. <view class="album_top flex-start">
  47. <image class="logo" :src="item.avatar" mode=""></image>
  48. <view class="">
  49. <u--text :text="item.user_nickname" bold size="32"></u--text>
  50. <u--text margin="6px 0 0 0" color="#999" :text="item.addtime"></u--text>
  51. </view>
  52. </view>
  53. <mote-lines-divide :line="3" @click.stop="" :expandText="$t('news.full')" :foldHint="$t('news.collapsed')">
  54. {{item.title}}
  55. </mote-lines-divide>
  56. <view class="album__content">
  57. <u-album multipleSize="200" space="16" :urls="item.img"></u-album>
  58. </view>
  59. <view class="flex tabbar">
  60. <view class="">
  61. <image src="/static/image/news/topic2.png" mode=""></image>
  62. <u--text color="#999" size="24" :text="item.favorites"></u--text>
  63. </view>
  64. <view class="">
  65. <image src="/static/image/news/topic7.png" mode=""></image>
  66. <u--text color="#999" size="24" :text="item.comment"></u--text>
  67. </view>
  68. <view class="">
  69. <image src="/static/image/news/topic6.png" mode=""></image>
  70. <u--text color="#999" size="24" :text="item.click"></u--text>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <u-empty
  77. v-if="luntanList.data && luntanList.data.length == 0"
  78. mode="data"
  79. width="474"
  80. height="312"
  81. textSize="28"
  82. marginTop="100"
  83. :text="$t('common.nodata')"
  84. icon="/static/image/common/nodata.png"
  85. >
  86. </u-empty>
  87. </view>
  88. </template>
  89. <script>
  90. import MoteLinesDivide from "@/components/mote-lines-divide/mote-lines-divide"
  91. export default {
  92. components: {
  93. MoteLinesDivide
  94. },
  95. data() {
  96. return {
  97. current:0,
  98. Headlist:{
  99. data:[]
  100. },
  101. page:1,
  102. luntanList:{
  103. data:[]
  104. },
  105. }
  106. },
  107. computed:{
  108. tabList() {
  109. let arr = [
  110. {
  111. name: this.$t('news.tab1'),
  112. },
  113. {
  114. name: this.$t('news.posts'),
  115. },
  116. ]
  117. return arr
  118. },
  119. info() {
  120. return this.$store.state.info
  121. },
  122. isLogin() {
  123. return this.$store.state.isLogin
  124. }
  125. },
  126. onLoad(option) {
  127. this.current = option.type;
  128. if(this.current == 0) {
  129. this.getHeadlines()
  130. }else {
  131. this.getLuntan()
  132. }
  133. },
  134. onReachBottom() { //触底加载
  135. if(this.current == 0) {
  136. if (JSON.stringify(this.HeadlinesList) == '{}') return
  137. if (this.status == 'more') {
  138. this.getHeadlines()
  139. }
  140. }else {
  141. if (this.status == 'more') {
  142. this.getLuntan()
  143. }
  144. }
  145. },
  146. methods:{
  147. changeTab(e) {
  148. this.current = e.index;
  149. this.page = 1;
  150. this.status = 'more';
  151. if(this.current == 0) {
  152. this.getHeadlines()
  153. }else {
  154. this.getLuntan()
  155. }
  156. },
  157. /* 收藏的列表 */
  158. getHeadlines() {
  159. this.status = 'loading';
  160. let uid = '';
  161. if(this.isLogin == 1) {
  162. uid = this.info.id
  163. }
  164. uni.$u.http.get('/api/Headlines_user/logList', {
  165. params:{page: this.page,type:1,uid:uid}
  166. }).then(res => {
  167. // this.$db.set('system'.res.data)
  168. this.HeadlinesList = res;
  169. if(this.page == 1) {
  170. this.Headlist.data = res.data
  171. }else {
  172. this.Headlist.data = [...this.data, ...res.data]
  173. }
  174. if (res.total > this.Headlist.data.length) {
  175. this.page++
  176. this.status = 'more'
  177. }else {
  178. this.status = 'nomore'
  179. }
  180. })
  181. },
  182. //
  183. getLuntan() {
  184. this.status = 'loading';
  185. let uid = '';
  186. if(this.isLogin == 1) {
  187. uid = this.info.id
  188. }
  189. uni.$u.http.get('/api/Circleuser/logList', {
  190. params:{page: this.page,type:1,uid:uid}
  191. }).then(res => {
  192. console.log(res);
  193. if(this.page == 1) {
  194. this.luntanList.data = res.data
  195. }else {
  196. this.luntanList.data = [...this.data, ...res.data]
  197. }
  198. if (res.total > this.luntanList.data.length) {
  199. this.page++
  200. this.status = 'more'
  201. }else {
  202. this.status = 'nomore'
  203. }
  204. })
  205. },
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. .head {
  211. position: sticky;
  212. top: 0;
  213. z-index: 99;
  214. background-color: $color1;
  215. }
  216. .topic-list {
  217. margin: 0 24rpx;
  218. padding: 0 24rpx;
  219. border-radius: 12rpx;
  220. background-color: white;
  221. .list-li {
  222. padding: 32rpx 0;
  223. border-bottom: 2rpx solid #F0F0F0;
  224. }
  225. .list-li-logo {
  226. width: 242rpx;
  227. height: 136rpx;
  228. margin-left: 32rpx;
  229. border-radius: 12rpx;
  230. }
  231. .list-li-left {
  232. flex: 1;
  233. display: flex;
  234. flex-wrap: wrap;
  235. height: 136rpx;
  236. image {
  237. width: 28rpx;
  238. height: 24rpx;
  239. margin-right: 8rpx;
  240. }
  241. .list-li-left-nav {
  242. color: #333;
  243. font-size: 32rpx;
  244. align-self: flex-start;
  245. }
  246. }
  247. .list-li-left-bot {
  248. width: 100%;
  249. font-size: 24rpx;
  250. align-self: flex-end;
  251. text {
  252. color: #CC374A;
  253. margin-right: 32rpx;
  254. }
  255. view {
  256. text {
  257. color: #999;
  258. }
  259. }
  260. }
  261. }
  262. .album {
  263. margin-top: 20rpx;
  264. padding: 32rpx 24rpx;
  265. border-radius: 12rpx;
  266. background-color: white;
  267. .logo {
  268. width: 72rpx;
  269. height: 72rpx;
  270. border-radius: 50%;
  271. margin-right: 16rpx;
  272. }
  273. .nav {
  274. padding-top: 20rpx;
  275. }
  276. .album__content {
  277. margin-top: 30rpx;
  278. image {
  279. border-radius: 10rpx;
  280. }
  281. }
  282. .tabbar {
  283. margin-top: 22rpx;
  284. padding: 0 22rpx;
  285. image {
  286. width: 48rpx;
  287. height: 48rpx;
  288. }
  289. view {
  290. display: flex;
  291. align-items: center;
  292. justify-content: flex-start;
  293. }
  294. }
  295. }
  296. </style>