points.vue 12 KB

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