index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <script setup>
  2. import {
  3. ref
  4. } from 'vue';
  5. import {
  6. onLoad,
  7. onUnload,
  8. onPullDownRefresh,
  9. onReachBottom,
  10. onPageScroll
  11. } from "@dcloudio/uni-app";
  12. import {
  13. getFocusList,
  14. } from "@/api/work/focus.js";
  15. import {
  16. addFocus,
  17. cancelFocus
  18. } from "@/api/work/focus.js";
  19. let scrollTop = ref(0)
  20. let loading = ref(true)
  21. // 参数
  22. let searchInfo = ref({
  23. pageNo: 1,
  24. pageSize: 10,
  25. })
  26. // 触底加载flag
  27. let moreListFlag = true
  28. // 获取列表
  29. let projectList = ref([]);
  30. let listTotal = ref(0);
  31. // 折叠/展开
  32. const changeFoldItem = (status, id) => {
  33. let item = projectList.value.find(item => item.id === id);
  34. item.unfold = status;
  35. }
  36. function getList() {
  37. if (searchInfo.value.pageNo == 1) {
  38. loading.value = true
  39. }
  40. getFocusList(searchInfo.value).then(res => {
  41. loading.value = false
  42. projectList.value = projectList.value.concat(res.data.list);
  43. listTotal.value = res.data.total;
  44. if (res.data.total == searchInfo.value.pageNo * searchInfo.value.pageSize - (10 - res.data.list
  45. .length)) moreListFlag = false;
  46. }).catch(() => {
  47. loading.value = false
  48. })
  49. }
  50. function goToDetail(id, subName) {
  51. uni.navigateTo({
  52. url: `/pages/projectInfo/detail/index?id=${id}&subName=${subName}`
  53. })
  54. }
  55. function goToPage(url) {
  56. uni.navigateTo({
  57. url
  58. })
  59. }
  60. function goToReport(type, subId, subName) {
  61. if (type === 'wtdb') {
  62. uni.navigateTo({
  63. url: `/pages/problemSupervision/index?type=${type}&subId=${subId}&subName=${subName}`
  64. })
  65. } else if (type === 'qtldjbm') {
  66. uni.navigateTo({
  67. url: `/pages/leadersList/index?type=${type}&subId=${subId}&subName=${subName}`
  68. })
  69. } else if (type === 'xcyx') {
  70. uni.navigateTo({
  71. url: `/pages/projectImageAndVideo/index?type=${type}&subId=${subId}&subName=${subName}`
  72. })
  73. } else if (type === 'more') {
  74. uni.navigateTo({
  75. url: `/pages/projectBtnList/index?type=${type}&subId=${subId}&subName=${subName}`
  76. })
  77. } else {
  78. uni.navigateTo({
  79. url: `/pages/projectInfo/report/index?type=${type}&subId=${subId}&subName=${subName}`
  80. })
  81. }
  82. }
  83. // 收藏/取消
  84. function changeFocus(id, status) {
  85. let item = projectList.value.find(item => item.id === id);
  86. if (status) {
  87. cancelFocus({
  88. subId: id
  89. }).then(res => {
  90. if (res.code === 200) {
  91. item.isAttention = 0;
  92. }
  93. }).catch(() => {
  94. uni.showToast({
  95. title: "更改收藏状态失败。",
  96. icon: "none",
  97. duration: 2000
  98. })
  99. })
  100. } else {
  101. addFocus({
  102. subId: id
  103. }).then(res => {
  104. if (res.code === 200) {
  105. item.isAttention = 1;
  106. }
  107. }).catch(() => {
  108. uni.showToast({
  109. title: "更改收藏状态失败。",
  110. icon: "none",
  111. duration: 2000
  112. })
  113. })
  114. }
  115. }
  116. onLoad((options) => {
  117. uni.$on('projectInfoSearch', resolve => {
  118. searchInfo.value = Object.assign(searchInfo.value, resolve);
  119. searchInfo.value.pageNo = 1;
  120. projectList.value = [];
  121. listTotal.value = 0;
  122. moreListFlag = true;
  123. getList();
  124. });
  125. getList();
  126. });
  127. onUnload(() => {
  128. uni.$off('projectInfoSearch');
  129. })
  130. onPageScroll((e) => {
  131. scrollTop.value = e.scrollTop
  132. })
  133. onPullDownRefresh(() => {
  134. searchInfo.value.pageNo = 1;
  135. projectList.value = [];
  136. moreListFlag = true;
  137. try {
  138. getList();
  139. } finally {
  140. uni.stopPullDownRefresh()
  141. }
  142. })
  143. onReachBottom(() => {
  144. if (!moreListFlag) {
  145. return uni.showToast({
  146. title: "已经到底了。",
  147. icon: "none",
  148. duration: 2000
  149. })
  150. }
  151. searchInfo.value.pageNo++;
  152. getList();
  153. })
  154. </script>
  155. <template>
  156. <view class="container">
  157. <page-title>关注项目</page-title>
  158. <view class="cards-list">
  159. <view v-for="(item,index) in projectList" :key="index">
  160. <!-- 未折叠卡片 -->
  161. <view class="card" v-if="item.unfold">
  162. <!-- 项目名称 -->
  163. <view class="card-item">
  164. <view class="card-item-name">项目名称</view>
  165. <view class="card-item-content">{{item.subName ?? "--"}}</view>
  166. </view>
  167. <!-- 总投资(万元) -->
  168. <view class="card-item">
  169. <view class="card-item-name">总投资(万元)</view>
  170. <view class="card-item-content">{{item.amtTotal ?? "--"}}</view>
  171. </view>
  172. <!-- 年度计划投资-申报单位(万元) -->
  173. <view class="card-item">
  174. <view class="card-item-name">年度计划投资-申报单位(万元)</view>
  175. <view class="card-item-content">{{item.yearAmt ?? "--"}}</view>
  176. </view>
  177. <!-- 已完成投资(万元)-->
  178. <view class="card-item">
  179. <view class="card-item-name">已完成投资(万元)</view>
  180. <view class="card-item-content">{{item.yearAmtSj ?? "--"}}</view>
  181. </view>
  182. <!-- 当前状态 -->
  183. <view class="card-item">
  184. <view class="card-item-name">当前状态</view>
  185. <view class="card-item-content">{{item.status ?? "--"}}</view>
  186. </view>
  187. <!-- 功能按钮 -->
  188. <view class="card-item">
  189. <!-- 项目查看按钮(特殊) -->
  190. <view class="card-btn fat-btn special-btn" @click="goToDetail(item.id,item.subName)"
  191. v-if="item.usersub == 1">
  192. 项目查看</view>
  193. <!-- 项目查看按钮 -->
  194. <view class="card-btn fat-btn project-btn" @click="goToDetail(item.id,item.subName)" v-else>项目查看
  195. </view>
  196. <!-- 关注按钮 -->
  197. <view class="card-btn fat-btn focus-btn" @click="changeFocus(item.id,item.isAttention)"
  198. v-if="!item.isAttention">关注</view>
  199. <view class="card-btn fat-btn focus-btn-no" @click="changeFocus(item.id,item.isAttention)" v-else>
  200. 取消关注</view>
  201. </view>
  202. <!-- 周月年报按钮 -->
  203. <view class="card-item bottom-item">
  204. <view class="card-btn thin-btn report-btn" @click="goToReport('weekly',item.id,item.subName)">周报
  205. </view>
  206. <view class="card-btn thin-btn report-btn" @click="goToReport('monthly',item.id,item.subName)">月报
  207. </view>
  208. <view class="card-btn thin-btn more-btn" @click="goToReport('more',item.id,item.subName)">更多操作
  209. </view>
  210. </view>
  211. <!-- 编号 -->
  212. <view class="card-fold-option"
  213. :class="item.status_fgw === '2' ? 'card-fold-red' :item.status_fgw === '1' ?'card-fold-yellow':''">
  214. <view class="card-fold-count">{{index + 1}} / {{listTotal}}</view>
  215. <view class="card-fold-center" @click.stop="changeFoldItem(false,item.id)">
  216. <view class="card-fold-btn card-unfold-btn"></view>
  217. </view>
  218. <view class="card-fold-chaos"></view>
  219. </view>
  220. </view>
  221. <!-- 折叠卡片 -->
  222. <view class="card-fold" v-else>
  223. {{item.subName ?? "--"}}
  224. <view class="card-fold-option"
  225. :class="item.status_fgw === '2' ? 'card-fold-red' :item.status_fgw === '1' ?'card-fold-yellow':''">
  226. <view class="card-fold-count">{{index + 1}} / {{listTotal}}</view>
  227. <view class="card-fold-center" @click.stop="changeFoldItem(true, item.id)">
  228. <view class="card-fold-btn"></view>
  229. </view>
  230. <view class="card-fold-chaos"></view>
  231. </view>
  232. </view>
  233. </view>
  234. <empty-show v-if="projectList.length===0"></empty-show>
  235. </view>
  236. <u-back-top :scroll-top="scrollTop"></u-back-top>
  237. <u-loading-page :loading="loading"></u-loading-page>
  238. </view>
  239. </template>
  240. <style lang="scss" scoped>
  241. .project-btn {
  242. width: 48% !important;
  243. background: #1869F6;
  244. }
  245. .focus-btn {
  246. width: 48% !important;
  247. background-color: #fff;
  248. border-radius: 16rpx 16rpx 16rpx 16rpx;
  249. border: 3rpx solid #1869F6;
  250. color: #1869F6;
  251. }
  252. .focus-btn-no {
  253. width: 48% !important;
  254. background-color: #fff;
  255. border-radius: 16rpx 16rpx 16rpx 16rpx;
  256. border: 3rpx solid #FF2D2D;
  257. color: #FF2D2D;
  258. }
  259. .more-btn {
  260. background-color: #fff;
  261. color: #1869F6;
  262. font-size: 32rpx;
  263. }
  264. .focusText {
  265. font-size: 12rpx;
  266. margin-right: 12rpx;
  267. }
  268. .card {
  269. padding-top: 16rpx;
  270. overflow: hidden;
  271. }
  272. .light-item {
  273. margin-bottom: 32rpx;
  274. }
  275. .card-light {
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. }
  280. .card-light-bottom {
  281. width: 122rpx;
  282. height: 44rpx;
  283. margin: auto 0;
  284. background-size: 100% 100%;
  285. }
  286. .light-red {
  287. background-image: url('@/static/icon-light-red.png');
  288. }
  289. .light-yellow {
  290. background-image: url('@/static/icon-light-yellow.png');
  291. }
  292. .light-green {
  293. background-image: url('@/static/icon-light-green.png');
  294. }
  295. .focus {
  296. width: 46rpx;
  297. height: 40rpx;
  298. background-image: url("@/static/focus-off.png");
  299. background-size: 100% 100%;
  300. }
  301. .focus-on {
  302. background-image: url("@/static/focus-on.png");
  303. }
  304. .special-btn {
  305. background: linear-gradient(225deg, #2428F1 0%, #12C8C2 94%);
  306. }
  307. .bottom-item {
  308. display: flex;
  309. flex-wrap: wrap;
  310. justify-content: space-between;
  311. align-content: flex-start;
  312. row-gap: 20rpx;
  313. margin-bottom: 64rpx;
  314. }
  315. .lamp {
  316. display: flex;
  317. justify-content: center;
  318. align-items: center;
  319. image {
  320. width: 72rpx;
  321. height: 72rpx;
  322. margin-right: 20rpx;
  323. }
  324. text {
  325. font-size: 32rpx;
  326. }
  327. }
  328. .card-box2 {
  329. padding: 0 0 36rpx 0;
  330. border-radius: 28rpx 28rpx 28rpx 28rpx;
  331. }
  332. .card-value {
  333. position: absolute;
  334. bottom: 0;
  335. right: 0;
  336. width: 255rpx;
  337. height: 68rpx;
  338. padding-right: 22rpx;
  339. text-align: right;
  340. line-height: 68rpx;
  341. color: #1869F6;
  342. font-size: 32rpx;
  343. background: linear-gradient(270deg, #B2CEFF 0%, rgba(219, 232, 255, 0) 100%);
  344. }
  345. .card-fold {
  346. position: relative;
  347. width: 100%;
  348. min-height: 152rpx;
  349. margin-bottom: 20rpx;
  350. padding: 24rpx 30rpx 52rpx;
  351. box-sizing: border-box;
  352. background: #FFFFFF;
  353. border-radius: 40rpx;
  354. overflow: hidden;
  355. }
  356. .card-fold-option {
  357. position: absolute;
  358. display: flex;
  359. justify-content: space-between;
  360. align-items: center;
  361. left: 0;
  362. bottom: 0;
  363. width: 100%;
  364. height: 38rpx;
  365. padding: 0 40rpx;
  366. box-sizing: border-box;
  367. background: linear-gradient(270deg, #CADDFF 4%, rgba(219, 232, 255, 0) 100%);
  368. z-index: 999;
  369. .card-fold-count {
  370. flex: 1;
  371. font-size: 28rpx;
  372. color: #1869F6;
  373. }
  374. .card-fold-center {
  375. flex: 1;
  376. .card-fold-btn {
  377. width: 32rpx;
  378. height: 20rpx;
  379. margin: 0 auto;
  380. background-image: url("@/static/icon-fold.png");
  381. background-size: 100% 100%;
  382. }
  383. .card-unfold-btn {
  384. transform: rotate(180deg);
  385. }
  386. }
  387. .card-fold-chaos {
  388. flex: 1;
  389. }
  390. }
  391. .card-fold-red {
  392. background: linear-gradient(270deg, #FF8080 0%, rgba(219, 232, 255, 0) 100%);
  393. .card-fold-count {
  394. color: #FF0000;
  395. }
  396. .card-fold-center {
  397. .card-fold-btn {
  398. background-image: url("@/static/icon-fold-red.png");
  399. }
  400. }
  401. }
  402. .card-fold-yellow {
  403. background: linear-gradient(270deg, #FFAA00 4%, rgba(219, 232, 255, 0) 100%);
  404. .card-fold-count {
  405. color: #E19703;
  406. }
  407. .card-fold-center {
  408. .card-fold-btn {
  409. background-image: url("@/static/icon-fold-yellow.png");
  410. }
  411. }
  412. }
  413. </style>