myfollow.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <view class="myFollw">
  3. <view class="bg"></view>
  4. <u-navbar :back-icon-color="'#fff'" :is-back="true" :border-bottom="true" :back-text="$t('common.Back')"
  5. :background="{background:'#1777FE'}" :back-text-style="{color:'#fff'}" :custom-back="back" :title="title"
  6. title-color="#fff">
  7. <!-- <view slot="right" class="edit" @click="editMyFollow(menuIndex)">编辑</view> 后期可能会用-->
  8. </u-navbar>
  9. <view class="menus" v-if="menuList.length>0">
  10. <u-tabs-swiper ref="uTabs" :list="menuList" :current="current" @change="tabsChange" :is-scroll="true"
  11. :bar-height="2" :bar-width="60" swiperWidth="750">
  12. </u-tabs-swiper>
  13. </view>
  14. <view class="followList" v-if="followList.length>0">
  15. <swiper :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
  16. <swiper-item class="swiper-item" v-for="(pageitem, pageidex) in followList" :key="pageidex">
  17. <scroll-view scroll-y style="height:100%;width:100%;background:#fafafa"
  18. @scrolltolower="onreachBottom">
  19. <view class="page" v-for="(item, index) in pageitem.list" :key="index">
  20. <view class="item" @click="showDetial(item,modelType)" v-if="item.followName!='已删除'">
  21. <view class="thumb">
  22. <image class="ui-img" :src="item.bannerImg" @error="showErrorImg(item)"></image>
  23. </view>
  24. <view class="info">
  25. <view class="label">{{item.followName}}</view>
  26. <view class="other date" v-if="swiperCurrent==0">
  27. <!--项目-->
  28. <text
  29. style="margin-right:20upx;color:#aaa;font-size:20upx">{{$t('common.FollowDate')}}</text>
  30. <text
  31. style="color:#aaa;font-size:20upx">{{formatDate(item.followSetUpDate)}}</text>
  32. </view>
  33. <view class="other qiye" v-if="swiperCurrent==1">
  34. <text
  35. style="margin-right:20upx;color:#aaa;font-size:20upx">{{item.followUnitCountry}}</text>
  36. <text style="color:#aaa;font-size:20upx">{{item.unitLabel}}</text>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="nodata" v-if="!showLoading && followList[swiperCurrent].list.length==0"
  42. style="text-align: center;margin-top: 120upx;">
  43. <view class="imgBox" style="height:400upx;margin-bottom:60upx">
  44. <image src="../../../static/img/public/7.png" style="width: 80%;margin:10%"
  45. mode="widthFix"></image>
  46. <text style="font-size:28upx;color:#ccc">{{$t('common.Nodata')}}</text>
  47. </view>
  48. </view>
  49. </scroll-view>
  50. </swiper-item>
  51. </swiper>
  52. </view>
  53. <!-- 页面优化提示 -->
  54. <view class="loading" v-if="showLoading" :class="{fixbottom:true}">
  55. <u-loadmore :status="status" iconType="flower" :load-text="{loading: $t('Loading')}" />
  56. </view>
  57. <u-toast ref="uToast" />
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. getFollowModelNumByUser,
  63. saveFollowModel
  64. } from '@/api/operation/basePortalModelFollowInfo'
  65. import {
  66. getPortalMyFollowMode
  67. } from '@/api/userCenter/myFollow'
  68. import UNavbar from '@/components/uni-nav-bar/uni-nav-bar.vue'
  69. export default {
  70. name: 'MyFollow',
  71. components: {
  72. UNavbar,
  73. },
  74. data() {
  75. return {
  76. defaultImgPath: 'https://m.geidcp.com/api/file/pub/',
  77. title: '',
  78. current: 0,
  79. swiperCurrent: 0,
  80. flag: false,
  81. pageNo: 1,
  82. totalPage: 0,
  83. pageSize: 10,
  84. modelType: '',
  85. menuList: [],
  86. followList: [],
  87. showLoading: true,
  88. status: 'loading',
  89. token: '',
  90. userId: '',
  91. }
  92. },
  93. onLoad(e) {
  94. this.title = this.$i18n.locale == 'zh' ? '我的关注' : 'My Attention';
  95. },
  96. created() {
  97. this.getFollowModelNumByUser();
  98. },
  99. onShow() {
  100. this.token = uni.getStorageSync('Auth-Token') ? 'Bearer ' + uni.getStorageSync('Auth-Token') : '';
  101. this.userId = uni.getStorageSync('user') ? JSON.parse(uni.getStorageSync('user')).id : '';
  102. // if(!this.token){
  103. // uni.navigateTo({url:'/pages/public/login?back=1'})
  104. // }else{
  105. // }
  106. },
  107. methods: {
  108. // 获取选项卡标题与默认项的数据列表
  109. async getFollowModelNumByUser() {
  110. let res = await this.$myRequest({
  111. url: '/op/basePortalModelFollowInfos/followModelNumByUser',
  112. data: {
  113. language: this.$i18n.locale.toUpperCase()
  114. }
  115. })
  116. if (res.status != 200) {
  117. this.showLoading = false;
  118. this.menuList = [];
  119. this.followList[0] = {
  120. list: []
  121. }
  122. } else {
  123. if (res.data.modelTypeMap.length > 0) {
  124. for (let i = 0; i < res.data.modelTypeMap.length; i++) {
  125. this.$set(res.data.modelTypeMap[i], 'name', res.data.modelTypeMap[i]['modelName']);
  126. this.followList[i] = {
  127. list: []
  128. }
  129. }
  130. this.menuList = res.data.modelTypeMap;
  131. this.modelType = res.data.modelTypeMap[0].modelType;
  132. this.getPortalMyFollowModel(0);
  133. }
  134. }
  135. },
  136. // 获取不同项目的数据列表
  137. async getPortalMyFollowModel(index, loadmore) {
  138. let data = {
  139. pageNo: this.pageNo,
  140. pageSize: this.pageSize,
  141. modelType: this.modelType,
  142. language: this.$i18n.locale.toUpperCase()
  143. }
  144. let res = await this.$myRequest({
  145. url: '/op/basePortalModelFollowInfos/getPortalMyFollowModel',
  146. headers: {
  147. token: this.token
  148. },
  149. data
  150. })
  151. this.showLoading = false;
  152. if (res.data.models) {
  153. this.totalPage = res.data.page.totalPage ? parseInt(res.data.page.totalPage) : 0;
  154. for (let i = 0; i < res.data.models.length; i++) {
  155. if (Array.isArray(res.data.models[i].bannerImg) && res.data.models[i].bannerImg.length > 0) {
  156. if (res.data.models[i].bannerImg[0] == "") {
  157. this.$set(res.data.models[i], 'bannerImg',
  158. 'https://m.geidcp.com/api/file/pub//def/projectdefault.png');
  159. } else {
  160. this.$set(res.data.models[i], 'bannerImg', this.defaultImgPath + res.data.models[i][
  161. 'bannerImg'
  162. ][0]);
  163. }
  164. } else this.$set(res.data.models[i], 'bannerImg', this.defaultImgPath + res.data.models[i]
  165. .bannerImg);
  166. }
  167. if (!loadmore) this.followList[index].list = res.data.models; // 不需要加载更多
  168. else this.followList[index].list = [...this.followList[index].list, ...res.data
  169. .models
  170. ]; // 加载更多
  171. }
  172. },
  173. //路由后退一步
  174. back() {
  175. // #ifdef H5
  176. history.back()
  177. // #endif
  178. // #ifndef H5
  179. uni.navigateBack()
  180. // #endif
  181. },
  182. // 查看项目详情
  183. showDetial(item, modelType) {
  184. let url;
  185. console.log(item)
  186. switch (modelType) {
  187. case "project": //项目
  188. url = "/pages/country/projectPresentation/projectPresentationDetails?id=" + item.id
  189. break;
  190. case "enterprise": // 企业
  191. url = "/pages/country/enterprise/enterpriseDetail?baseEntityId=" + item.id
  192. break;
  193. case "meeting": // 会议
  194. url = ""
  195. break;
  196. case "country": // 国别
  197. url = '/pages/country/countryList/countryDetail?baseEntityId=' + item.id;
  198. break;
  199. case "activity": // 活动
  200. url =
  201. "/pages/cooperationExchange/cooperationExchangeList/activitiesInfo?ActivitesId=" +
  202. item.id
  203. break;
  204. case "exhibition": // 会展
  205. url = '';
  206. break;
  207. case "researchResources": // 调研资源
  208. url = "/pages/resourceSharing/resourceDetails?entityId=" + item.entityId;
  209. break;
  210. case "investmentGuidelines": //投资指引
  211. url = '/pages/financialService/investmentGuide/guideDetial?id=' + item.id;
  212. break;
  213. case "researchResult": // 研究成果
  214. url = "/pages/resourceSharing/resultDetails?entityId=" + item.entityId;
  215. break;
  216. case "financialInstitution": //金融机构
  217. url = '/pages/financialService/financialOrgans/organsDetial?baseEntityId=' + item.id;
  218. break;
  219. }
  220. if (url) uni.navigateTo({
  221. url
  222. })
  223. },
  224. // 处理错误图像
  225. showErrorImg(item) {
  226. this.$set(item, 'bannerImg', 'https://m.geidcp.com/api/file/pub//def/projectdefault.png')
  227. },
  228. // tabs通知swiper切换
  229. async tabsChange(index) {
  230. this.swiperCurrent = index;
  231. this.pageNo = 1;
  232. this.showLoading = true;
  233. this.modelType = this.menuList[index].modelType;
  234. },
  235. // swiper-item左右移动,通知tabs的滑块跟随移动
  236. transition(e) {
  237. let dx = e.detail.dx;
  238. this.$refs.uTabs.setDx(dx);
  239. },
  240. // 由于swiper的内部机制问题,快速切换swiper不会触发dx的连续变化,需要在结束时重置状态
  241. animationfinish(e) {
  242. let current = e.detail.current;
  243. this.$refs.uTabs.setFinishCurrent(current);
  244. this.swiperCurrent = current;
  245. this.followList[this.swiperCurrent].list = [];
  246. this.current = current;
  247. this.pageNo = 1;
  248. this.showLoading = true;
  249. this.modelType = this.menuList[this.current].modelType;
  250. this.getPortalMyFollowModel(this.current);
  251. },
  252. // scroll-view到底部加载更多
  253. onreachBottom() {
  254. if (this.pageNo < this.totalPage) {
  255. this.pageNo++;
  256. this.showLoading = true;
  257. this.getPortalMyFollowModel(this.swiperCurrent, 'loadmore')
  258. } else {
  259. if (this.showLoading != false) this.showLoading = false;
  260. }
  261. }
  262. }
  263. }
  264. </script>
  265. <style lang="scss" scoped>
  266. .myFollw {
  267. .bg {
  268. position: fixed;
  269. width: 100%;
  270. right: 0;
  271. bottom: 0;
  272. top: 0;
  273. right: 0;
  274. background-color: #fafafa;
  275. z-index: -1;
  276. }
  277. width:100%;
  278. .edit {
  279. height: 80upx;
  280. line-height: 80upx;
  281. margin-right: 30upx;
  282. color: #fff;
  283. display: flex;
  284. align-items: center;
  285. position: relative;
  286. overflow: hidden;
  287. }
  288. .line-h {
  289. height: 1px;
  290. background-color: #eee;
  291. margin: 10upx 0;
  292. }
  293. .loading {
  294. width: 100%;
  295. padding: 20rpx 0;
  296. background-color: #fafafa;
  297. /deep/ .u-load-more-wrap {
  298. margin-top: 50rpx;
  299. }
  300. &.fixbottom {
  301. position: fixed;
  302. bottom: 0;
  303. z-index: 999;
  304. }
  305. }
  306. .nomore {
  307. position: flex;
  308. bottom: 0;
  309. text-align: center;
  310. height: 50upx;
  311. line-height: 50upx;
  312. font-size: 24upx;
  313. color: #666;
  314. margin-top: 1%;
  315. }
  316. .menus {
  317. width: 750rpx;
  318. height: 80rpx;
  319. background-color: red;
  320. /deep/ .u-tabs {
  321. padding: 10rpx 0;
  322. }
  323. }
  324. .followList {
  325. display: flex;
  326. flex-direction: column;
  327. position: fixed;
  328. padding: 20upx 0;
  329. width: 100%;
  330. height: 92%;
  331. /deep/ uni-swiper {
  332. height: 92%;
  333. }
  334. .item {
  335. display: flex;
  336. margin: 30upx;
  337. background-color: #fff;
  338. border-radius: 16rpx;
  339. overflow: hidden;
  340. box-shadow: 0 0 5px 3px #eee;
  341. .thumb {
  342. width: 200upx;
  343. min-height: 150upx;
  344. position: relative;
  345. overflow: hidden;
  346. .ui-img {
  347. width: 96%;
  348. height: 96%;
  349. display: block;
  350. margin: auto auto;
  351. position: absolute;
  352. top: 0;
  353. bottom: 0;
  354. left: 0;
  355. right: 0;
  356. }
  357. }
  358. .info {
  359. flex: 1;
  360. padding: 16rpx;
  361. display: flex;
  362. flex-direction: column;
  363. .label {
  364. font-size: 24upx;
  365. display: flex;
  366. width: 100%;
  367. flex: 1;
  368. align-self: flex-start;
  369. }
  370. .other {
  371. align-self: flex-start;
  372. display: flex;
  373. }
  374. .tags {
  375. .textitem {
  376. margin-right: 20upx;
  377. background-color: #0081FF;
  378. color: #fff;
  379. font-size: 12px;
  380. }
  381. }
  382. }
  383. }
  384. }
  385. }
  386. </style>