points.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  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. <text class="star-icon">⭐</text>
  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="card-pending">支出待入账: {{ pointsData.pendingExpense || '0.00' }}</view>
  14. <view class="withdraw-btn" @click="goWithdraw">去提现</view>
  15. </view>
  16. </view>
  17. <!-- 筛选和汇总区域 -->
  18. <view class="filter-summary-section">
  19. <view class="filter-row">
  20. <view class="date-picker" @click="showDatePicker = true">
  21. <text>{{ selectedDate }}</text>
  22. <text class="arrow-down">▾</text>
  23. </view>
  24. <view class="type-buttons">
  25. <view class="type-btn" :class="{ active: incomeType === 'income' }" @click="switchType('income')">
  26. 收入
  27. </view>
  28. <view class="type-btn" :class="{ active: incomeType === 'expense' }" @click="switchType('expense')">
  29. 支出
  30. </view>
  31. </view>
  32. <view class="total-amount">
  33. 收入{{ summaryData.totalIncome || '0.00' }}
  34. </view>
  35. </view>
  36. <view class="type-filter" @click="showTypePicker = true">
  37. <text>{{ selectedType || '全部类型' }}</text>
  38. <text class="arrow-down">▾</text>
  39. </view>
  40. </view>
  41. <!-- 交易列表 -->
  42. <view class="transaction-list">
  43. <view class="transaction-item" v-for="(item, index) in transactionList" :key="index">
  44. <view class="item-left">
  45. <view class="item-title">{{ item.title }}</view>
  46. <view class="item-time">{{ item.dateTime }}</view>
  47. </view>
  48. <view class="item-amount" :class="item.type">
  49. {{ item.type === 'income' ? '+' : '-' }}{{ item.amount }}
  50. </view>
  51. </view>
  52. </view>
  53. </scroll-view>
  54. <!-- 日期选择弹窗 -->
  55. <view class="date-picker-popup" v-if="showDatePicker" @click="showDatePicker = false">
  56. <view class="picker-content" @click.stop>
  57. <view class="picker-header">
  58. <view class="picker-cancel" @click="showDatePicker = false">取消</view>
  59. <view class="picker-title">选择年月</view>
  60. <view class="picker-confirm" @click="confirmDate">确定</view>
  61. </view>
  62. <view class="picker-body">
  63. <picker mode="date" fields="month" :value="tempDate" @change="onDateChange">
  64. <view class="picker-item">
  65. <text>{{ tempDate || '请选择年月' }}</text>
  66. </view>
  67. </picker>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- 类型选择弹窗 -->
  72. <view class="type-picker-popup" v-if="showTypePicker" @click="showTypePicker = false">
  73. <view class="picker-content" @click.stop>
  74. <view class="picker-header">
  75. <view class="picker-cancel" @click="showTypePicker = false">取消</view>
  76. <view class="picker-title">选择类型</view>
  77. <view class="picker-confirm" @click="confirmType">确定</view>
  78. </view>
  79. <view class="picker-body">
  80. <view class="picker-item"
  81. :class="{ active: tempType === item.value }"
  82. v-for="(item, index) in typeOptions"
  83. :key="index"
  84. @click="tempType = item.value">
  85. {{ item.label }}
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import { getPointsList, getPointsInfo } from '@/api-js/points'
  94. export default {
  95. data() {
  96. return {
  97. statusBarHeight: uni.getSystemInfoSync().statusBarHeight + 'px',
  98. showDatePicker: false,
  99. showTypePicker: false,
  100. selectedDate: '2025-12',
  101. tempDate: '2025-12',
  102. incomeType: 'income', // income: 收入, expense: 支出
  103. selectedType: '全部类型',
  104. tempType: '全部类型',
  105. typeOptions: [
  106. { label: '全部类型', value: '全部类型' },
  107. { label: '医生座诊', value: '医生座诊' },
  108. { label: '科普讲座', value: '科普讲座' },
  109. { label: '用药调研', value: '用药调研' },
  110. { label: '科普短视频', value: '科普短视频' }
  111. ],
  112. pointsData: {
  113. balance: '320.00',
  114. pendingExpense: '30.00'
  115. },
  116. summaryData: {
  117. totalIncome: '600.00'
  118. },
  119. transactionList: []
  120. }
  121. },
  122. onLoad() {
  123. this.loadData()
  124. },
  125. onReachBottom() {
  126. this.loadMore()
  127. },
  128. methods: {
  129. goBack() {
  130. uni.navigateBack()
  131. },
  132. goWithdraw() {
  133. uni.navigateTo({
  134. url: '/pages/user/withdraw'
  135. })
  136. },
  137. onDateChange(e) {
  138. this.tempDate = e.detail.value
  139. },
  140. confirmDate() {
  141. this.selectedDate = this.tempDate
  142. this.showDatePicker = false
  143. this.loadData()
  144. },
  145. confirmType() {
  146. this.selectedType = this.tempType
  147. this.showTypePicker = false
  148. this.loadData()
  149. },
  150. switchType(type) {
  151. this.incomeType = type
  152. this.loadData()
  153. },
  154. async loadData() {
  155. try {
  156. uni.showLoading({ title: '加载中...' })
  157. const [infoRes, listRes] = await Promise.all([
  158. getPointsInfo(),
  159. getPointsList({
  160. date: this.selectedDate,
  161. type: this.incomeType,
  162. category: this.selectedType === '全部类型' ? '' : this.selectedType,
  163. page: 1,
  164. pageSize: 20
  165. })
  166. ])
  167. uni.hideLoading()
  168. if (infoRes.code === 200 && infoRes.data) {
  169. this.pointsData = {
  170. balance: (infoRes.data.balance || 0).toFixed(2),
  171. pendingExpense: (infoRes.data.pendingExpense || 0).toFixed(2)
  172. }
  173. }
  174. if (listRes.code === 200 && listRes.data) {
  175. this.transactionList = listRes.data.list || this.getDefaultData()
  176. this.summaryData = {
  177. totalIncome: (listRes.data.totalIncome || 0).toFixed(2)
  178. }
  179. } else {
  180. this.transactionList = this.getDefaultData()
  181. }
  182. } catch (e) {
  183. uni.hideLoading()
  184. console.error('加载数据失败', e)
  185. this.transactionList = this.getDefaultData()
  186. }
  187. },
  188. async loadMore() {
  189. // 加载更多数据
  190. },
  191. getDefaultData() {
  192. // 默认数据,根据图片中的示例
  193. return [
  194. { title: '医生座诊', dateTime: '2021-07-29 19:55', amount: '300', type: 'income' },
  195. { title: '科普讲座', dateTime: '2021-07-29 19:55', amount: '300', type: 'income' }
  196. ]
  197. }
  198. }
  199. }
  200. </script>
  201. <style lang="scss" scoped>
  202. .container {
  203. min-height: 100vh;
  204. background: #f5f5f5;
  205. display: flex;
  206. flex-direction: column;
  207. }
  208. .status-bar {
  209. width: 100%;
  210. background: #fff;
  211. }
  212. .header {
  213. position: relative;
  214. height: 88rpx;
  215. display: flex;
  216. align-items: center;
  217. justify-content: center;
  218. background: #fff;
  219. border-bottom: 1rpx solid #f0f0f0;
  220. .back-btn {
  221. position: absolute;
  222. left: 24rpx;
  223. width: 40rpx;
  224. height: 40rpx;
  225. image {
  226. width: 100%;
  227. height: 100%;
  228. }
  229. }
  230. .title {
  231. font-size: 36rpx;
  232. font-weight: bold;
  233. color: #333;
  234. }
  235. .header-right {
  236. position: absolute;
  237. right: 24rpx;
  238. display: flex;
  239. align-items: center;
  240. gap: 16rpx;
  241. .more-icon {
  242. font-size: 32rpx;
  243. color: #333;
  244. }
  245. }
  246. }
  247. .content {
  248. flex: 1;
  249. background: #f5f5f5;
  250. }
  251. .points-card {
  252. position: relative;
  253. margin: 24rpx;
  254. background: linear-gradient(135deg, #FF9800 0%, #FFC107 100%);
  255. border-radius: 24rpx;
  256. padding: 48rpx 32rpx;
  257. overflow: hidden;
  258. .card-decoration {
  259. position: absolute;
  260. top: 20rpx;
  261. right: 20rpx;
  262. width: 120rpx;
  263. height: 120rpx;
  264. background: rgba(255, 255, 255, 0.2);
  265. border-radius: 50%;
  266. display: flex;
  267. align-items: center;
  268. justify-content: center;
  269. .star-icon {
  270. font-size: 60rpx;
  271. }
  272. }
  273. .card-content {
  274. position: relative;
  275. z-index: 1;
  276. .card-label {
  277. font-size: 28rpx;
  278. color: rgba(255, 255, 255, 0.9);
  279. margin-bottom: 16rpx;
  280. }
  281. .card-balance {
  282. font-size: 72rpx;
  283. font-weight: bold;
  284. color: #fff;
  285. margin-bottom: 16rpx;
  286. }
  287. .card-pending {
  288. font-size: 24rpx;
  289. color: rgba(255, 255, 255, 0.8);
  290. margin-bottom: 32rpx;
  291. }
  292. .withdraw-btn {
  293. display: inline-block;
  294. padding: 16rpx 48rpx;
  295. background: #fff;
  296. border-radius: 44rpx;
  297. font-size: 28rpx;
  298. color: #FF9800;
  299. font-weight: 500;
  300. }
  301. }
  302. }
  303. .filter-summary-section {
  304. background: #fff;
  305. margin: 0 24rpx 24rpx;
  306. border-radius: 16rpx;
  307. padding: 24rpx;
  308. .filter-row {
  309. display: flex;
  310. align-items: center;
  311. justify-content: space-between;
  312. margin-bottom: 24rpx;
  313. .date-picker {
  314. display: flex;
  315. align-items: center;
  316. gap: 8rpx;
  317. font-size: 28rpx;
  318. color: #333;
  319. .arrow-down {
  320. font-size: 20rpx;
  321. color: #999;
  322. }
  323. }
  324. .type-buttons {
  325. display: flex;
  326. gap: 16rpx;
  327. .type-btn {
  328. padding: 12rpx 32rpx;
  329. border-radius: 44rpx;
  330. font-size: 26rpx;
  331. background: #f5f5f5;
  332. color: #333;
  333. &.active {
  334. background: #FF9800;
  335. color: #fff;
  336. }
  337. }
  338. }
  339. .total-amount {
  340. font-size: 28rpx;
  341. color: #333;
  342. font-weight: 500;
  343. }
  344. }
  345. .type-filter {
  346. display: flex;
  347. align-items: center;
  348. gap: 8rpx;
  349. font-size: 28rpx;
  350. color: #333;
  351. .arrow-down {
  352. font-size: 20rpx;
  353. color: #999;
  354. }
  355. }
  356. }
  357. .transaction-list {
  358. background: #fff;
  359. margin: 0 24rpx 24rpx;
  360. border-radius: 16rpx;
  361. padding: 24rpx;
  362. }
  363. .transaction-item {
  364. display: flex;
  365. align-items: center;
  366. justify-content: space-between;
  367. padding: 24rpx 0;
  368. border-bottom: 1rpx solid #f0f0f0;
  369. &:last-child {
  370. border-bottom: none;
  371. }
  372. .item-left {
  373. flex: 1;
  374. .item-title {
  375. font-size: 30rpx;
  376. color: #333;
  377. margin-bottom: 8rpx;
  378. }
  379. .item-time {
  380. font-size: 24rpx;
  381. color: #999;
  382. }
  383. }
  384. .item-amount {
  385. font-size: 32rpx;
  386. font-weight: bold;
  387. &.income {
  388. color: #FF5030;
  389. }
  390. &.expense {
  391. color: #333;
  392. }
  393. }
  394. }
  395. .date-picker-popup,
  396. .type-picker-popup {
  397. position: fixed;
  398. top: 0;
  399. left: 0;
  400. right: 0;
  401. bottom: 0;
  402. background: rgba(0, 0, 0, 0.5);
  403. z-index: 999;
  404. display: flex;
  405. align-items: flex-end;
  406. }
  407. .picker-content {
  408. width: 100%;
  409. background: #fff;
  410. border-radius: 24rpx 24rpx 0 0;
  411. .picker-header {
  412. display: flex;
  413. align-items: center;
  414. justify-content: space-between;
  415. padding: 24rpx;
  416. border-bottom: 1rpx solid #f0f0f0;
  417. .picker-cancel {
  418. font-size: 30rpx;
  419. color: #666;
  420. }
  421. .picker-title {
  422. font-size: 32rpx;
  423. font-weight: bold;
  424. color: #333;
  425. }
  426. .picker-confirm {
  427. font-size: 30rpx;
  428. color: #FF9800;
  429. }
  430. }
  431. .picker-body {
  432. padding: 24rpx;
  433. max-height: 600rpx;
  434. overflow-y: auto;
  435. .picker-item {
  436. padding: 24rpx 0;
  437. font-size: 30rpx;
  438. color: #333;
  439. border-bottom: 1rpx solid #f0f0f0;
  440. &:last-child {
  441. border-bottom: none;
  442. }
  443. &.active {
  444. color: #FF9800;
  445. font-weight: bold;
  446. }
  447. }
  448. }
  449. }
  450. </style>