points.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. <template>
  2. <view class="container">
  3. <!-- 状态栏占位 -->
  4. <scroll-view class="content" scroll-y>
  5. <!-- 积分卡片 -->
  6. <view class="points-card">
  7. <view class="card-decoration">
  8. <image class="w194 h166" src="@/static/image/img_bg_card.png" mode=""></image>
  9. </view>
  10. <view class="card-content">
  11. <view class="card-label">积分账户</view>
  12. <view class="card-balance">{{ pointsData.balance || '0.00' }}</view>
  13. <view class="x-bc">
  14. <view class="card-pending">支出待入账: {{ pointsData.pendingExpense || '0.00' }}</view>
  15. <view class="withdraw-btn x-c" @click="goWithdraw">去提现</view>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 筛选和汇总区域 -->
  20. <view class="filter-summary-section">
  21. <view class="filter-row">
  22. <picker mode="date" fields="month" :value="tempDate" @change="onDateChange">
  23. <view class="date-picker" @click="showDatePicker = true">
  24. <text>{{ selectedDate }}</text>
  25. <text class="arrow-down">▾</text>
  26. </view>
  27. </picker>
  28. <view class="total-amount">
  29. 收入{{ summaryData.totalIncome || '0.00' }}
  30. </view>
  31. </view>
  32. <view class="x-bc">
  33. <view class="type-buttons">
  34. <view class="type-btn" :class="{ active: incomeType === 'income' }" @click="switchType('income')">
  35. 收入
  36. </view>
  37. <view class="type-btn" :class="{ active: incomeType === 'expense' }" @click="switchType('expense')">
  38. 支出
  39. </view>
  40. </view>
  41. <view class="type-filter" @click="openTypePicker">
  42. <text>{{ selectedType || '全部类型' }}</text>
  43. <text class="arrow-down">▾</text>
  44. </view>
  45. </view>
  46. <!-- 交易列表 -->
  47. <view class="transaction-list">
  48. <view class="transaction-item" v-for="(item, index) in transactionList" :key="index">
  49. <view class="item-left">
  50. <view class="item-title">{{ item.title }}</view>
  51. <view class="item-time">{{ item.dateTime }}</view>
  52. </view>
  53. <view class="item-amount" :class="item.type">
  54. {{ item.type === 'income' ? '+' : '-' }}{{ item.amount }}
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </scroll-view>
  60. <!-- 任务类型筛选弹窗 -->
  61. <view class="type-picker-popup" v-if="showTypePicker" @click="closeTypePicker">
  62. <view class="picker-content" @click.stop>
  63. <view class="picker-header">
  64. <view class="picker-title">任务类型</view>
  65. <view class="picker-close" @click="closeTypePicker">
  66. <image class="w44 h44" src="@/static/image/icon_cross.png" mode=""></image>
  67. </view>
  68. </view>
  69. <view class="picker-body">
  70. <view class="type-grid">
  71. <view class="type-btn-item"
  72. :class="{ active: tempType === item.value }"
  73. v-for="(item, index) in typeOptions"
  74. :key="index"
  75. @click="tempType = item.value">
  76. {{ item.label }}
  77. </view>
  78. </view>
  79. </view>
  80. <view class="picker-footer">
  81. <view class="footer-btn btn-reset" @click="resetType">重置</view>
  82. <view class="footer-btn btn-confirm" @click="confirmType">确定</view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import { getPointsList, getPointsInfo } from '@/api-js/points'
  90. export default {
  91. data() {
  92. return {
  93. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  94. showDatePicker: false,
  95. showTypePicker: false,
  96. selectedDate: '2025-12',
  97. tempDate: '2025-12',
  98. incomeType: 'income', // income: 收入, expense: 支出
  99. selectedType: '全部类型',
  100. tempType: '全部类型',
  101. typeOptions: [
  102. { label: '全部类型', value: '全部类型' },
  103. { label: '医生坐诊', value: '医生坐诊' },
  104. { label: '科普讲座', value: '科普讲座' },
  105. { label: '学术研究', value: '学术研究' },
  106. { label: '科普文章', value: '科普文章' },
  107. { label: '科普短视频', value: '科普短视频' },
  108. { label: '科普长视频', value: '科普长视频' },
  109. { label: '空中课堂', value: '空中课堂' },
  110. { label: '用药调研', value: '用药调研' },
  111. { label: '问卷调研', value: '问卷调研' },
  112. { label: '社群咨询', value: '社群咨询' },
  113. { label: '健康问答', value: '健康问答' },
  114. { label: '受试者随访', value: '受试者随访' },
  115. { label: '受试者招募', value: '受试者招募' }
  116. ],
  117. pointsData: {
  118. balance: '320.00',
  119. pendingExpense: '30.00'
  120. },
  121. summaryData: {
  122. totalIncome: '600.00'
  123. },
  124. transactionList: []
  125. }
  126. },
  127. onLoad() {
  128. this.loadData()
  129. },
  130. onReachBottom() {
  131. this.loadMore()
  132. },
  133. methods: {
  134. goBack() {
  135. uni.navigateBack()
  136. },
  137. goWithdraw() {
  138. uni.navigateTo({
  139. url: '/pages_user/withdraw'
  140. })
  141. },
  142. onDateChange(e) {
  143. this.selectedDate = e.detail.value
  144. this.loadData()
  145. },
  146. // confirmDate() {
  147. // this.selectedDate = this.tempDate
  148. // this.showDatePicker = false
  149. // this.loadData()
  150. // },
  151. closeTypePicker() {
  152. this.showTypePicker = false
  153. // 关闭时恢复临时选择
  154. this.tempType = this.selectedType
  155. },
  156. resetType() {
  157. this.tempType = '全部类型'
  158. },
  159. confirmType() {
  160. this.selectedType = this.tempType
  161. this.showTypePicker = false
  162. this.loadData()
  163. },
  164. switchType(type) {
  165. this.incomeType = type
  166. this.loadData()
  167. },
  168. openTypePicker() {
  169. this.tempType = this.selectedType
  170. this.showTypePicker = true
  171. },
  172. async loadData() {
  173. try {
  174. uni.showLoading({ title: '加载中...' })
  175. const [infoRes, listRes] = await Promise.all([
  176. getPointsInfo(),
  177. getPointsList({
  178. date: this.selectedDate,
  179. type: this.incomeType,
  180. category: this.selectedType === '全部类型' ? '' : this.selectedType,
  181. page: 1,
  182. pageSize: 20
  183. })
  184. ])
  185. uni.hideLoading()
  186. if (infoRes.code === 200 && infoRes.data) {
  187. this.pointsData = {
  188. balance: (infoRes.data.balance || 0).toFixed(2),
  189. pendingExpense: (infoRes.data.pendingExpense || 0).toFixed(2)
  190. }
  191. }
  192. if (listRes.code === 200 && listRes.data) {
  193. this.transactionList = listRes.data.list || this.getDefaultData()
  194. this.summaryData = {
  195. totalIncome: (listRes.data.totalIncome || 0).toFixed(2)
  196. }
  197. } else {
  198. this.transactionList = this.getDefaultData()
  199. }
  200. } catch (e) {
  201. uni.hideLoading()
  202. console.error('加载数据失败', e)
  203. this.transactionList = this.getDefaultData()
  204. }
  205. },
  206. async loadMore() {
  207. // 加载更多数据
  208. },
  209. getDefaultData() {
  210. // 默认数据,根据图片中的示例
  211. return [
  212. { title: '医生座诊', dateTime: '2021-07-29 19:55', amount: '300', type: 'income' },
  213. { title: '科普讲座', dateTime: '2021-07-29 19:55', amount: '300', type: 'income' }
  214. ]
  215. }
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. .container {
  221. min-height: 100vh;
  222. background: #f5f5f5;
  223. display: flex;
  224. flex-direction: column;
  225. }
  226. .status-bar {
  227. width: 100%;
  228. background: #fff;
  229. }
  230. .header {
  231. position: relative;
  232. height: 88rpx;
  233. display: flex;
  234. align-items: center;
  235. justify-content: center;
  236. background: #fff;
  237. border-bottom: 1rpx solid #f0f0f0;
  238. .back-btn {
  239. position: absolute;
  240. left: 24rpx;
  241. width: 40rpx;
  242. height: 40rpx;
  243. image {
  244. width: 100%;
  245. height: 100%;
  246. }
  247. }
  248. .title {
  249. font-size: 36rpx;
  250. font-weight: bold;
  251. color: #333;
  252. }
  253. .header-right {
  254. position: absolute;
  255. right: 24rpx;
  256. display: flex;
  257. align-items: center;
  258. gap: 16rpx;
  259. .more-icon {
  260. font-size: 32rpx;
  261. color: #333;
  262. }
  263. }
  264. }
  265. .content {
  266. flex: 1;
  267. background: #f5f5f5;
  268. }
  269. .points-card {
  270. position: relative;
  271. margin: 24rpx;
  272. height: 280rpx;
  273. background: linear-gradient(135deg, #FF9800 0%, #FFC107 100%);
  274. border-radius: 24rpx;
  275. padding: 48rpx 40rpx;
  276. overflow: hidden;
  277. .card-decoration {
  278. position: absolute;
  279. top: 0;
  280. right: 0;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. .star-icon {
  285. font-size: 60rpx;
  286. }
  287. }
  288. .card-content {
  289. position: relative;
  290. z-index: 1;
  291. height: 100%;
  292. display: flex;
  293. flex-direction: column;
  294. justify-content: space-around;
  295. .card-label {
  296. font-family: PingFang SC, PingFang SC;
  297. font-weight: 500;
  298. font-size: 32rpx;
  299. color: #583504;
  300. }
  301. .card-balance {
  302. font-family: PingFang SC, PingFang SC;
  303. font-weight: 600;
  304. font-size: 48rpx;
  305. color: #583504;
  306. }
  307. .card-pending {
  308. font-family: PingFang SC, PingFang SC;
  309. font-weight: 400;
  310. font-size: 28rpx;
  311. color: #583504;
  312. // margin-bottom: 32rpx;
  313. }
  314. .withdraw-btn {
  315. width: 164rpx;
  316. height: 64rpx;
  317. background: rgba(255,255,255,0.4);
  318. border-radius: 34rpx 34rpx 34rpx 34rpx;
  319. border: 2rpx solid #FFFFFF;
  320. font-family: PingFang SC, PingFang SC;
  321. font-weight: 500;
  322. font-size: 28rpx;
  323. color: #583504;
  324. }
  325. }
  326. }
  327. .filter-summary-section {
  328. background: #fff;
  329. margin: 0 24rpx;
  330. border-radius: 16rpx;
  331. padding: 40rpx 32rpx;
  332. .type-buttons {
  333. display: flex;
  334. gap: 16rpx;
  335. .type-btn {
  336. padding: 12rpx 32rpx;
  337. border-radius: 30rpx;
  338. font-size: 26rpx;
  339. background: #F7F8FA;
  340. color:#666666;
  341. &.active {
  342. background: rgba(250,171,12,0.2);
  343. color:#F08112;
  344. }
  345. }
  346. }
  347. .filter-row {
  348. display: flex;
  349. align-items: center;
  350. justify-content: space-between;
  351. margin-bottom: 24rpx;
  352. .date-picker {
  353. display: flex;
  354. align-items: center;
  355. gap: 8rpx;
  356. font-size: 28rpx;
  357. color: #333;
  358. .arrow-down {
  359. font-size: 20rpx;
  360. color: #999;
  361. }
  362. }
  363. .total-amount {
  364. font-size: 28rpx;
  365. color: #333;
  366. font-weight: 500;
  367. }
  368. }
  369. .type-filter {
  370. display: flex;
  371. align-items: center;
  372. gap: 8rpx;
  373. font-size: 28rpx;
  374. color: #333;
  375. .arrow-down {
  376. font-size: 20rpx;
  377. color: #999;
  378. }
  379. }
  380. }
  381. .transaction-list {
  382. background: #fff;
  383. // margin: 0 24rpx 24rpx;
  384. border-radius: 16rpx;
  385. padding: 24rpx;
  386. }
  387. .transaction-item {
  388. display: flex;
  389. align-items: center;
  390. justify-content: space-between;
  391. padding: 24rpx 0;
  392. border-bottom: 1rpx solid #f0f0f0;
  393. &:last-child {
  394. border-bottom: none;
  395. }
  396. .item-left {
  397. flex: 1;
  398. .item-title {
  399. font-size: 30rpx;
  400. color: #333;
  401. margin-bottom: 16rpx;
  402. }
  403. .item-time {
  404. font-size: 24rpx;
  405. color: #999;
  406. }
  407. }
  408. .item-amount {
  409. font-size: 32rpx;
  410. font-weight: 500;
  411. &.income {
  412. color: #333333;
  413. }
  414. &.expense {
  415. color: #333;
  416. }
  417. }
  418. }
  419. .date-picker-popup {
  420. position: fixed;
  421. top: 0;
  422. left: 0;
  423. right: 0;
  424. bottom: 0;
  425. background: rgba(0, 0, 0, 0.5);
  426. z-index: 999;
  427. display: flex;
  428. align-items: flex-end;
  429. }
  430. .type-picker-popup {
  431. position: fixed;
  432. top: 0;
  433. left: 0;
  434. right: 0;
  435. bottom: 0;
  436. background: rgba(0, 0, 0, 0.5);
  437. z-index: 999;
  438. display: flex;
  439. align-items: flex-end;
  440. }
  441. .picker-content {
  442. width: 100%;
  443. background: #fff;
  444. border-radius: 24rpx 24rpx 0 0;
  445. max-height: 80vh;
  446. display: flex;
  447. flex-direction: column;
  448. .picker-header {
  449. display: flex;
  450. align-items: center;
  451. justify-content: center;
  452. padding: 32rpx 24rpx;
  453. position: relative;
  454. .picker-cancel {
  455. font-size: 30rpx;
  456. color: #666;
  457. }
  458. .picker-title {
  459. font-family: PingFang SC, PingFang SC;
  460. font-weight: 500;
  461. font-size: 32rpx;
  462. color: #333333;
  463. }
  464. .picker-close {
  465. position: absolute;
  466. right: 24rpx;
  467. top: 50%;
  468. transform: translateY(-50%);
  469. font-size: 48rpx;
  470. color: #999;
  471. width: 48rpx;
  472. height: 48rpx;
  473. display: flex;
  474. align-items: center;
  475. justify-content: center;
  476. line-height: 1;
  477. }
  478. .picker-confirm {
  479. font-size: 30rpx;
  480. color: #FF9800;
  481. }
  482. }
  483. .picker-body {
  484. flex: 1;
  485. padding: 32rpx 24rpx;
  486. overflow-y: auto;
  487. .type-grid {
  488. display: flex;
  489. flex-wrap: wrap;
  490. gap: 20rpx;
  491. .type-btn-item {
  492. padding: 14rpx 0;
  493. border-radius:70rpx;
  494. font-size: 28rpx;
  495. color: #333;
  496. background: #F7F8FA;
  497. border: 2rpx solid transparent;
  498. width: calc((100% - 60rpx)/3);
  499. text-align: center;
  500. &.active {
  501. background: rgba(56,139,255,0.15);
  502. border-color: #388BFF;
  503. color: #388BFF;
  504. }
  505. }
  506. }
  507. .picker-item {
  508. padding: 24rpx 0;
  509. font-size: 30rpx;
  510. color: #333;
  511. border-bottom: 1rpx solid #f0f0f0;
  512. &:last-child {
  513. border-bottom: none;
  514. }
  515. &.active {
  516. color: #FF9800;
  517. font-weight: bold;
  518. }
  519. }
  520. }
  521. .picker-footer {
  522. display: flex;
  523. gap: 24rpx;
  524. padding: 24rpx;
  525. margin-bottom: 40rpx;
  526. .footer-btn {
  527. flex: 1;
  528. height: 88rpx;
  529. display: flex;
  530. align-items: center;
  531. justify-content: center;
  532. border-radius: 200rpx 200rpx 200rpx 200rpx;
  533. font-family: PingFang SC, PingFang SC;
  534. font-weight: 400;
  535. font-size: 28rpx;
  536. color: #FFFFFF;
  537. &.btn-reset {
  538. background: #fff;
  539. border: 2rpx solid #388BFF;
  540. color: #388BFF;
  541. }
  542. &.btn-confirm {
  543. background: #388BFF;
  544. color: #fff;
  545. }
  546. }
  547. }
  548. }
  549. </style>