resourceRecommend.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view class="rf-category" style="position: relative;">
  3. <!--搜索导航栏-->
  4. <!--<view class="icoStyle">
  5. <view class="leftArrow" @tap="back">
  6. <u-icon name="arrow-left" color="#fff" size="36"></u-icon>
  7. </view>
  8. <rf-search-bar @search="navToSearch" icon="iconkuaijiecaidan" />
  9. </view>-->
  10. <view class="icoStyle">
  11. <view style="width:90%;height:99upx">
  12. <rf-search-bar2 @search="" icon="iconkuaijiecaidan"
  13. style="z-index: 99;" />
  14. </view>
  15. </view>
  16. <u-toast ref="uToast"/>
  17. <view style="width: 100%;">
  18. <view style="width: 100%;">
  19. <view v-for="(item,index) in recommendList" style="width: 100%;height: 280upx;margin-bottom: 20upx;padding: 30upx;background-color: white;" @click="toDetaile(item.entityId)">
  20. <view style="width: 270upx;height: 220upx;float: left;">
  21. <image v-if="item.researchResourcesMedia!='null'&&item.researchResourcesMedia!=null&&item.researchResourcesMedia!=''&&item.researchResourcesMedia!=undefined"
  22. :src="'https://www.geidcp.com//api/file/pub/'+item.researchResourcesMedia" mode="" style="width: 100%;height: 100%;"></image>
  23. <image v-else src="@/static/img/resourceSharing/lavle.png" mode="" style="width: 100%;height: 100%;"></image>
  24. </view>
  25. <view style="width: 390upx;height: 100%;float: left;margin-left: 30upx;position: relative;">
  26. <view>
  27. <text style="font-size: 30upx; color: #0B0B11;" class="twoLine">
  28. {{item.name}}
  29. </text>
  30. </view>
  31. <view>
  32. <text style="font-size: 20upx; color: #666666;" class="twoLine">
  33. {{item.affiliatedUnitName}}
  34. </text>
  35. </view>
  36. <view style="margin-top: 13upx;">
  37. <text style="font-size: 26upx; padding: 0 13upx; border: 2px solid #1777FE;
  38. display: inline-block;border-radius: 32upx;color: #1777FE;">
  39. {{item.researchResourcesType}}
  40. </text>
  41. </view>
  42. <view style="position: absolute;bottom: 0;width: 100%;height: 35upx;color: #666;">
  43. <view style="float: left;height: 100%">
  44. <text style="font-size: 28upx;">{{item.createDate}}</text>
  45. </view>
  46. <view style="float: right;">
  47. <view style="float: left;font-size: 28upx;font-weight: 400;">
  48. <u-icon name="heart" color="#848485" size="28" style="margin-right: 6upx"></u-icon>
  49. <text style="color: #666;">
  50. {{item.num=='null'?'0':item.num}}
  51. </text>
  52. </view>
  53. <!--<view style="float: left;font-size: 28upx;font-weight: 400;margin-left: 70upx;">
  54. <u-icon name="arrow-right" color="#848485" size="28" style="margin-right: 6upx"></u-icon>
  55. <text style="color: #666;">
  56. 888
  57. </text>
  58. </view>-->
  59. </view>
  60. <view style="clear: both;"></view>
  61. </view>
  62. </view>
  63. <view style="clear: both;"></view>
  64. </view>
  65. <view style="margin-top: 20rpx;">
  66. <u-loadmore :status="status" :load-text="loadText" />
  67. </view>
  68. </view>
  69. </view>
  70. <rf-back-top :scrollTop="scrollTop"></rf-back-top>
  71. </view>
  72. </template>
  73. <script>
  74. import rfSearchBar from '@/components/rf-search-bar';
  75. import rfSearchBar2 from '@/components/rf-search-bar-xiangmu';
  76. export default {
  77. data() {
  78. return {
  79. recommendList:[],
  80. pageNo:0,
  81. totalPage:1,
  82. status: 'loading',
  83. isLoading: true,
  84. loadText: {
  85. loading: this.$i18n.locale == 'zh'? '加载中': 'Loading',
  86. nomore: this.$i18n.locale == 'zh'? '没有更多数据了': 'No more'
  87. },
  88. // 字典
  89. classify1:'',
  90. classify2:'',
  91. // 返回顶部
  92. scrollTop: 0,
  93. }
  94. },
  95. components: { rfSearchBar,rfSearchBar2 },
  96. async onShow() {
  97. await this.initData();
  98. await this.getDict();
  99. await this.getRecommend();
  100. },
  101. onPageScroll(e) {
  102. this.scrollTop = e.scrollTop;
  103. },
  104. onReachBottom() { //页面拉到底部加载
  105. if(this.isLoading) {
  106. this.getRecommend();
  107. }
  108. },
  109. watch:{
  110. /* recommendList(val){
  111. this.$refs.uToast.show({
  112. title: `${this.i18n('resourceRecommended')}${this.recommendList.length}${this.i18n('resourceRecommended2')}`,
  113. position: "top",
  114. icon: false,
  115. })
  116. }, */
  117. },
  118. methods: {
  119. async initData(){
  120. this.recommendList = [];
  121. this.pageNo = 0;
  122. this.totalPage = 1;
  123. this.status = 'loading';
  124. this.isLoading = true;
  125. this.loadText = {
  126. loading: this.$i18n.locale == 'zh'? '加载中' : 'Loading',
  127. nomore: this.$i18n.locale == 'zh'? '没有更多数据了' : 'No more'
  128. };
  129. // 字典
  130. this.classify1 = '';
  131. this.classify2 = '';
  132. // 返回顶部
  133. this.scrollTop = 0;
  134. },
  135. navToSearch(){},
  136. toDetaile(entityId){
  137. this.$mRouter.push({
  138. route: `/pages/resourceSharing/resourceDetails?entityId=${entityId}`,
  139. });
  140. },
  141. async getDict(){
  142. const res = await this.$myRequest({
  143. url: '/sys/sysDicts',
  144. data: {
  145. type:this.$i18n.locale=="zh"?'RESEARCH_RESULT_TYPE_DICT,RESEARCH_RESOURCE_TYPE_DICT':'RESEARCH_RESULT_TYPE_DICT_EN,RESEARCH_RESOURCE_TYPE_DICT_EN',
  146. }
  147. });
  148. if (res.data) {
  149. let both={
  150. label:this.$t('common.All'),
  151. value:null
  152. };
  153. this.classify1=res.data[0];
  154. this.classify2=res.data[1];
  155. this.classify1.unshift(both);
  156. this.classify2.unshift(both);
  157. }
  158. },
  159. async getRecommend(){
  160. const that = this;
  161. let params = {
  162. pageNo: '',
  163. pageSize: 50,
  164. language: this.$i18n.locale.toUpperCase(),
  165. status: 0,
  166. descStatus: 0,
  167. effective:'Y',
  168. };
  169. if( this.pageNo >= this.totalPage){
  170. this.isLoading = false;
  171. this.status = 'nomore';
  172. }else{
  173. this.isLoading = true;
  174. this.pageNo++;
  175. params.pageNo = this.pageNo;
  176. const res = await this.$myRequest({
  177. url: '/resourceshare/baseResearchResourcesViews/',
  178. data: {
  179. ...params
  180. }
  181. })
  182. if (res.data) {
  183. let data = res.data.baseResearchResourcesViews;
  184. data.forEach((i) => {
  185. i.createDate = i.createDate ? this.formatDate(i.createDate, "YYYY-MM-DD") : "";
  186. if (i.researchResourcesMedia){
  187. i.researchResourcesMedia = i.researchResourcesMedia.split(',')
  188. i.researchResourcesMedia = i.researchResourcesMedia[0]
  189. }
  190. })
  191. for (let i=0;i<data.length;i++){
  192. for (let o=0;o<that.classify2.length;o++){
  193. if (data[i].researchResourcesType == that.classify2[o].value){
  194. data[i].researchResourcesType = that.classify2[o].label;
  195. }
  196. }
  197. }
  198. that.recommendList = [...that.recommendList,...data]
  199. that.totalPage = res.data.page.totalPage;
  200. if(that.totalPage == 1){
  201. this.isLoading = false;
  202. this.status = 'nomore';
  203. }
  204. }
  205. }
  206. },
  207. back() {
  208. uni.navigateBack();
  209. },
  210. //中英文切换
  211. i18n (data) {
  212. return this.$t('common.'+data);
  213. },
  214. }
  215. }
  216. </script>
  217. <style lang="scss" scoped>
  218. .rf-category {
  219. background-color: #F3F4F5;
  220. /* #ifdef APP-PLUS */
  221. margin-top: calc(20upx + var(--status-bar-height));
  222. /* #endif */
  223. .icoStyle {
  224. display: flex;
  225. .leftArrow {
  226. position: absolute;
  227. left: 4upx;
  228. top: calc(30upx + var(--status-bar-height));;
  229. z-index: 9999;
  230. }
  231. }
  232. .oneLine{
  233. /* 隐藏溢出元素 */
  234. overflow: hidden;
  235. /* 单行显示 */
  236. white-space: nowrap;
  237. /* 溢出显示省略号 */
  238. text-overflow: ellipsis;
  239. }
  240. .twoLine{
  241. overflow : hidden;
  242. text-overflow: ellipsis;
  243. display: -webkit-box;
  244. -webkit-line-clamp: 2;
  245. -webkit-box-orient: vertical;
  246. }
  247. .threeLine{
  248. overflow : hidden;
  249. text-overflow: ellipsis;
  250. display: -webkit-box;
  251. -webkit-line-clamp: 3;
  252. -webkit-box-orient: vertical;
  253. }
  254. .wrap {
  255. display: flex;
  256. flex-direction: column;
  257. height: calc(100vh - var(--window-top));
  258. width: 100%;
  259. }
  260. .swiper-box {
  261. flex: 1;
  262. }
  263. .swiper-item {
  264. height: 100%;
  265. }
  266. .item-box {
  267. margin-bottom: 50rpx;
  268. display: flex;
  269. flex-wrap: wrap;
  270. justify-content: space-between;
  271. }
  272. .item-box .item {
  273. border: 1px solid $u-type-primary;
  274. color: $u-type-primary;
  275. padding: 8rpx 40rpx;
  276. border-radius: 100rpx;
  277. margin-top: 30rpx;
  278. }
  279. .recommendScroll{
  280. overflow: hidden;
  281. white-space: nowrap; // 滚动必须加的属性
  282. width: 100%;
  283. height: 210upx;
  284. margin: 0 auto;
  285. }
  286. .recommendScroll .item{
  287. width: 400upx;
  288. height: 210upx;
  289. border: 1px solid #979797;
  290. display: inline-block;
  291. vertical-align: top;
  292. }
  293. }
  294. </style>
  295. <style>
  296. /deep/ .u-position-top{
  297. width: 70%;
  298. }
  299. </style>