points.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  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.creditNum || '0.00' }}</view>
  13. <view class="x-bc">
  14. <view class="card-pending">支出待入账: {{ pointsData.waitCreditNum || '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. {{incomeType === 2?"收入":"支出"}}{{ 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 === 2 }" @click="switchType(2)">
  35. 收入
  36. </view>
  37. <view class="type-btn" :class="{ active: incomeType === 1 }" @click="switchType(1)">
  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.doctorName }}</view>
  51. <view class="item-time">{{ item.createAt }}</view>
  52. </view>
  53. <view class="item-amount" :class="item.type">
  54. {{ item.changeType === 2 ? '+' : '-' }}{{ item.changeMoney }}
  55. </view>
  56. </view>
  57. <view class="no-more" v-if="!hasMore && transactionList.length > 0">没有更多了~</view>
  58. </view>
  59. </view>
  60. </scroll-view>
  61. <!-- 任务类型筛选弹窗 -->
  62. <view class="type-picker-popup" v-if="showTypePicker" @click="closeTypePicker">
  63. <view class="picker-content" @click.stop>
  64. <view class="picker-header">
  65. <view class="picker-title">任务类型</view>
  66. <view class="picker-close" @click="closeTypePicker">
  67. <image class="w44 h44" src="@/static/image/icon_cross.png" mode=""></image>
  68. </view>
  69. </view>
  70. <view class="picker-body">
  71. <view class="type-grid">
  72. <view class="type-btn-item"
  73. :class="{ active: tempType === item.value }"
  74. v-for="(item, index) in typeOptions"
  75. :key="index"
  76. @click="tempType = item.value">
  77. {{ item.label }}
  78. </view>
  79. </view>
  80. </view>
  81. <view class="picker-footer">
  82. <view class="footer-btn btn-reset" @click="resetType">重置</view>
  83. <view class="footer-btn btn-confirm" @click="confirmType">确定</view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </template>
  89. <script>
  90. import { getPointsList, getPointsInfo, getPointsTypeOptions, getPointsStatistics } from '@/api/points'
  91. export default {
  92. data() {
  93. return {
  94. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  95. showDatePicker: false,
  96. showTypePicker: false,
  97. selectedDate: '2025-12',
  98. tempDate: '2025-12',
  99. incomeType: 2, // income: 收入, expense: 支出
  100. selectedType: '全部类型',
  101. tempType: '',
  102. typeOptions: [
  103. ],
  104. pointsData: {
  105. },
  106. summaryData: {
  107. totalIncome: '0.00'
  108. },
  109. transactionList: [],
  110. pageNum: 1,
  111. pageSize: 10,
  112. hasMore: true,
  113. loading: false
  114. }
  115. },
  116. onLoad() {
  117. this.loadTypeOptions()
  118. this.initCurrentMonth()
  119. },
  120. onShow() {
  121. this.loadData()
  122. },
  123. onReachBottom() {
  124. this.loadMore()
  125. },
  126. methods: {
  127. // 核心:初始化当前月份
  128. initCurrentMonth() {
  129. const now = new Date();
  130. const year = now.getFullYear();
  131. const month = (now.getMonth() + 1).toString().padStart(2, "0");
  132. this.selectedDate = `${year}-${month}`;
  133. this.tempDate = `${year}-${month}`;
  134. },
  135. goBack() {
  136. uni.navigateBack()
  137. },
  138. goWithdraw() {
  139. uni.navigateTo({
  140. url: '/pages_user/withdraw'
  141. })
  142. },
  143. onDateChange(e) {
  144. this.selectedDate = e.detail.value
  145. this.pageNum = 1
  146. this.hasMore = true
  147. this.loadList()
  148. },
  149. closeTypePicker() {
  150. this.showTypePicker = false
  151. },
  152. resetType() {
  153. this.tempType = ''
  154. },
  155. confirmType() {
  156. // 根据 tempType 找到对应的选项
  157. const selectedOption = this.typeOptions.find(item => item.value === this.tempType)
  158. this.selectedType = selectedOption ? selectedOption.label : '全部类型'
  159. if (!selectedOption) this.tempType = ''
  160. this.showTypePicker = false
  161. this.pageNum = 1
  162. this.hasMore = true
  163. this.loadList()
  164. },
  165. switchType(type) {
  166. this.incomeType = type
  167. this.pageNum = 1
  168. this.hasMore = true
  169. this.loadList()
  170. },
  171. openTypePicker() {
  172. // 根据 selectedType 找到对应的 value 设置给 tempType
  173. const selectedOption = this.typeOptions.find(item => item.label === this.selectedType)
  174. this.tempType = selectedOption ? selectedOption.value : ''
  175. this.showTypePicker = true
  176. },
  177. async loadData() {
  178. try {
  179. this.pageNum = 1
  180. this.hasMore = true
  181. uni.showLoading({ title: '加载中...' })
  182. const [infoRes] = await Promise.all([
  183. getPointsInfo({}),
  184. this.loadList(true) // 不显示loading,因为外层已经显示了
  185. ])
  186. uni.hideLoading()
  187. if (infoRes.code == 200 && infoRes.data) {
  188. this.pointsData = infoRes.data
  189. }
  190. } catch (e) {
  191. uni.hideLoading()
  192. console.error('加载数据失败', e)
  193. }
  194. },
  195. async loadList(silent = false) {
  196. try {
  197. if (!silent) {
  198. uni.showLoading({ title: '加载中...' })
  199. }
  200. // 获取选中的类型值
  201. const businessType = this.selectedType === '全部类型' ? '' :
  202. (this.typeOptions.find(item => item.label === this.selectedType)?.value || '')
  203. const listRes = await getPointsList({
  204. selectTime:this.selectedDate,
  205. pageNum: this.pageNum,
  206. pageSize: this.pageSize,
  207. changeType: this.incomeType,
  208. ...(businessType && { businessType })
  209. })
  210. if (!silent) {
  211. uni.hideLoading()
  212. }
  213. if (listRes.code == 200 && listRes.data) {
  214. if (this.pageNum == 1) {
  215. // 第一页,直接替换
  216. this.transactionList = listRes.data.doctorBalanceLogs || []
  217. } else {
  218. // 后续页,追加数据
  219. this.transactionList = [...this.transactionList, ...(listRes.data.doctorBalanceLogs || [])]
  220. }
  221. this.summaryData = {
  222. totalIncome: (listRes.data.total || 0).toFixed(2)
  223. }
  224. // 判断是否还有更多数据
  225. if (!listRes.data.doctorBalanceLogs || listRes.data.doctorBalanceLogs.length < this.pageSize) {
  226. this.hasMore = false
  227. }
  228. } else {
  229. if (this.pageNum == 1) {
  230. this.transactionList = []
  231. }
  232. this.hasMore = false
  233. }
  234. } catch (e) {
  235. if (!silent) {
  236. uni.hideLoading()
  237. }
  238. console.error('加载列表失败', e)
  239. if (this.pageNum === 1) {
  240. this.transactionList = []
  241. }
  242. this.hasMore = false
  243. }
  244. },
  245. async loadTypeOptions() {
  246. // 加载积分类型选项
  247. try {
  248. const res = await getPointsTypeOptions({dictType:"credit_flow_type"})
  249. if (res.code === 200 && res.data && Array.isArray(res.data)) {
  250. // 更新类型选项列表
  251. this.typeOptions = [
  252. { label: '全部类型', value: '' },
  253. ...res.data.map(item => ({
  254. label: item.dictLabel,
  255. value: item.dictValue
  256. }))
  257. ]
  258. }
  259. } catch (e) {
  260. console.error('加载积分类型选项失败', e)
  261. }
  262. },
  263. async loadMore() {
  264. if (!this.hasMore || this.loading) return
  265. try {
  266. this.loading = true
  267. this.pageNum = this.pageNum + 1
  268. await this.loadList(true) // 静默加载,不显示loading
  269. } catch (e) {
  270. console.error('加载更多数据失败', e)
  271. } finally {
  272. this.loading = false
  273. }
  274. }
  275. }
  276. }
  277. </script>
  278. <style lang="scss" scoped>
  279. .container {
  280. min-height: 100vh;
  281. background: #f5f5f5;
  282. display: flex;
  283. flex-direction: column;
  284. }
  285. .status-bar {
  286. width: 100%;
  287. background: #fff;
  288. }
  289. .header {
  290. position: relative;
  291. height: 88rpx;
  292. display: flex;
  293. align-items: center;
  294. justify-content: center;
  295. background: #fff;
  296. border-bottom: 1rpx solid #f0f0f0;
  297. .back-btn {
  298. position: absolute;
  299. left: 24rpx;
  300. width: 40rpx;
  301. height: 40rpx;
  302. image {
  303. width: 100%;
  304. height: 100%;
  305. }
  306. }
  307. .title {
  308. font-size: 36rpx;
  309. font-weight: bold;
  310. color: #333;
  311. }
  312. .header-right {
  313. position: absolute;
  314. right: 24rpx;
  315. display: flex;
  316. align-items: center;
  317. gap: 16rpx;
  318. .more-icon {
  319. font-size: 32rpx;
  320. color: #333;
  321. }
  322. }
  323. }
  324. .content {
  325. flex: 1;
  326. background: #f5f5f5;
  327. }
  328. .points-card {
  329. position: relative;
  330. margin: 24rpx;
  331. height: 280rpx;
  332. background: linear-gradient( 81deg, #FFDF87 0%, #FFB042 100%);
  333. border-radius: 24rpx;
  334. padding: 48rpx 40rpx;
  335. overflow: hidden;
  336. .card-decoration {
  337. position: absolute;
  338. top: 0;
  339. right: 0;
  340. display: flex;
  341. align-items: center;
  342. justify-content: center;
  343. .star-icon {
  344. font-size: 60rpx;
  345. }
  346. }
  347. .card-content {
  348. position: relative;
  349. z-index: 1;
  350. height: 100%;
  351. display: flex;
  352. flex-direction: column;
  353. justify-content: space-around;
  354. .card-label {
  355. font-family: PingFang SC, PingFang SC;
  356. font-weight: 500;
  357. font-size: 32rpx;
  358. color: #583504;
  359. }
  360. .card-balance {
  361. font-family: PingFang SC, PingFang SC;
  362. font-weight: 600;
  363. font-size: 48rpx;
  364. color: #583504;
  365. }
  366. .card-pending {
  367. font-family: PingFang SC, PingFang SC;
  368. font-weight: 400;
  369. font-size: 28rpx;
  370. color: #583504;
  371. // margin-bottom: 32rpx;
  372. }
  373. .withdraw-btn {
  374. width: 164rpx;
  375. height: 64rpx;
  376. background: rgba(255,255,255,0.4);
  377. border-radius: 34rpx 34rpx 34rpx 34rpx;
  378. border: 2rpx solid #FFFFFF;
  379. font-family: PingFang SC, PingFang SC;
  380. font-weight: 500;
  381. font-size: 28rpx;
  382. color: #583504;
  383. }
  384. }
  385. }
  386. .filter-summary-section {
  387. background: #fff;
  388. margin: 0 24rpx;
  389. border-radius: 16rpx;
  390. padding: 40rpx 32rpx;
  391. .type-buttons {
  392. display: flex;
  393. gap: 16rpx;
  394. .type-btn {
  395. padding: 12rpx 32rpx;
  396. border-radius: 30rpx;
  397. font-size: 26rpx;
  398. background: #F7F8FA;
  399. color:#666666;
  400. &.active {
  401. background: rgba(250,171,12,0.2);
  402. color:#F08112;
  403. }
  404. }
  405. }
  406. .filter-row {
  407. display: flex;
  408. align-items: center;
  409. justify-content: space-between;
  410. margin-bottom: 24rpx;
  411. .date-picker {
  412. display: flex;
  413. align-items: center;
  414. gap: 8rpx;
  415. font-size: 28rpx;
  416. color: #333;
  417. .arrow-down {
  418. font-size: 20rpx;
  419. color: #999;
  420. }
  421. }
  422. .total-amount {
  423. font-size: 28rpx;
  424. color: #333;
  425. font-weight: 500;
  426. }
  427. }
  428. .type-filter {
  429. display: flex;
  430. align-items: center;
  431. gap: 8rpx;
  432. font-size: 28rpx;
  433. color: #333;
  434. .arrow-down {
  435. font-size: 20rpx;
  436. color: #999;
  437. }
  438. }
  439. }
  440. .transaction-list {
  441. background: #fff;
  442. // margin: 0 24rpx 24rpx;
  443. border-radius: 16rpx;
  444. padding: 24rpx;
  445. .no-more {
  446. text-align: center;
  447. padding: 48rpx 0;
  448. font-size: 24rpx;
  449. color: #999;
  450. }
  451. }
  452. .transaction-item {
  453. display: flex;
  454. align-items: center;
  455. justify-content: space-between;
  456. padding: 24rpx 0;
  457. border-bottom: 1rpx solid #f0f0f0;
  458. &:last-child {
  459. border-bottom: none;
  460. }
  461. .item-left {
  462. flex: 1;
  463. .item-title {
  464. font-size: 30rpx;
  465. color: #333;
  466. margin-bottom: 16rpx;
  467. }
  468. .item-time {
  469. font-size: 24rpx;
  470. color: #999;
  471. }
  472. }
  473. .item-amount {
  474. font-size: 32rpx;
  475. font-weight: 500;
  476. &.income {
  477. color: #333333;
  478. }
  479. &.expense {
  480. color: #333;
  481. }
  482. }
  483. }
  484. .date-picker-popup {
  485. position: fixed;
  486. top: 0;
  487. left: 0;
  488. right: 0;
  489. bottom: 0;
  490. background: rgba(0, 0, 0, 0.5);
  491. z-index: 999;
  492. display: flex;
  493. align-items: flex-end;
  494. }
  495. .type-picker-popup {
  496. position: fixed;
  497. top: 0;
  498. left: 0;
  499. right: 0;
  500. bottom: 0;
  501. background: rgba(0, 0, 0, 0.5);
  502. z-index: 999;
  503. display: flex;
  504. align-items: flex-end;
  505. }
  506. .picker-content {
  507. width: 100%;
  508. background: #fff;
  509. border-radius: 24rpx 24rpx 0 0;
  510. max-height: 80vh;
  511. display: flex;
  512. flex-direction: column;
  513. .picker-header {
  514. display: flex;
  515. align-items: center;
  516. justify-content: center;
  517. padding: 32rpx 24rpx;
  518. position: relative;
  519. .picker-cancel {
  520. font-size: 30rpx;
  521. color: #666;
  522. }
  523. .picker-title {
  524. font-family: PingFang SC, PingFang SC;
  525. font-weight: 500;
  526. font-size: 32rpx;
  527. color: #333333;
  528. }
  529. .picker-close {
  530. position: absolute;
  531. right: 24rpx;
  532. top: 50%;
  533. transform: translateY(-50%);
  534. font-size: 48rpx;
  535. color: #999;
  536. width: 48rpx;
  537. height: 48rpx;
  538. display: flex;
  539. align-items: center;
  540. justify-content: center;
  541. line-height: 1;
  542. }
  543. .picker-confirm {
  544. font-size: 30rpx;
  545. color: #FF9800;
  546. }
  547. }
  548. .picker-body {
  549. flex: 1;
  550. padding: 32rpx 24rpx;
  551. overflow-y: auto;
  552. .type-grid {
  553. display: flex;
  554. flex-wrap: wrap;
  555. gap: 20rpx;
  556. .type-btn-item {
  557. padding: 14rpx 0;
  558. border-radius:70rpx;
  559. font-size: 28rpx;
  560. color: #333;
  561. background: #F7F8FA;
  562. border: 2rpx solid transparent;
  563. width: calc((100% - 60rpx)/3);
  564. text-align: center;
  565. &.active {
  566. background: rgba(56,139,255,0.15);
  567. border-color: #388BFF;
  568. color: #388BFF;
  569. }
  570. }
  571. }
  572. .picker-item {
  573. padding: 24rpx 0;
  574. font-size: 30rpx;
  575. color: #333;
  576. border-bottom: 1rpx solid #f0f0f0;
  577. &:last-child {
  578. border-bottom: none;
  579. }
  580. &.active {
  581. color: #FF9800;
  582. font-weight: bold;
  583. }
  584. }
  585. }
  586. .picker-footer {
  587. display: flex;
  588. gap: 24rpx;
  589. padding: 24rpx;
  590. margin-bottom: 40rpx;
  591. .footer-btn {
  592. flex: 1;
  593. height: 88rpx;
  594. display: flex;
  595. align-items: center;
  596. justify-content: center;
  597. border-radius: 200rpx 200rpx 200rpx 200rpx;
  598. font-family: PingFang SC, PingFang SC;
  599. font-weight: 400;
  600. font-size: 28rpx;
  601. color: #FFFFFF;
  602. &.btn-reset {
  603. background: #fff;
  604. border: 2rpx solid #388BFF;
  605. color: #388BFF;
  606. }
  607. &.btn-confirm {
  608. background: #388BFF;
  609. color: #fff;
  610. }
  611. }
  612. }
  613. }
  614. </style>