search.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view>
  3. <u-navbar :back-text="i18n('Back')" :back-text-style="backStyle"
  4. back-icon-color="#fff" title-color="#fff"
  5. :title="i18n('SearchResults')"
  6. :background="background">
  7. </u-navbar>
  8. <view class="" style="margin: 20upx 50upx;position: relative;">
  9. <u-input v-model="keyword" type="text" :border="true" />
  10. <u-button type="primary" style="padding: 0 20upx; height: 100%;position: absolute;right: 0;top: 0;"
  11. @click="keywordChange"
  12. >{{i18n('Search')}}
  13. </u-button>
  14. </view>
  15. <u-tabs :list="list" :is-scroll="true" :current="current" @change="tabChange"></u-tabs>
  16. <view style="min-height:200upx">
  17. <u-gap height="20" bg-color="#f3f4f5"></u-gap>
  18. <view class="cursor" v-for="(item,index) in initData" @click="toViewNew(item)"
  19. style="padding:30upx 20upx 0upx 20upx;" >
  20. <view class="div1">
  21. <u-tag :text="item.type=='meeting'?i18n('Conference'):
  22. item.type=='project'?i18n('Project'):
  23. item.type=='unit'?i18n('Enterprise'):
  24. item.type=='information'?i18n('News'):
  25. item.type=='activity'?i18n('Activity'):
  26. item.type=='country'?i18n('Country'):''" type="primary" />
  27. <text style="font-weight: 700;font-size: 34upx;margin-left: 15upx;" v-html="item.title"></text>
  28. </view>
  29. <view class="div2">
  30. <text v-html="item.content"
  31. class="plate"
  32. style="line-height: 60upx;color: #333;font-size: 28upx;
  33. -webkit-box-orient: vertical;
  34. position:relative;
  35. overflow: hidden;
  36. display: inline-block;
  37. max-height:180upx;overflow: hidden;"></text></view>
  38. <view class="div3" style="margin-bottom: 30upx;">{{i18n('LatestUpdateTime')}}: {{formatDate(item.update_date)}}</view>
  39. <u-gap height="20" bg-color="#f3f4f5"></u-gap>
  40. </view>
  41. </view>
  42. <u-loadmore :status="status" />
  43. <rf-back-top :scrollTop="scrollTop"></rf-back-top>
  44. </view>
  45. </template>
  46. <script>
  47. export default {
  48. data() {
  49. return {
  50. keyword:'',
  51. background:{
  52. backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
  53. },
  54. backStyle:{
  55. color:'#fff'
  56. },
  57. scrollTop: 0,
  58. list: [{
  59. name: this.i18n('All'),
  60. value:'all',
  61. }, {
  62. name: this.i18n('Project'),
  63. value:'project'
  64. }, {
  65. name: this.i18n('Enterprise'),
  66. value:'unit'
  67. }, {
  68. name: this.i18n('News'),
  69. value:'information'
  70. }, {
  71. name: this.i18n('Events'),
  72. value:'activity'
  73. }, {
  74. name: this.i18n('Conference'),
  75. value:'meeting',
  76. }, {
  77. name: this.i18n('Country'),
  78. value:'country'
  79. }],
  80. current:0,
  81. initData: [],
  82. activeId:'project,unit,information,activity,meeting,country',
  83. page: 1,
  84. total2:0,
  85. status:'loadmore'
  86. }
  87. },
  88. onShow(){
  89. this.getData(this.page);
  90. },
  91. onPageScroll(e) {
  92. this.scrollTop = e.scrollTop;
  93. },
  94. onReachBottom() {
  95. if(this.page*10 >= this.total2) return ;
  96. this.status = 'loading';
  97. this.page = this.page+1;
  98. if((this.page-1 )*10 >= this.total2){
  99. this.status = 'nomore';
  100. } else{
  101. this.status = 'loading';
  102. this.getData(this.page);
  103. }
  104. },
  105. methods: {
  106. async getData(page){
  107. let indexName = this.activeId;
  108. let search = '/search/' + indexName + '/search'
  109. const res = await this.$myRequest({
  110. url: search,
  111. data: {
  112. pageNo: page,
  113. keyword:this.keyword,
  114. pageSize: 10,
  115. language: this.$i18n.locale
  116. }
  117. });
  118. if(this.page==1){
  119. this.initData = res.data.list;
  120. }else {
  121. this.initData=this.initData.concat(res.data.list)
  122. }
  123. this.total2 = res.data.totalCount;
  124. if(this.total2<4){
  125. this.status = 'nomore';
  126. }
  127. },
  128. i18n (data) {
  129. return this.$t('common.'+data);
  130. },
  131. tabChange(index){
  132. this.current = index;
  133. this.activeId = this.list[index].value;
  134. this.page = 1;
  135. this.getData(this.page );
  136. },
  137. keywordChange(){
  138. this.page =1;
  139. this.getData();
  140. },
  141. toViewNew(item){
  142. let router =null;
  143. switch (item.type) {
  144. case 'meeting':
  145. // 会议
  146. router = '/pages/conference/meetingIndexCh/meetingOver?id=' + item.id;
  147. break;
  148. case 'project':
  149. // 项目
  150. router = '/pages/country/projectPresentation/projectPresentationDetails?id=' + item.base_entity_id;
  151. break;
  152. case 'unit':
  153. // 企业
  154. router = '/pages/country/enterprise/enterpriseDetail?baseEntityId=' + item.base_entity_id;
  155. break;
  156. case 'information':
  157. // 资讯
  158. router = '/pages/information/components/rankDetail?key=' + item.base_entity_id;
  159. break;
  160. case 'activity':
  161. // 活动
  162. router = '/pages/cooperationExchange/cooperationExchangeList/activitiesInfo?ActivitesId=' + item.base_entity_id;
  163. break;
  164. case 'country':
  165. // 国别
  166. router = '/pages/country/countryList/countryDetail?baseEntityId=' + item.base_entity_id;
  167. break;
  168. }
  169. uni.navigateTo({
  170. url: router,
  171. });
  172. },
  173. },
  174. onLoad(options){
  175. this.keyword = options.keyword;
  176. }
  177. }
  178. </script>
  179. <style>
  180. page {
  181. background-color: #fff;
  182. }
  183. .cursor:active {
  184. background-color: #f1f2f3;
  185. }
  186. </style>