points.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  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. pageNum: this.pageNum,
  205. pageSize: this.pageSize,
  206. changeType: this.incomeType,
  207. ...(businessType && { businessType })
  208. })
  209. if (!silent) {
  210. uni.hideLoading()
  211. }
  212. if (listRes.code === 200 && listRes.data) {
  213. if (this.pageNum === 1) {
  214. // 第一页,直接替换
  215. this.transactionList = listRes.data.doctorBalanceLogs || []
  216. } else {
  217. // 后续页,追加数据
  218. this.transactionList = [...this.transactionList, ...(listRes.data.doctorBalanceLogs || [])]
  219. }
  220. this.summaryData = {
  221. totalIncome: (listRes.data.total || 0).toFixed(2)
  222. }
  223. // 判断是否还有更多数据
  224. if (!listRes.data.doctorBalanceLogs || listRes.data.doctorBalanceLogs.length < this.pageSize) {
  225. this.hasMore = false
  226. }
  227. } else {
  228. if (this.pageNum === 1) {
  229. this.transactionList = []
  230. }
  231. this.hasMore = false
  232. }
  233. } catch (e) {
  234. if (!silent) {
  235. uni.hideLoading()
  236. }
  237. console.error('加载列表失败', e)
  238. if (this.pageNum === 1) {
  239. this.transactionList = []
  240. }
  241. this.hasMore = false
  242. }
  243. },
  244. async loadTypeOptions() {
  245. // 加载积分类型选项
  246. try {
  247. const res = await getPointsTypeOptions({dictType:"credit_flow_type"})
  248. if (res.code === 200 && res.data && Array.isArray(res.data)) {
  249. // 更新类型选项列表
  250. this.typeOptions = [
  251. { label: '全部类型', value: '' },
  252. ...res.data.map(item => ({
  253. label: item.dictLabel,
  254. value: item.dictValue
  255. }))
  256. ]
  257. }
  258. } catch (e) {
  259. console.error('加载积分类型选项失败', e)
  260. }
  261. },
  262. async loadMore() {
  263. if (!this.hasMore || this.loading) return
  264. try {
  265. this.loading = true
  266. this.pageNum = this.pageNum + 1
  267. await this.loadList(true) // 静默加载,不显示loading
  268. } catch (e) {
  269. console.error('加载更多数据失败', e)
  270. } finally {
  271. this.loading = false
  272. }
  273. }
  274. }
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. .container {
  279. min-height: 100vh;
  280. background: #f5f5f5;
  281. display: flex;
  282. flex-direction: column;
  283. }
  284. .status-bar {
  285. width: 100%;
  286. background: #fff;
  287. }
  288. .header {
  289. position: relative;
  290. height: 88rpx;
  291. display: flex;
  292. align-items: center;
  293. justify-content: center;
  294. background: #fff;
  295. border-bottom: 1rpx solid #f0f0f0;
  296. .back-btn {
  297. position: absolute;
  298. left: 24rpx;
  299. width: 40rpx;
  300. height: 40rpx;
  301. image {
  302. width: 100%;
  303. height: 100%;
  304. }
  305. }
  306. .title {
  307. font-size: 36rpx;
  308. font-weight: bold;
  309. color: #333;
  310. }
  311. .header-right {
  312. position: absolute;
  313. right: 24rpx;
  314. display: flex;
  315. align-items: center;
  316. gap: 16rpx;
  317. .more-icon {
  318. font-size: 32rpx;
  319. color: #333;
  320. }
  321. }
  322. }
  323. .content {
  324. flex: 1;
  325. background: #f5f5f5;
  326. }
  327. .points-card {
  328. position: relative;
  329. margin: 24rpx;
  330. height: 280rpx;
  331. background: linear-gradient( 81deg, #FFDF87 0%, #FFB042 100%);
  332. border-radius: 24rpx;
  333. padding: 48rpx 40rpx;
  334. overflow: hidden;
  335. .card-decoration {
  336. position: absolute;
  337. top: 0;
  338. right: 0;
  339. display: flex;
  340. align-items: center;
  341. justify-content: center;
  342. .star-icon {
  343. font-size: 60rpx;
  344. }
  345. }
  346. .card-content {
  347. position: relative;
  348. z-index: 1;
  349. height: 100%;
  350. display: flex;
  351. flex-direction: column;
  352. justify-content: space-around;
  353. .card-label {
  354. font-family: PingFang SC, PingFang SC;
  355. font-weight: 500;
  356. font-size: 32rpx;
  357. color: #583504;
  358. }
  359. .card-balance {
  360. font-family: PingFang SC, PingFang SC;
  361. font-weight: 600;
  362. font-size: 48rpx;
  363. color: #583504;
  364. }
  365. .card-pending {
  366. font-family: PingFang SC, PingFang SC;
  367. font-weight: 400;
  368. font-size: 28rpx;
  369. color: #583504;
  370. // margin-bottom: 32rpx;
  371. }
  372. .withdraw-btn {
  373. width: 164rpx;
  374. height: 64rpx;
  375. background: rgba(255,255,255,0.4);
  376. border-radius: 34rpx 34rpx 34rpx 34rpx;
  377. border: 2rpx solid #FFFFFF;
  378. font-family: PingFang SC, PingFang SC;
  379. font-weight: 500;
  380. font-size: 28rpx;
  381. color: #583504;
  382. }
  383. }
  384. }
  385. .filter-summary-section {
  386. background: #fff;
  387. margin: 0 24rpx;
  388. border-radius: 16rpx;
  389. padding: 40rpx 32rpx;
  390. .type-buttons {
  391. display: flex;
  392. gap: 16rpx;
  393. .type-btn {
  394. padding: 12rpx 32rpx;
  395. border-radius: 30rpx;
  396. font-size: 26rpx;
  397. background: #F7F8FA;
  398. color:#666666;
  399. &.active {
  400. background: rgba(250,171,12,0.2);
  401. color:#F08112;
  402. }
  403. }
  404. }
  405. .filter-row {
  406. display: flex;
  407. align-items: center;
  408. justify-content: space-between;
  409. margin-bottom: 24rpx;
  410. .date-picker {
  411. display: flex;
  412. align-items: center;
  413. gap: 8rpx;
  414. font-size: 28rpx;
  415. color: #333;
  416. .arrow-down {
  417. font-size: 20rpx;
  418. color: #999;
  419. }
  420. }
  421. .total-amount {
  422. font-size: 28rpx;
  423. color: #333;
  424. font-weight: 500;
  425. }
  426. }
  427. .type-filter {
  428. display: flex;
  429. align-items: center;
  430. gap: 8rpx;
  431. font-size: 28rpx;
  432. color: #333;
  433. .arrow-down {
  434. font-size: 20rpx;
  435. color: #999;
  436. }
  437. }
  438. }
  439. .transaction-list {
  440. background: #fff;
  441. // margin: 0 24rpx 24rpx;
  442. border-radius: 16rpx;
  443. padding: 24rpx;
  444. .no-more {
  445. text-align: center;
  446. padding: 48rpx 0;
  447. font-size: 24rpx;
  448. color: #999;
  449. }
  450. }
  451. .transaction-item {
  452. display: flex;
  453. align-items: center;
  454. justify-content: space-between;
  455. padding: 24rpx 0;
  456. border-bottom: 1rpx solid #f0f0f0;
  457. &:last-child {
  458. border-bottom: none;
  459. }
  460. .item-left {
  461. flex: 1;
  462. .item-title {
  463. font-size: 30rpx;
  464. color: #333;
  465. margin-bottom: 16rpx;
  466. }
  467. .item-time {
  468. font-size: 24rpx;
  469. color: #999;
  470. }
  471. }
  472. .item-amount {
  473. font-size: 32rpx;
  474. font-weight: 500;
  475. &.income {
  476. color: #333333;
  477. }
  478. &.expense {
  479. color: #333;
  480. }
  481. }
  482. }
  483. .date-picker-popup {
  484. position: fixed;
  485. top: 0;
  486. left: 0;
  487. right: 0;
  488. bottom: 0;
  489. background: rgba(0, 0, 0, 0.5);
  490. z-index: 999;
  491. display: flex;
  492. align-items: flex-end;
  493. }
  494. .type-picker-popup {
  495. position: fixed;
  496. top: 0;
  497. left: 0;
  498. right: 0;
  499. bottom: 0;
  500. background: rgba(0, 0, 0, 0.5);
  501. z-index: 999;
  502. display: flex;
  503. align-items: flex-end;
  504. }
  505. .picker-content {
  506. width: 100%;
  507. background: #fff;
  508. border-radius: 24rpx 24rpx 0 0;
  509. max-height: 80vh;
  510. display: flex;
  511. flex-direction: column;
  512. .picker-header {
  513. display: flex;
  514. align-items: center;
  515. justify-content: center;
  516. padding: 32rpx 24rpx;
  517. position: relative;
  518. .picker-cancel {
  519. font-size: 30rpx;
  520. color: #666;
  521. }
  522. .picker-title {
  523. font-family: PingFang SC, PingFang SC;
  524. font-weight: 500;
  525. font-size: 32rpx;
  526. color: #333333;
  527. }
  528. .picker-close {
  529. position: absolute;
  530. right: 24rpx;
  531. top: 50%;
  532. transform: translateY(-50%);
  533. font-size: 48rpx;
  534. color: #999;
  535. width: 48rpx;
  536. height: 48rpx;
  537. display: flex;
  538. align-items: center;
  539. justify-content: center;
  540. line-height: 1;
  541. }
  542. .picker-confirm {
  543. font-size: 30rpx;
  544. color: #FF9800;
  545. }
  546. }
  547. .picker-body {
  548. flex: 1;
  549. padding: 32rpx 24rpx;
  550. overflow-y: auto;
  551. .type-grid {
  552. display: flex;
  553. flex-wrap: wrap;
  554. gap: 20rpx;
  555. .type-btn-item {
  556. padding: 14rpx 0;
  557. border-radius:70rpx;
  558. font-size: 28rpx;
  559. color: #333;
  560. background: #F7F8FA;
  561. border: 2rpx solid transparent;
  562. width: calc((100% - 60rpx)/3);
  563. text-align: center;
  564. &.active {
  565. background: rgba(56,139,255,0.15);
  566. border-color: #388BFF;
  567. color: #388BFF;
  568. }
  569. }
  570. }
  571. .picker-item {
  572. padding: 24rpx 0;
  573. font-size: 30rpx;
  574. color: #333;
  575. border-bottom: 1rpx solid #f0f0f0;
  576. &:last-child {
  577. border-bottom: none;
  578. }
  579. &.active {
  580. color: #FF9800;
  581. font-weight: bold;
  582. }
  583. }
  584. }
  585. .picker-footer {
  586. display: flex;
  587. gap: 24rpx;
  588. padding: 24rpx;
  589. margin-bottom: 40rpx;
  590. .footer-btn {
  591. flex: 1;
  592. height: 88rpx;
  593. display: flex;
  594. align-items: center;
  595. justify-content: center;
  596. border-radius: 200rpx 200rpx 200rpx 200rpx;
  597. font-family: PingFang SC, PingFang SC;
  598. font-weight: 400;
  599. font-size: 28rpx;
  600. color: #FFFFFF;
  601. &.btn-reset {
  602. background: #fff;
  603. border: 2rpx solid #388BFF;
  604. color: #388BFF;
  605. }
  606. &.btn-confirm {
  607. background: #388BFF;
  608. color: #fff;
  609. }
  610. }
  611. }
  612. }
  613. </style>