userCenterMyFollow.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <div style="width: 100%;background: #fff;min-height: 700px;color: #666;" class="userCenterMyActivity">
  3. <div style="height: 60px;line-height: 60px;padding-top: 30px;margin-left: 30px;margin-right: 30px; border-bottom: 1px solid rgba(228, 228, 228, 1);">
  4. {{$t('common.MyAttention')}}
  5. </div>
  6. <div v-if="!ProjectType">
  7. <ul style="margin:30px;width: 90%;">
  8. <img v-if="this.$i18n.locale.toUpperCase()=='ZH'" src="@/assets/img/noData.png" alt="" style="width: 100%;height: 100%;">
  9. <img v-if="this.$i18n.locale.toUpperCase()=='EN'" src="@/assets/img/noDataEn.png" alt="" style="width: 100%;height: 100%;">
  10. </ul>
  11. </div>
  12. <div style="min-height: 60px;line-height: 60px;margin-left: 30px;margin-right: 30px; " v-else>
  13. <span v-for="(item,index) in ProjectType" @click="getData(item,index)" :class="index==jsonType?'jsonType1 cursor':'jsonType2 cursor'">
  14. {{$t(item.modelName)}}({{modelTypeNumMap[item.modelName]}})
  15. </span>
  16. <!-- <el-input :placeholder="$t('common.keywordSearch')" v-model="keyWord" style="float: right;margin-top: 10px;">
  17. <template slot="append"><i class="el-icon-search" @click="keyWordSearch()"></i></template>
  18. </el-input> -->
  19. </div>
  20. <div style="margin-left: 30px;margin-right: 30px;margin-top: 10px; " class="myActivity" >
  21. <div>
  22. <ul>
  23. <li class="myActivityLi" v-for="(item,index) in tableData " :key="index">
  24. <img @click="toView('',item,index)"
  25. :src="'api/file/pub/'+ item.bannerImg" alt
  26. style="width: 100%;height: 131px;cursor: pointer;"/>
  27. <div
  28. style="color: #bcbcbc;font-size: 14px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"
  29. >{{item.followName}}
  30. </div>
  31. </li>
  32. <li class="myActivityLi" v-if="initDataOther.length!=0" :key="'other'+index" v-for="(item,index) in initDataOther " >
  33. </li>
  34. </ul>
  35. </div>
  36. <!-- <div style="width: 100%;height: 160px;">-->
  37. <!-- <div class="recommend">-->
  38. <!-- <ul>-->
  39. <!-- <li v-for="(item,index) in tableData">-->
  40. <!-- &lt;!&ndash; <img @click="toViewChange(item.projectId,index)" :src="'api/file/pub/' + item.bannerList[0]" alt style="width: 100%;height: 115px;cursor: pointer;" /> &ndash;&gt;-->
  41. <!-- <img @click="toViewProject('projectPresentationDetails',item.id,index)"-->
  42. <!-- :src="'api/file/pub/'+ item.bannerImg" alt-->
  43. <!-- style="width: 100%;height: 115px;cursor: pointer;"/>-->
  44. <!-- <div-->
  45. <!-- style="color: #bcbcbc;font-size: 14px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;"-->
  46. <!-- >{{item.followName}}-->
  47. <!-- </div>-->
  48. <!-- </li>-->
  49. <!-- </ul>-->
  50. <!-- </div>-->
  51. <!-- </div>-->
  52. </div>
  53. <div style="width: 100%;position: relative;height: 100px;">
  54. <el-pagination
  55. style="margin-top: 40px;height: 80px;position: absolute;left: 50%;top: 0;transform: translateX(-50%);"
  56. background
  57. layout="prev, pager, next"
  58. page-size="8"
  59. :total=total @size-change="handleSizeChange"
  60. @current-change="handleCurrentChange">
  61. </el-pagination>
  62. </div>
  63. </div>
  64. </template>
  65. <script>
  66. import {followModelNumByUser,getPortalMyFollowMode} from "@/api/userCenter/myFollow";
  67. import { saveFollowModelLanguage } from "@/api/operation/basePortalModelFollowInfo";
  68. import {getToken} from "@/utils/auth";
  69. import Base from "@/views/base/Base";
  70. export default {
  71. name: 'userCenterMyFollow',
  72. extends: Base,
  73. data () {
  74. return {
  75. formInline: {
  76. user: '',
  77. region: ''
  78. },
  79. jsonType:0,
  80. ProjectType:[],
  81. modelTypeNumMap:{},
  82. tableData: [],
  83. userId:'',
  84. toDate:Date.parse(new Date()),
  85. total:1,
  86. modelType:'',
  87. params: {
  88. pageNo: 1,
  89. pageSize: "8",
  90. modelType: "project",
  91. language:""
  92. },
  93. initDataOther:[]
  94. }
  95. },
  96. mounted(){
  97. let user = window.localStorage.getItem('user');
  98. var users = JSON.parse(user);
  99. this.userId = users.userId;
  100. this.getFollowNum();// 获取用户关注数量
  101. },
  102. watch:{
  103. '$i18n.locale'(){
  104. this.getFollowNum();
  105. }
  106. },
  107. methods:{
  108. toView(router,json,index){
  109. console.log(json)
  110. if('已删除' == json.followName||'Deleted' == json.followName){
  111. this.shareChange(json.id);
  112. return;
  113. }
  114. if(this.params.modelType=='project'){
  115. router='projectPresentationDetails'
  116. window.localStorage.setItem('router', router);
  117. this.$store.commit('modify', router);
  118. const { href } =this.$router.resolve({
  119. name: router,
  120. query: {
  121. key: json.id,
  122. dataIndex:index,
  123. }
  124. });
  125. window.open(href, '_blank');
  126. }else if(this.params.modelType=='activity'){
  127. router = 'cooperationExchangeListDetails'
  128. this.$store.commit('modify', router);
  129. window.localStorage.setItem('router', router);
  130. const { href } = this.$router.resolve({
  131. name: router,
  132. query: {
  133. key: json.id
  134. },
  135. });
  136. window.open(href, '_blank');
  137. }else if(this.params.modelType=='country'){
  138. router = 'countryNationalSpace'
  139. this.$store.commit('modify', router);
  140. window.localStorage.setItem('router', router);
  141. const { href } = this.$router.resolve({
  142. name: 'countryNationalSpace',
  143. query: {
  144. key: json.id
  145. }
  146. });
  147. window.open(href, '_blank');
  148. }else if(this.params.modelType=='enterprise'){
  149. this.$store.commit('modify', router);
  150. window.localStorage.setItem('router', router);
  151. const { href } = this.$router.resolve({
  152. name: 'enterpriseDetails',
  153. query: {
  154. key: json.id
  155. }
  156. });
  157. window.open(href, '_blank');
  158. }else if(this.params.modelType=='researchResources'){
  159. router = 'resourceSharingResourceDetails'
  160. this.$store.commit('modify', router);
  161. window.localStorage.setItem('router', router);
  162. let params = {
  163. entityId:json.entityId,
  164. }
  165. const { href } = this.$router.resolve({
  166. name: 'resourceSharingResourceDetails',
  167. query: {
  168. key : JSON.stringify(json)
  169. }
  170. });
  171. window.open(href, '_blank');
  172. }else if(this.params.modelType=='researchResult'){
  173. router = 'resourceSharingDetails'
  174. this.$store.commit('modify', router);
  175. window.localStorage.setItem('router', router);
  176. let params = {
  177. entityId:json.entityId,
  178. }
  179. const { href } = this.$router.resolve({
  180. name: 'resourceSharingDetails',
  181. query: {
  182. key : JSON.stringify(json)
  183. }
  184. });
  185. window.open(href, '_blank');
  186. }else if(this.params.modelType=='financialInstitution'){
  187. router = 'FinancialServicesDetails'
  188. this.$store.commit('modify', router);
  189. window.localStorage.setItem('router', router);
  190. let params = {
  191. key:json.id,
  192. }
  193. const { href } = this.$router.resolve({
  194. name: 'FinancialServicesDetails',
  195. query: {
  196. key : json.id
  197. }
  198. });
  199. window.open(href, '_blank');
  200. }else if(this.params.modelType=='investmentGuidelines'){
  201. router = 'FinancialServicesGuideDetails'
  202. this.$store.commit('modify', router);
  203. window.localStorage.setItem('router', router);
  204. let params = {
  205. key:json.id,
  206. }
  207. const { href } = this.$router.resolve({
  208. name: 'FinancialServicesGuideDetails',
  209. query: {
  210. key : json.id
  211. }
  212. });
  213. window.open(href, '_blank');
  214. }
  215. },
  216. getFollowNum(){
  217. let params={
  218. // userId:this.userId,
  219. language:this.$i18n.locale.toUpperCase()
  220. };
  221. let token =getToken();
  222. followModelNumByUser(params,token).then(res=>{
  223. this.ProjectType=res.data.modelTypeMap;
  224. this.modelTypeNumMap=res.data.modelTypeNumMap;
  225. this.modelType=res.data.modelTypeMap[0].modelType
  226. this.getList(this.userId,res.data.modelTypeMap[0].modelType);
  227. })
  228. },
  229. getList(id,type){
  230. if(type){
  231. this.params.modelType = type;
  232. }
  233. this.params.language=this.$i18n.locale.toUpperCase();
  234. let token =getToken();
  235. let that = this;
  236. getPortalMyFollowMode(this.params,token).then(res=>{
  237. that.tableData=res.data?res.data.models:[];
  238. that.tableData.forEach(element => {
  239. if(element.bannerImg && element.bannerImg instanceof Array && element.bannerImg[0] != ''){
  240. var bannerImgs = element.bannerImg;
  241. element.bannerImg = bannerImgs[0];
  242. }else if(element.bannerImg && element.bannerImg.constructor==String && element.bannerImg !='') {
  243. var bannerImgs = element.bannerImg.split(",");
  244. element.bannerImg = bannerImgs[0];
  245. }else{
  246. element.bannerImg = '';
  247. }
  248. });
  249. if (that.params.modelType == "project") {
  250. that.tableData.forEach((i) => {
  251. i.status = "project"
  252. if(!i.bannerImg || i.bannerImg ==''){
  253. i.bannerImg = "def/projectdefault.png"
  254. }
  255. })
  256. }
  257. if (that.params.modelType == "enterprise") {
  258. that.tableData.forEach((i) => {
  259. i.status = "enterprise"
  260. if(!i.bannerImg || i.bannerImg ==''){
  261. i.bannerImg = "def/enterpriseDefault.png"
  262. }
  263. })
  264. }
  265. if (that.params.modelType == "country") {
  266. that.tableData.forEach((i) => {
  267. i.status = "country"
  268. if(!i.bannerImg || i.bannerImg ==''){
  269. i.bannerImg = "def/projectdefault.png"
  270. }
  271. })
  272. }
  273. if (that.params.modelType == "activity") {
  274. that.tableData.forEach((i) => {
  275. i.status = "activity"
  276. if(!i.bannerImg || i.bannerImg ==''){
  277. i.bannerImg = "def/projectdefault.png"
  278. }
  279. })
  280. }
  281. if (that.params.modelType == "researchResources") {
  282. that.tableData.forEach((i) => {
  283. i.status = "researchResources"
  284. if(!i.bannerImg || i.bannerImg ==''){
  285. i.bannerImg = "def/projectdefault.png"
  286. }
  287. })
  288. }
  289. if (that.params.modelType == "researchResult") {
  290. that.tableData.forEach((i) => {
  291. i.status = "researchResult"
  292. if(!i.bannerImg || i.bannerImg ==''){
  293. i.bannerImg = "def/projectdefault.png"
  294. }
  295. })
  296. }
  297. that.total=res.data?res.data.page.totalCount-0:0;
  298. that.initDataOther = [];
  299. var initDataNum = that.tableData.length%4
  300. initDataNum = 4-initDataNum;
  301. if(initDataNum!=4){
  302. for (var i=0;i<(initDataNum);i++){
  303. that.initDataOther[i] = {}
  304. }
  305. }
  306. })
  307. },
  308. shareChange(id) {
  309. this.saveFollowModelDo("unfollow",id);
  310. },
  311. saveFollowModelDo: function(followType,projectId){
  312. let user = window.localStorage.getItem('user');
  313. if (!user) {
  314. this.$message.warning("请先登录");
  315. } else {
  316. let token = "" + getToken();
  317. this.resetToken();
  318. // 接口逻辑
  319. this.submitHandler(token => {
  320. saveFollowModelLanguage(this.$i18n.locale.toUpperCase(),projectId,this.modelType, this.userId,followType,token).then(result => {
  321. // console.log(result);
  322. this.$message({
  323. message: result.data,
  324. type: 'success'
  325. });
  326. this.getList();
  327. }).catch(error => {
  328. // 此处你的业务代码
  329. });
  330. });
  331. }
  332. },
  333. // 获取数据
  334. getData(json,index){
  335. //json为搜索标识
  336. this.jsonType=index;
  337. this.modelType=json.modelType;
  338. this.getList(this.userId,json.modelType);
  339. },
  340. // 撤回
  341. withdraw(index,rows) {
  342. console.log(index, rows)
  343. },
  344. handleSizeChange(val) {
  345. console.log(`每页 ${val} 条`);
  346. },
  347. handleCurrentChange(val) {
  348. this.params.pageNo=val;
  349. this.getList()
  350. },
  351. }
  352. }
  353. </script>
  354. <style scoped>
  355. .el-input {
  356. width: 200px ;
  357. }
  358. .el-form-item__content,.el-select {
  359. width: 200px !important;
  360. }
  361. .el-table thead {
  362. background: #eee;
  363. }
  364. .userCenterMyActivity >>> .el-pagination .el-pager li,
  365. .userCenterMyActivity >>> .el-pagination .btn-next,
  366. .userCenterMyActivity >>> .el-pagination .btn-prev{
  367. width: 35px;
  368. height: 35px;
  369. line-height: 35px;
  370. }
  371. .userCenterMyActivity >>> .el-pagination.is-background .el-pager li:not(.disabled).active {
  372. background: #0050d8;
  373. }
  374. .margin_left {
  375. margin-left: 5px;
  376. }
  377. .myActivityLi {
  378. width: 220px;
  379. float: left;
  380. /*height: 153px;*/
  381. margin-bottom: 20px;
  382. /*border: 1px solid rgba(228, 228, 228, 1);*/
  383. /*box-shadow: rgba(228, 228, 228, 1);*/
  384. }
  385. .myActivityLi .title {
  386. color: #666;
  387. font-weight: 700;
  388. margin-left: 10px;
  389. margin-top: 8px;
  390. }
  391. .myActivityLi_data {
  392. color: #666;
  393. font-size: 12px;
  394. margin-top: 5px;
  395. margin-left: 10px;
  396. }
  397. .myActivity ul {
  398. text-align: top;
  399. height: 100%;
  400. display: flex;
  401. display: -webkit-flex; /* Safari */
  402. justify-content:space-between;
  403. flex-wrap:wrap;
  404. }
  405. .el-tag {
  406. height: 22px;
  407. line-height: 22px;
  408. margin-right: 5px;
  409. }
  410. .jsonType1 {
  411. font-size: 14px;
  412. margin-right: 10px;
  413. color: #0050d8;
  414. }
  415. .jsonType2 {
  416. font-size: 14px;
  417. margin-right: 10px;
  418. }
  419. .recommend {
  420. width: 456px;
  421. float: left;
  422. height: 153px;
  423. margin-bottom: 20px;
  424. border: 1px solid rgba(228, 228, 228, 1);
  425. box-shadow: rgba(228, 228, 228, 1);
  426. /* margin-left: 30px; */
  427. }
  428. .recommend li {
  429. display: inline-block;
  430. width: 170px;
  431. /* height: 130px; */
  432. text-align: center;
  433. margin-right: 16px;
  434. }
  435. </style>