index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <div>
  3. <div class="auto lists">
  4. <Row>
  5. <Col :span="15">
  6. <div class="lists-item" v-for="item in listData">
  7. <img v-lazy="picPath+item.infoimg" alt="" :key="item.infoId">
  8. <div class="content-text">
  9. <nuxt-link class="line-one" style="-webkit-box-orient: vertical;" :to="{path: '/content', query:{id:item.infoId}}" tag="a" target="_blank">{{item.title}}</nuxt-link>
  10. <p style="-webkit-box-orient: vertical;">{{item.summary}}</p>
  11. <div class="source" v-if="item.columnname?item.columnname.includes('—'):false">
  12. <nuxt-link :to="{path: '/lists', query:{id:item.parentcolumnId}}" class="line-one" style="-webkit-box-orient: vertical;" tag="a" target="_blank">{{item.columnname.split('—')[0]}}</nuxt-link>
  13. <span>—</span>
  14. <nuxt-link :to="{path: '/lists', query:{id:item.columnId}}" class="line-one" style="-webkit-box-orient: vertical;" tag="a" target="_blank">{{item.columnname.split('—')[1]}}</nuxt-link>
  15. <span>/{{item.uptimeStr}}</span>
  16. </div>
  17. <div class="source" v-else>
  18. <nuxt-link v-if="item.columnname" :to="{path: '/lists', query:{id:item.columnId}}" class="line-one" style="-webkit-box-orient: vertical;" tag="a" target="_blank">{{item.columnname}}/</nuxt-link>
  19. <span>{{item.uptimeStr}}</span>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="page-nation">
  24. <Page :total="total" size="small" show-elevator show-sizer show-total :page-size="pageNation.rows" :current="pageNation.page" @on-change="pageChange" @on-page-size-change="pageSizeChange"/>
  25. </div>
  26. </Col>
  27. <Col :span="1" style="height:100px"></Col>
  28. <Col :span="8">
  29. <div>
  30. <!-- <a v-if="imgTo" :href="imgTo">
  31. <img style="width:333px" v-lazy="'http://pic-asean2.oss-cn-hongkong.aliyuncs.com/'+imgPath" alt="">
  32. </a>
  33. <img v-else style="width:333px" v-lazy="'http://pic-asean2.oss-cn-hongkong.aliyuncs.com/'+imgPath" alt=""> -->
  34. </div>
  35. </Col>
  36. </Row>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import {getColumnInfoList,getColumnAd,search,listKeywordInfo} from '~/api/lists'
  42. import {listFocusInfo} from '~/api/homePage'
  43. import {formatTime} from '~/common/publicFun'
  44. import Bus from "~/common/bus";
  45. import { mapState } from 'vuex'
  46. export default {
  47. data(){
  48. return {
  49. picPath: 'http://pic-asean2.oss-cn-hongkong.aliyuncs.com/',
  50. suffix:'?x-oss-process=image/watermark,image_d2F0ZXJtYXJrL3dtMS5wbmc_eC1vc3MtcHJvY2Vzcz1pbWFnZS9yZXNpemUsUF8zMA==,g_se,x_10,y_10,t_70',
  51. listData:[],
  52. pageNation:{
  53. "page": 1,
  54. "rows": 20
  55. },
  56. total:0,
  57. imgPath:'',
  58. imgTo:'',
  59. id:'',
  60. fromSearch:false,
  61. // keyword:this.$store.getters.keyword,
  62. }
  63. },
  64. async asyncData ({query}) {
  65. let params={
  66. "page": 1,
  67. "rows": 20,
  68. "reqdata":{}
  69. }
  70. let fun='';
  71. if(query.id=='search'){
  72. params.reqdata.title=query.id;
  73. fun=search;
  74. }else if(['focus','recommend'].includes(query.id)){
  75. params.reqdata.type=query.id;
  76. fun=listFocusInfo;
  77. }else if(parseInt(query.id)){
  78. params.reqdata.columnId=parseInt(query.id);
  79. fun=getColumnInfoList;
  80. }else{
  81. params.reqdata.keyword=query.id;
  82. fun=listKeywordInfo;
  83. }
  84. let [dataObj,imgObj] = await Promise.all([
  85. fun(params),
  86. getColumnAd({ "reqdata": { "adPosition": "column" }})
  87. ]);
  88. let page=dataObj.currpage;
  89. return{
  90. listData:dataObj.list,
  91. total:dataObj.totalrecords,
  92. pageNation:{page},
  93. imgPath:imgObj.object?imgObj.object.adimg:'',
  94. imgTo:imgObj.object?imgObj.object.adurl:''
  95. }
  96. },
  97. mounted(){
  98. this.id=this.$route.query.id;
  99. console.log(this.id,'this.id')
  100. // this.getData();
  101. Bus.$emit("columnId", this.id);
  102. },
  103. computed:{
  104. searchVal:function() { //通过方法访问
  105. return this.$store.getters.searchVal;
  106. },
  107. // keyword:function() { //关键字
  108. // return this.$store.getters.keyword;
  109. // },
  110. },
  111. watch:{
  112. // $route(){
  113. // if(['focus','recommend'].includes(this.$route.params.id)){
  114. // this.id = this.$route.params.id
  115. // }else{
  116. // this.id = this.$route.params.id
  117. // }
  118. // },
  119. // searchVal(){
  120. // this.fromSearch=true;
  121. // this.getData()
  122. // },
  123. // keyword(){
  124. // this.fromSearch=false;
  125. // this.id = this.keyword
  126. // this.getData()
  127. // },
  128. // id() {
  129. // this.fromSearch=false;
  130. // this.getData()
  131. // },
  132. },
  133. methods:{
  134. getData(){
  135. let params={
  136. "page": this.pageNation.page,
  137. "rows": this.pageNation.rows,
  138. "reqdata":{}
  139. }
  140. if(this.fromSearch){
  141. params.reqdata.title=this.searchVal
  142. search(params).then(res=>{
  143. if(res.status==100){
  144. this.listData=res.list;
  145. this.total=res.totalrecords
  146. this.pageNation.page=res.currpage;
  147. }
  148. })
  149. }else if(['focus','recommend'].includes(this.id)){
  150. params.reqdata.type=this.id
  151. listFocusInfo(params).then(res=>{
  152. if(res.status==100){
  153. this.listData=res.list;
  154. this.total=res.totalrecords
  155. this.pageNation.page=res.currpage;
  156. }
  157. });
  158. }else if(parseInt(this.id)){
  159. params.reqdata.columnId=parseInt(this.id)
  160. getColumnInfoList(params).then(res=>{
  161. if(res.status==100){
  162. this.listData=res.list;
  163. this.total=res.totalrecords
  164. this.pageNation.page=res.currpage;
  165. }
  166. });
  167. }else{
  168. params.reqdata.keyword=this.id;
  169. listKeywordInfo(params).then(res=>{
  170. if(res.status==100){
  171. this.listData=res.list;
  172. this.total=res.totalrecords
  173. this.pageNation.page=res.currpage;
  174. }
  175. })
  176. }
  177. },
  178. pageChange(page){
  179. this.pageNation.page=page;
  180. this.getData();
  181. },
  182. pageSizeChange(pageSize){
  183. this.pageNation.rows=pageSize;
  184. this.getData();
  185. },
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .lists{
  191. padding-top: 15px;
  192. margin-bottom: 123px;
  193. .lists-item{
  194. display: inline-flex;
  195. padding: 19px 0;
  196. border-bottom: 1px solid #ccc;
  197. width: 100%;
  198. img{
  199. width: 35%;
  200. height: 150px;
  201. border-radius: 10px;
  202. margin-right: 10px;
  203. }
  204. .content-text{
  205. position: relative;
  206. margin-left: 10px;
  207. width: 62%;
  208. a{
  209. font-size: 20px;
  210. float: left;
  211. width: 100%;
  212. margin-bottom:4px;
  213. }
  214. p{
  215. font-size: 14px;
  216. margin: 0 0 10px 0;
  217. color: #aaaaaa;
  218. width: 100%;
  219. height: 95px;
  220. overflow: hidden;
  221. text-overflow: ellipsis;
  222. display: -webkit-box;
  223. -webkit-line-clamp: 4;
  224. }
  225. span{
  226. float: left;
  227. font-size: 12px;
  228. margin-top: 15px;
  229. }
  230. .source{
  231. position: absolute;
  232. bottom: 0px;
  233. left: 0px;
  234. width: 100%;
  235. a{
  236. font-size: 13px;
  237. width: auto;
  238. color: #515a6e;
  239. margin: auto;
  240. }
  241. span{
  242. float: left;
  243. font-size: 12px;
  244. margin: auto;
  245. }
  246. }
  247. }
  248. }
  249. .page-nation{
  250. height: 50px;
  251. line-height: 50px;
  252. input{
  253. height: 2px;
  254. }
  255. }
  256. }
  257. </style>