myfollowEdit.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <view class="myFollwEdit">
  3. <u-navbar :is-back="true" back-icon-color="#2af" :border-bottom="true" back-text="返回"
  4. :back-text-style="{color:'#2af'}" :title="title">
  5. <!-- <view slot="right" class="edit" ><icon type="search" size="16"/>编辑</view> -->
  6. </u-navbar>
  7. <view class="menus">
  8. <view class="item" v-for="(item,index) in menus" :key="index" @click="showDifferentItem(item,index)"
  9. :class="{active:menuIndex==index}">{{item.modelName}}</view>
  10. </view>
  11. <scroll-view class="followList" :scroll-y="true" @scrolltolower="scrollToBottom" :show-scrollbar="true">
  12. <view class="item" v-for="(item,index) in followList" :key="index">
  13. <view class="select">
  14. <u-checkbox v-model="item.checked" shape="circle" @change="showCheccked(item)"></u-checkbox>
  15. </view>
  16. <view class="thumb">
  17. <image class="img" :src="item.thumb" mode="widthFix"></image>
  18. </view>
  19. <view class="info">
  20. <view class="label">
  21. <view class="labeltext">{{item.followName}}</view>
  22. <view class="follow" v-if="item.followed">已关注</view>
  23. </view>
  24. </view>
  25. </view>
  26. </scroll-view>
  27. <view class="nomore" v-if="flag">已全部加载完成</view>
  28. <view class="opt">
  29. <view class="clearList" @click="deleteListData('0')">一键清空</view>
  30. <view class="removeListItem" @click="deleteListData('1')">删除</view>
  31. </view>
  32. <u-toast ref="uToast" />
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. getFollowModelNumByUser,
  38. saveFollowModels
  39. } from '@/api/operation/basePortalModelFollowInfo'
  40. import {
  41. getPortalMyFollowMode
  42. } from '@/api/userCenter/myFollow'
  43. import UNavbar from '@/components/uni-nav-bar/uni-nav-bar.vue'
  44. export default {
  45. name: 'MyFollwEdit',
  46. components: {
  47. UNavbar
  48. },
  49. data() {
  50. return {
  51. title: '',
  52. menuIndex: 0,
  53. checkedList: [],
  54. idStrs: '',
  55. modelType: '',
  56. menus: [],
  57. count: 7,
  58. flag: false,
  59. followList: []
  60. }
  61. },
  62. onLoad() {
  63. uni.showLoading({
  64. title: this.$i18n.locale == 'zh' ? '加载中...' : 'Loading...'
  65. });
  66. this.title = this.$i18n.locale == 'zh' ? '我的关注' : 'My Follow';
  67. setTimeout(() => {
  68. uni.hideLoading();
  69. }, 100)
  70. },
  71. created() {
  72. this.getFollowModelNumByUser(this.$i18n.locale, this.token);
  73. },
  74. computed: {
  75. token() {
  76. return 'Bearer ' + uni.getStorageSync('Auth-Token');
  77. },
  78. userId() {
  79. return JSON.parse(uni.getStorageSync('user')).id;
  80. }
  81. },
  82. methods: {
  83. //模拟滚动加载更多
  84. scrollToBottom(e) {
  85. // if(this.count<30){
  86. // this.followList.push({
  87. // id:this.count++,
  88. // thumb:'../../../static/img/cooperationNetwork/equipments.png',
  89. // label:'日本大型海上风电项目',
  90. // follow:true,
  91. // country:'日本 东京',
  92. // stage:'招标阶段',
  93. // tags:['基础建设','清洁能源']
  94. // })
  95. // uni.showLoading({title: this.$i18n.locale == 'zh'? '加载中...': 'Loading...'});
  96. // setTimeout(()=>{uni.hideLoading();},300)
  97. // }else{
  98. // this.flag=true;
  99. // uni.hideLoading()
  100. // }
  101. },
  102. //展示不同的项目
  103. showDifferentItem(item, index) {
  104. if (this.menuIndex != index) {
  105. this.menuIndex = index;
  106. this.modelType = item.modelType;
  107. this.getPortalMyFollowModel()
  108. }
  109. },
  110. // 获取选项卡标题
  111. async getFollowModelNumByUser(lang, token) {
  112. let res = await getFollowModelNumByUser(lang, token);
  113. this.menus = res.data.modelTypeMap;
  114. if (res.data.modelTypeMap.length > 0) {
  115. this.modelType = res['data']['modelTypeMap'][0]['modelType'];
  116. this.getPortalMyFollowModel();
  117. }
  118. },
  119. // 获取不同项目的数据
  120. async getPortalMyFollowModel() {
  121. let params = {
  122. pageNo: this.pageNo,
  123. pageSize: this.pageSize,
  124. modelType: this.modelType,
  125. language: this.$i18n.locale
  126. }
  127. let res = await getPortalMyFollowMode(params);
  128. if (res.data.models) {
  129. this.followList = res.data.models;
  130. for (let i = 0; i < this.followList.length; i++) {
  131. this.$set(this.followList[i], 'thumb', 'https://m.geidcp.com/api/file/pub/' + this.followList[
  132. i]['bannerImg'][0]);
  133. this.$set(this.followList[i], 'followed', true)
  134. }
  135. } else this.followList = [];
  136. },
  137. // 批量取消关注
  138. async saveFollowModels() {
  139. let res = await saveFollowModels(this.idStrs, this.modelType, this.userId, 'unfollow', this.token);
  140. if (res.status == '200' && res.msg == 'ok') this.$refs.uToast.show({
  141. title: '已取消关注',
  142. type: 'success'
  143. })
  144. else this.$refs.uToast.show({
  145. title: '取消关注失败',
  146. type: 'error'
  147. })
  148. },
  149. // 获取已经选中的数据
  150. showCheccked(item) {
  151. if (this.checkedList.indexOf(item.id) == -1) {
  152. this.checkedList.push(item.id);
  153. } else {
  154. for (let i = 0; i < this.checkedList.length; i++) {
  155. if (this.checkedList[i] == item.id) this.checkedList.splice(i, 1);
  156. }
  157. }
  158. this.idStrs = this.checkedList.join(',');
  159. },
  160. //批量取消关注
  161. deleteListData(type) {
  162. if (type == '0') {
  163. this.$refs.uToast.show({
  164. title: '功能正在开发中',
  165. type: 'success'
  166. })
  167. return
  168. }
  169. if (this.idStrs) {
  170. this.saveFollowModels()
  171. } else {
  172. this.$refs.uToast.show({
  173. title: '请选择',
  174. type: 'error'
  175. })
  176. }
  177. },
  178. // 一键取消当前账户的所有关注
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. .myFollwEdit {
  184. background-color: #fefefe;
  185. width: 100%;
  186. height: 100%;
  187. position: absolute;
  188. .edit {
  189. margin-right: 30upx;
  190. color: #333;
  191. display: flex;
  192. align-items: center;
  193. position: relative;
  194. overflow: hidden;
  195. }
  196. .line-h {
  197. height: 1px;
  198. background-color: #eee;
  199. margin: 10upx 0;
  200. }
  201. .nomore {
  202. position: flex;
  203. bottom: 0;
  204. text-align: center;
  205. height: 50upx;
  206. line-height: 50upx;
  207. font-size: 24upx;
  208. color: #666;
  209. margin-top: 1%;
  210. }
  211. .menus {
  212. width: 100%;
  213. padding: 0 3%;
  214. height: 50upx;
  215. display: flex;
  216. justify-content: space-between;
  217. border-bottom: 1px solid #f0f0f0;
  218. margin: 30upx auto 0;
  219. .item {
  220. line-height: 50upx;
  221. &.active {
  222. border-bottom: 2px solid #007AFF;
  223. }
  224. }
  225. }
  226. .followList {
  227. display: flex;
  228. flex-direction: column;
  229. padding: 2% 3%;
  230. height: 82%;
  231. border-bottom: 1px solid #eee;
  232. .item {
  233. display: flex;
  234. margin: 20upx 0 0 0;
  235. .select {
  236. width: 36upx;
  237. height: 36upx;
  238. margin-right: 10upx;
  239. align-self: center;
  240. }
  241. .thumb {
  242. width: 200upx;
  243. height: 140upx;
  244. position: relative;
  245. overflow: hidden;
  246. margin-right: 3%;
  247. .img {
  248. width: 100%;
  249. display: block;
  250. margin: auto auto;
  251. position: absolute;
  252. top: 0;
  253. bottom: 0;
  254. left: 0;
  255. right: 0;
  256. }
  257. }
  258. .info {
  259. flex: 1;
  260. .label {
  261. font-size: 24upx;
  262. display: flex;
  263. .labeltext {
  264. flex: 1;
  265. }
  266. .follow {
  267. text-align: center;
  268. width: 100upx;
  269. height: 50upx;
  270. line-height: 50upx;
  271. background-color: #ff4422;
  272. color: #fff;
  273. border-radius: 50upx;
  274. margin-left: 10upx;
  275. }
  276. }
  277. .tags {
  278. .textitem {
  279. margin-right: 20upx;
  280. background-color: #0081FF;
  281. color: #fff;
  282. font-size: 12px;
  283. }
  284. }
  285. }
  286. }
  287. }
  288. .opt {
  289. width: 100%;
  290. padding: 0 10%;
  291. position: fixed;
  292. left: 0;
  293. right: 0;
  294. bottom: 20upx;
  295. height: 100upx;
  296. margin: 0 auto;
  297. background: #fefefe;
  298. display: flex;
  299. align-items: center;
  300. justify-content: space-between;
  301. .clearList,
  302. .removeListItem {
  303. margin-top: 52upx;
  304. width: 50%;
  305. line-height: 70upx;
  306. border: 1px solid #eee;
  307. padding: 0 40upx;
  308. border-radius: 0 0 80upx 80upx;
  309. text-align: center;
  310. }
  311. }
  312. }
  313. </style>