science.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. <template>
  2. <view class="container">
  3. <!-- 筛选标签栏 -->
  4. <view class="filter-bar">
  5. <view class="filter-tabs">
  6. <view class="tab-item"
  7. :class="{ active: currentTab === item.value }"
  8. v-for="(item, index) in tabs"
  9. :key="index"
  10. @click="switchTab(item.value)">
  11. {{ item.label }}
  12. </view>
  13. </view>
  14. <view class="filter-divider"></view>
  15. <view class="filter-btn" @click="showFilter = true">
  16. <image class="w32 h32" src="@/static/image/icon_select.png" mode=""></image>
  17. </view>
  18. </view>
  19. <!-- 任务列表 -->
  20. <scroll-view class="content" scroll-y>
  21. <view class="task-card" v-for="(item, index) in taskList" :key="index" @click="showDetail(item)">
  22. <view class="card-header">
  23. <view class="card-title">{{ item.title }}</view>
  24. <view class="status-tag" :class="item.status">
  25. {{ item.statusText }}
  26. </view>
  27. </view>
  28. <view class="card-tags">
  29. <view class="tag-item video-tag" v-if="item.videoType">
  30. <image class="w28 h28 mr10" src="@/static/image/icon_longvideo.png" mode=""></image>
  31. <text>{{ item.videoType }}</text>
  32. </view>
  33. <view class="tag-item" v-if="item.category">
  34. {{ item.category }}
  35. </view>
  36. <view class="tag-item points-tag">
  37. {{ item.points }}积分
  38. </view>
  39. <view class="tag-item">
  40. {{ item.count }}个
  41. </view>
  42. </view>
  43. <view class="card-dates">
  44. <view class="date-item">
  45. <text>开始时间: {{ item.startTime }}</text>
  46. </view>
  47. <view class="date-item">
  48. <text>结束时间: {{ item.endTime }}</text>
  49. </view>
  50. </view>
  51. <view class="card-warning" v-if="item.warning">
  52. <text class="warning-icon">⚠</text>
  53. <text>{{ item.warning }}</text>
  54. </view>
  55. <view class="card-rejection" v-if="item.rejectionReason">
  56. <text class="rejection-icon">❌</text>
  57. <text>驳回原因: {{ item.rejectionReason }}</text>
  58. </view>
  59. <view class="card-footer">
  60. <view class="footer-date">{{ item.createTime }}</view>
  61. <view class="footer-actions">
  62. <view class="action-btn" v-if="item.status === 'pending'" @click="goComplete(item)">
  63. 去完成
  64. </view>
  65. <view class="action-btn" v-if="item.status === 'rejected'" @click="goEdit(item)">
  66. 编辑
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </scroll-view>
  72. <!-- 筛选弹窗 -->
  73. <view class="filter-popup" v-if="showFilter" @click="closeFilter">
  74. <view class="filter-content" @click.stop>
  75. <view class="filter-header">
  76. <view class="filter-title">筛选</view>
  77. <view class="filter-close-btn" @click="closeFilter">×</view>
  78. </view>
  79. <!-- 申请时间筛选 -->
  80. <view class="filter-group">
  81. <view class="group-label">申请时间</view>
  82. <view class="date-range-inputs">
  83. <picker mode="date" :value="tempDateRange.startDate" @change="onStartDateChange">
  84. <view class="date-input" :class="{ placeholder: !tempDateRange.startDate }">
  85. {{ tempDateRange.startDate || '开始时间' }}
  86. </view>
  87. </picker>
  88. <text class="date-separator">-</text>
  89. <picker mode="date" :value="tempDateRange.endDate" @change="onEndDateChange">
  90. <view class="date-input" :class="{ placeholder: !tempDateRange.endDate }">
  91. {{ tempDateRange.endDate || '结束时间' }}
  92. </view>
  93. </picker>
  94. </view>
  95. </view>
  96. <!-- 任务类型筛选 -->
  97. <view class="filter-group">
  98. <view class="group-label">任务类型</view>
  99. <view class="filter-tags">
  100. <view
  101. class="filter-tag"
  102. :class="{ active: tempSelectedTaskType === item.value }"
  103. v-for="(item, index) in taskTypeOptions"
  104. :key="index"
  105. @click="selectTaskType(item.value)">
  106. {{ item.label }}
  107. </view>
  108. </view>
  109. </view>
  110. <!-- 操作按钮 -->
  111. <view class="filter-actions">
  112. <view class="reset-btn" @click="resetFilters">重置</view>
  113. <view class="confirm-btn" @click="confirmFilters">确定</view>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </template>
  119. <script>
  120. import { getAirClassroomList } from '@/api-js/airClassroom'
  121. export default {
  122. data() {
  123. return {
  124. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  125. currentTab: 'all',
  126. showFilter: false,
  127. dateRange: {
  128. startDate: '',
  129. endDate: ''
  130. },
  131. tempDateRange: {
  132. startDate: '',
  133. endDate: ''
  134. },
  135. selectedTaskType: 'article', // 默认选中科普文章
  136. tempSelectedTaskType: 'article',
  137. taskTypeOptions: [
  138. { label: '科普文章', value: 'article' },
  139. { label: '科普短视频', value: 'shortVideo' },
  140. { label: '科普长视频', value: 'longVideo' }
  141. ],
  142. tabs: [
  143. { label: '全部', value: 'all' },
  144. { label: '未完成', value: 'pending' },
  145. { label: '待审核', value: 'reviewing' },
  146. { label: '已通过', value: 'approved' },
  147. { label: '已驳回', value: 'rejected' }
  148. ],
  149. taskList: []
  150. }
  151. },
  152. watch: {
  153. showFilter(newVal) {
  154. if (newVal) {
  155. // 打开弹窗时,同步临时日期范围和任务类型为当前值
  156. this.tempDateRange = {
  157. startDate: this.dateRange.startDate,
  158. endDate: this.dateRange.endDate
  159. }
  160. this.tempSelectedTaskType = this.selectedTaskType
  161. }
  162. }
  163. },
  164. onLoad() {
  165. this.loadData()
  166. },
  167. onReachBottom() {
  168. this.loadMore()
  169. },
  170. methods: {
  171. goBack() {
  172. uni.navigateBack()
  173. },
  174. switchTab(value) {
  175. this.currentTab = value
  176. this.loadData()
  177. },
  178. closeFilter() {
  179. // 关闭弹窗时,恢复临时日期范围和任务类型为当前值
  180. this.tempDateRange = {
  181. startDate: this.dateRange.startDate,
  182. endDate: this.dateRange.endDate
  183. }
  184. this.tempSelectedTaskType = this.selectedTaskType
  185. this.showFilter = false
  186. },
  187. selectTaskType(value) {
  188. // 如果点击的是已选中的,则取消选择
  189. if (this.tempSelectedTaskType === value) {
  190. this.tempSelectedTaskType = ''
  191. } else {
  192. this.tempSelectedTaskType = value
  193. }
  194. },
  195. onStartDateChange(e) {
  196. this.tempDateRange.startDate = e.detail.value
  197. },
  198. onEndDateChange(e) {
  199. this.tempDateRange.endDate = e.detail.value
  200. },
  201. resetFilters() {
  202. this.tempDateRange = {
  203. startDate: '',
  204. endDate: ''
  205. }
  206. this.tempSelectedTaskType = ''
  207. },
  208. confirmFilters() {
  209. // 验证日期范围
  210. if (this.tempDateRange.startDate && this.tempDateRange.endDate) {
  211. if (new Date(this.tempDateRange.startDate) > new Date(this.tempDateRange.endDate)) {
  212. uni.showToast({
  213. icon: 'none',
  214. title: '开始时间不能大于结束时间'
  215. })
  216. return
  217. }
  218. }
  219. this.dateRange = {
  220. startDate: this.tempDateRange.startDate,
  221. endDate: this.tempDateRange.endDate
  222. }
  223. this.selectedTaskType = this.tempSelectedTaskType
  224. this.showFilter = false
  225. this.loadData()
  226. },
  227. goComplete(item) {
  228. uni.navigateTo({
  229. url: `/pages_task/completeTask?id=${item.id}`
  230. })
  231. },
  232. goEdit(item) {
  233. uni.navigateTo({
  234. url: `/pages_task/completeTask?id=${item.id}&edit=true`
  235. })
  236. },
  237. // 查看详情
  238. showDetail(item) {
  239. uni.navigateTo({
  240. url: `/pages_task/taskDetail?id=${item.id}`
  241. })
  242. },
  243. async loadData() {
  244. try {
  245. uni.showLoading({ title: '加载中...' })
  246. const res = await getAirClassroomList({
  247. status: this.currentTab,
  248. startDate: this.dateRange.startDate,
  249. endDate: this.dateRange.endDate,
  250. taskType: this.selectedTaskType,
  251. page: 1,
  252. pageSize: 20
  253. })
  254. uni.hideLoading()
  255. if (res.code === 200 && res.data) {
  256. this.taskList = res.data.list || this.getDefaultData()
  257. } else {
  258. this.taskList = this.getDefaultData()
  259. }
  260. } catch (e) {
  261. uni.hideLoading()
  262. console.error('加载数据失败', e)
  263. this.taskList = this.getDefaultData()
  264. }
  265. },
  266. async loadMore() {
  267. // 加载更多数据
  268. },
  269. getDefaultData() {
  270. return [
  271. {
  272. id: 1,
  273. title: '王小明医生空中任务',
  274. videoType: '长视频',
  275. category: '学术',
  276. points: '10',
  277. count: '1',
  278. startTime: '2025-9-20 13:55',
  279. endTime: '2025-9-20 13:55',
  280. createTime: '2025-9-20 13:55',
  281. status: 'pending',
  282. statusText: '待完成'
  283. },
  284. {
  285. id: 2,
  286. title: '王小明医生空中任务',
  287. videoType: '长视频',
  288. category: '学术',
  289. points: '10',
  290. count: '1',
  291. startTime: '2025-9-20 13:55',
  292. endTime: '2025-9-20 13:55',
  293. createTime: '2025-9-20 13:55',
  294. status: 'pending',
  295. statusText: '待完成',
  296. warning: '有效观看不足5人'
  297. },
  298. {
  299. id: 3,
  300. title: '王小明医生空中任务',
  301. videoType: '短视频',
  302. category: '学术',
  303. points: '10',
  304. count: '1',
  305. startTime: '2025-9-20 13:55',
  306. endTime: '2025-9-20 13:55',
  307. createTime: '2025-9-20 13:55',
  308. status: 'reviewing',
  309. statusText: '待审核'
  310. },
  311. {
  312. id: 4,
  313. title: '王小明医生空中任务',
  314. videoType: '文章',
  315. category: '学术',
  316. points: '10',
  317. count: '1',
  318. startTime: '2025-9-20 13:55',
  319. endTime: '2025-9-20 13:55',
  320. createTime: '2025-9-20 13:55',
  321. status: 'rejected',
  322. statusText: '已驳回',
  323. rejectionReason: '交付物无效,请重新编辑'
  324. },
  325. {
  326. id: 5,
  327. title: '王小明医生空中任务',
  328. videoType: '长视频',
  329. category: '学术',
  330. points: '10',
  331. count: '1',
  332. startTime: '2025-9-20 13:55',
  333. endTime: '2025-9-20 13:55',
  334. createTime: '2025-9-20 13:55',
  335. status: 'approved',
  336. statusText: '已通过'
  337. }
  338. ]
  339. }
  340. }
  341. }
  342. </script>
  343. <style lang="scss" scoped>
  344. .container {
  345. min-height: 100vh;
  346. background: #f5f5f5;
  347. display: flex;
  348. flex-direction: column;
  349. }
  350. .status-bar {
  351. width: 100%;
  352. background: #fff;
  353. }
  354. .header {
  355. position: relative;
  356. height: 88rpx;
  357. display: flex;
  358. align-items: center;
  359. justify-content: center;
  360. background: #fff;
  361. border-bottom: 1rpx solid #f0f0f0;
  362. .back-btn {
  363. position: absolute;
  364. left: 24rpx;
  365. width: 40rpx;
  366. height: 40rpx;
  367. image {
  368. width: 100%;
  369. height: 100%;
  370. }
  371. }
  372. .title {
  373. font-size: 36rpx;
  374. font-weight: bold;
  375. color: #333;
  376. }
  377. .header-right {
  378. position: absolute;
  379. right: 24rpx;
  380. display: flex;
  381. align-items: center;
  382. gap: 16rpx;
  383. .more-icon {
  384. font-size: 32rpx;
  385. color: #333;
  386. }
  387. }
  388. }
  389. .filter-bar {
  390. display: flex;
  391. align-items: center;
  392. background: #fff;
  393. padding: 0 24rpx;
  394. border-bottom: 1rpx solid #f0f0f0;
  395. .filter-tabs {
  396. flex: 1;
  397. display: flex;
  398. align-items: center;
  399. gap: 32rpx;
  400. overflow-x: auto;
  401. .tab-item {
  402. padding: 24rpx 0;
  403. font-size: 28rpx;
  404. color: #666;
  405. white-space: nowrap;
  406. position: relative;
  407. &.active {
  408. color: #388BFF;
  409. font-weight: bold;
  410. &::after {
  411. content: '';
  412. position: absolute;
  413. bottom: 0;
  414. left: 0;
  415. right: 0;
  416. height: 4rpx;
  417. background: #388BFF;
  418. }
  419. }
  420. }
  421. }
  422. .filter-divider {
  423. width: 1rpx;
  424. height: 40rpx;
  425. background: #e0e0e0;
  426. margin: 0 16rpx;
  427. }
  428. .filter-btn {
  429. padding: 24rpx 0;
  430. .filter-icon {
  431. font-size: 32rpx;
  432. color: #333;
  433. }
  434. }
  435. }
  436. .content {
  437. flex: 1;
  438. padding: 24rpx;
  439. box-sizing: border-box;
  440. }
  441. .task-card {
  442. background: #fff;
  443. border-radius: 16rpx;
  444. padding: 24rpx;
  445. margin-bottom: 24rpx;
  446. .card-header {
  447. display: flex;
  448. align-items: flex-start;
  449. justify-content: space-between;
  450. margin-bottom: 16rpx;
  451. .card-title {
  452. flex: 1;
  453. font-size: 32rpx;
  454. font-weight: bold;
  455. color: #333;
  456. }
  457. .status-tag {
  458. padding: 8rpx 16rpx;
  459. border-radius: 20rpx;
  460. font-size: 24rpx;
  461. &.pending {
  462. background: #E3F2FD;
  463. color: #2196F3;
  464. }
  465. &.reviewing {
  466. background: #FFF3E0;
  467. color: #FF9800;
  468. }
  469. &.approved {
  470. background: #E8F5E9;
  471. color: #4CAF50;
  472. }
  473. &.rejected {
  474. background: #FFEBEE;
  475. color: #F44336;
  476. }
  477. }
  478. }
  479. .card-tags {
  480. display: flex;
  481. align-items: center;
  482. flex-wrap: wrap;
  483. gap: 12rpx;
  484. margin-bottom: 16rpx;
  485. .tag-item {
  486. padding: 8rpx 16rpx;
  487. background: #f5f5f5;
  488. border-radius: 8rpx;
  489. font-size: 24rpx;
  490. color: #666;
  491. &.video-tag {
  492. background: #FFF3E0;
  493. color: #FF9800;
  494. .tag-icon {
  495. margin-right: 4rpx;
  496. }
  497. }
  498. &.points-tag {
  499. border: 1rpx solid #388BFF;
  500. color: #388BFF;
  501. background: transparent;
  502. }
  503. }
  504. }
  505. .card-dates {
  506. margin-bottom: 16rpx;
  507. .date-item {
  508. font-size: 26rpx;
  509. color: #999;
  510. margin-bottom: 8rpx;
  511. }
  512. }
  513. .card-warning {
  514. display: flex;
  515. align-items: center;
  516. gap: 8rpx;
  517. padding: 12rpx;
  518. background: #FFF3E0;
  519. border-radius: 8rpx;
  520. margin-bottom: 16rpx;
  521. font-size: 26rpx;
  522. color: #FF9800;
  523. .warning-icon {
  524. font-size: 28rpx;
  525. }
  526. }
  527. .card-rejection {
  528. display: flex;
  529. align-items: center;
  530. gap: 8rpx;
  531. padding: 12rpx;
  532. background: #FFEBEE;
  533. border-radius: 8rpx;
  534. margin-bottom: 16rpx;
  535. font-size: 26rpx;
  536. color: #F44336;
  537. .rejection-icon {
  538. font-size: 28rpx;
  539. }
  540. }
  541. .card-footer {
  542. display: flex;
  543. align-items: center;
  544. justify-content: space-between;
  545. padding-top: 16rpx;
  546. border-top: 1rpx solid #f0f0f0;
  547. .footer-date {
  548. font-size: 24rpx;
  549. color: #999;
  550. }
  551. .footer-actions {
  552. .action-btn {
  553. padding: 12rpx 32rpx;
  554. background: #388BFF;
  555. border-radius: 8rpx;
  556. font-size: 28rpx;
  557. color: #fff;
  558. }
  559. }
  560. }
  561. }
  562. .filter-popup {
  563. position: fixed;
  564. top: 0;
  565. left: 0;
  566. right: 0;
  567. bottom: 0;
  568. background: rgba(0, 0, 0, 0.5);
  569. z-index: 999;
  570. display: flex;
  571. align-items: flex-end;
  572. }
  573. .filter-content {
  574. width: 100%;
  575. background: #fff;
  576. border-radius: 24rpx 24rpx 0 0;
  577. padding: 24rpx;
  578. .filter-header {
  579. display: flex;
  580. align-items: center;
  581. justify-content: space-between;
  582. margin-bottom: 32rpx;
  583. .filter-title {
  584. font-size: 32rpx;
  585. font-weight: bold;
  586. color: #333;
  587. }
  588. .filter-close-btn {
  589. width: 48rpx;
  590. height: 48rpx;
  591. display: flex;
  592. align-items: center;
  593. justify-content: center;
  594. font-size: 40rpx;
  595. color: #999;
  596. }
  597. }
  598. .filter-group {
  599. margin-bottom: 32rpx;
  600. .group-label {
  601. font-size: 28rpx;
  602. font-weight: bold;
  603. color: #333;
  604. margin-bottom: 20rpx;
  605. }
  606. .date-range-inputs {
  607. display: flex;
  608. align-items: center;
  609. gap: 16rpx;
  610. .date-input {
  611. flex: 1;
  612. height: 80rpx;
  613. line-height: 80rpx;
  614. padding: 0 24rpx;
  615. background: #f5f5f5;
  616. border-radius: 8rpx;
  617. font-size: 28rpx;
  618. color: #333;
  619. text-align: center;
  620. &.placeholder {
  621. color: #999;
  622. }
  623. }
  624. .date-separator {
  625. font-size: 28rpx;
  626. color: #666;
  627. }
  628. }
  629. .filter-tags {
  630. display: flex;
  631. flex-wrap: wrap;
  632. gap: 16rpx;
  633. .filter-tag {
  634. padding: 12rpx 24rpx;
  635. background: #f5f5f5;
  636. border-radius: 8rpx;
  637. font-size: 26rpx;
  638. color: #666;
  639. border: 1rpx solid transparent;
  640. &.active {
  641. background: #388BFF;
  642. color: #fff;
  643. border-color: #388BFF;
  644. }
  645. }
  646. }
  647. }
  648. .filter-actions {
  649. display: flex;
  650. gap: 24rpx;
  651. margin-top: 40rpx;
  652. padding-top: 24rpx;
  653. border-top: 1rpx solid #f0f0f0;
  654. .reset-btn,
  655. .confirm-btn {
  656. flex: 1;
  657. height: 88rpx;
  658. line-height: 88rpx;
  659. text-align: center;
  660. border-radius: 8rpx;
  661. font-size: 30rpx;
  662. }
  663. .reset-btn {
  664. background: #fff;
  665. color: #666;
  666. border: 1rpx solid #e0e0e0;
  667. }
  668. .confirm-btn {
  669. background: #388BFF;
  670. color: #fff;
  671. }
  672. }
  673. }
  674. </style>