news.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <view id="index">
  3. <view class="malNotBox">
  4. <view class="notList dfsb">
  5. <view class="gogo">
  6. <view v-for="(val, index) in headList" :key="index" @tap="goList(val.id)" :class="[headSel == val.id ? 'select' : '', 'headli']">{{ val.name }}</view>
  7. </view>
  8. <view class="selmore"><uicon color="#666" size="12" @tap="showSel = !showSel" :type="!showSel ? 'iconzixunfenleix' : 'iconzixunshouqix'"></uicon></view>
  9. </view>
  10. <view v-if="showSel" class="selLists">
  11. <view @tap="goList(item.id)" :class="['selList', headSel == item.id ? 'selbtn' : '']" v-for="(item, index) in headList" :key="index">{{ item.name }}</view>
  12. <view @tap="showSel = false" class="btn">关闭</view>
  13. </view>
  14. </view>
  15. <view class="notCon">
  16. <newsBox :newsInfo="pageList"></newsBox>
  17. <view class="nodata" v-if="pageList.length < 1"><u-empty icon-size="200" text="还没有新闻哦" mode="news"></u-empty></view>
  18. <view class="moredata" v-if="pageList.length > 0"><u-loadmore bg-color="#fff" :status="status" /></view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import newsBox from 'components/ycommon/newsPage.vue';
  24. export default {
  25. components: {
  26. newsBox
  27. },
  28. data() {
  29. return {
  30. showSel: false, //展示更多选择
  31. headSel: 0, //tab选择项
  32. headList: [],
  33. pageList: [
  34. // {
  35. // title: '测试标题要长一点哦再来点 随便写点吧',
  36. // name: '我哦',
  37. // hits: 456,
  38. // img: '../../static/images/common/buy-z.png'
  39. // }
  40. ],
  41. banner: '',
  42. page: 1,
  43. pagenum:6,
  44. status: 'loadmore'
  45. };
  46. },
  47. onShow() {
  48. this.page = 1;
  49. this.pageList = [];
  50. this.getCat();
  51. },
  52. onReachBottom() {
  53. if (this.status == 'nomore') return;
  54. this.status = 'loadmore';
  55. this.page = ++this.page;
  56. this.loading();
  57. },
  58. methods: {
  59. //小说 跳转
  60. toLink(id) {
  61. uni.navigateTo({
  62. url: './newsInfo?flag=2&id=' + id
  63. });
  64. },
  65. getCat(){
  66. this.$api
  67. .request('index/getNewsCate', {
  68. },'get')
  69. .then(data => {
  70. console.log(data);
  71. if (data.code == '200') {
  72. this.headList = data.data;
  73. this.headSel=data.data[0].id
  74. this.loading();
  75. } else {
  76. this.$api.toast(data.msg);
  77. }
  78. })
  79. .catch(function(error) {
  80. console.log(error);
  81. });
  82. },
  83. loading() {
  84. this.$api
  85. .request('news/getNews', {
  86. nc_id: this.headSel,
  87. page: this.page,
  88. limit: this.pagenum,
  89. },'get')
  90. .then(data => {
  91. console.log(data);
  92. if (data.code == '200') {
  93. this.pageList = this.pageList.concat(data.data.list);
  94. // 数据全部加载完成
  95. if (data.data.list.length < this.pagenum) {
  96. this.status = 'nomore'
  97. }
  98. } else {
  99. this.$api.toast(data.msg);
  100. }
  101. })
  102. .catch(function(error) {
  103. console.log(error);
  104. });
  105. },
  106. //子分类下
  107. goList(id) {
  108. this.headSel = id;
  109. this.showSel = false;
  110. this.page = 1;
  111. this.pageList = [];
  112. this.loading();
  113. }
  114. }
  115. };
  116. </script>
  117. <style lang="scss" scoped>
  118. #index {
  119. padding-top: 80rpx;
  120. min-height: 100vh;
  121. background-color: #fff;
  122. .malNotBox {
  123. background-color: #fff;
  124. position: fixed;
  125. top: 0;
  126. //#ifdef H5
  127. top: 44px;
  128. //#endif
  129. left: 0;
  130. width: 100%;
  131. z-index: 80;
  132. .notList {
  133. width: 100%;
  134. padding: 0 30rpx;
  135. border-bottom: 1rpx solid #eee;
  136. .selmore {
  137. height: 60rpx;
  138. padding-left: 20rpx;
  139. }
  140. .gogo {
  141. flex: 1;
  142. white-space: nowrap; /*文本不会换行,文本会在在同一行上继续*/
  143. display: -webkit-box;
  144. overflow-x: auto;
  145. /*适应苹果*/
  146. -webkit-overflow-scrolling: touch;
  147. //父盒子隐藏滚动条
  148. &::-webkit-scrollbar {
  149. display: none;
  150. }
  151. .headli {
  152. font-family: PingFangSC-Medium;
  153. height: 60rpx;
  154. font-size: 28rpx;
  155. text-align: center;
  156. margin-right: 60rpx;
  157. color: #666;
  158. }
  159. .select {
  160. border-radius: 4rpx;
  161. font-size: 32rpx;
  162. color: #ae7a58;
  163. border-bottom: 3px solid #ae7a58;
  164. font-family: PingFangSC-Semibold, PingFang SC;
  165. font-weight: 500;
  166. }
  167. }
  168. }
  169. .selLists {
  170. position: relative;
  171. padding: 42rpx 40rpx 400rpx;
  172. width: 100%;
  173. height: 100vh;
  174. background-color: #fff;
  175. overflow: scroll;
  176. // box-shadow: 0rpx 2rpx 0rpx 2rpx rgba(0, 0, 0, 0.1);
  177. .selList {
  178. float: left;
  179. min-width: 112rpx;
  180. padding: 0 30rpx;
  181. margin: 0 20rpx 40rpx;
  182. line-height: 50rpx;
  183. border-radius: 32rpx;
  184. text-align: center;
  185. font-size: 28rpx;
  186. border: 1px solid $prosecond;
  187. color: $prosecond;
  188. }
  189. .selbtn {
  190. background-color: $prosecond;
  191. color: #fff;
  192. }
  193. .btn {
  194. position: fixed;
  195. bottom: 110rpx;
  196. left: 50%;
  197. margin-left: -348rpx;
  198. width: 690rpx;
  199. text-align: center;
  200. height: 88rpx;
  201. line-height: 88rpx;
  202. border-radius: 44rpx;
  203. border: 1rpx solid $prosecond;
  204. font-size: 36rpx;
  205. color: $prosecond;
  206. background-color: #fff;
  207. }
  208. }
  209. }
  210. //#ifndef H5
  211. .malNotBox {
  212. top: 0rpx;
  213. .selLists {
  214. padding: 42rpx 40rpx 200rpx;
  215. }
  216. .btn {
  217. position: fixed;
  218. bottom: 10rpx;
  219. }
  220. .selmore {
  221. // position: fixed;
  222. // top: 12rpx;
  223. }
  224. }
  225. //#endif
  226. .notBgc {
  227. margin: 0 auto;
  228. width: 690rpx;
  229. height: 314rpx;
  230. img {
  231. width: 100%;
  232. height: 100%;
  233. }
  234. }
  235. .notCon {
  236. position: relative;
  237. top: 0rpx;
  238. margin: 0rpx 30rpx 0rpx;
  239. z-index: 69;
  240. background-color: #fff;
  241. border-radius: 30rpx 30rpx 0 0;
  242. .van-cell {
  243. padding: 0;
  244. }
  245. .notConPic {
  246. height: 314rpx;
  247. width: 100%;
  248. background-color: #f5f5f5;
  249. border-radius: 30rpx;
  250. }
  251. .van-swipe {
  252. height: 314rpx;
  253. width: 100%;
  254. background-color: #f5f5f5;
  255. border-radius: 16rpx;
  256. img {
  257. width: 100%;
  258. height: 100%;
  259. }
  260. }
  261. .notConArt {
  262. border-bottom: 1px solid #ececec;
  263. padding: 32rpx 0;
  264. .artTit {
  265. width: 432rpx;
  266. .elli {
  267. width: 432rpx;
  268. font-size: 32rpx;
  269. font-weight: 400;
  270. height: 88rpx;
  271. line-height: 44rpx;
  272. text-overflow: -o-ellipsis-lastline;
  273. overflow: hidden;
  274. text-overflow: ellipsis;
  275. display: -webkit-box;
  276. -webkit-line-clamp: 2;
  277. line-clamp: 2;
  278. -webkit-box-orient: vertical;
  279. margin-bottom: 20rpx;
  280. }
  281. .user {
  282. .graytext {
  283. line-height: 40rpx;
  284. }
  285. image {
  286. width: 25rpx;
  287. height: 20rpx;
  288. margin: 0 10rpx 0 30rpx;
  289. }
  290. }
  291. }
  292. .artImg {
  293. width: 228rpx;
  294. height: 148rpx;
  295. border-radius: 16rpx;
  296. background-color: #e5e5e5;
  297. }
  298. }
  299. }
  300. .dataok {
  301. margin-top: 40rpx;
  302. }
  303. }
  304. </style>