billPage.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <view class="bill-page">
  3. <!-- 顶部积分信息 -->
  4. <view class="points-header">
  5. <view class="points-item">
  6. <text class="points-label">当前可用积分</text>
  7. <text class="points-value">{{ totalPoints }}</text>
  8. </view>
  9. <view class="points-item">
  10. <text class="points-label">本月获得积分</text>
  11. <text class="points-value">{{ earnedPoints }}</text>
  12. </view>
  13. <view class="points-item">
  14. <text class="points-label">本月即将到期积分</text>
  15. <text class="points-value">{{ expirePoints }}</text>
  16. </view>
  17. </view>
  18. <view class="container">
  19. <!-- 标签切换 -->
  20. <u-tabs
  21. :list="tabs"
  22. :current="categoryIndex"
  23. @change="handleTabChange"
  24. lineWidth="60"
  25. lineColor="#20CAC2"
  26. :activeStyle="{
  27. color: '#303133',
  28. fontWeight: 'bold',
  29. transform: 'scale(1.05)'
  30. }"
  31. :inactiveStyle="{
  32. color: '#606266',
  33. transform: 'scale(1)'
  34. }"
  35. itemStyle="padding:0 85rpx; height: 72rpx;font-size:28rpx"
  36. class="tabs-container"
  37. ></u-tabs>
  38. <!-- 积分记录列表 -->
  39. <view class="records-container">
  40. <u-list @scrolltolower="loadMore" style="height:calc(75vh - 60rpx)">
  41. <u-list-item v-for="(item, index) in filteredRecords" :key="item.id" class="record-item">
  42. <view class="record-info">
  43. <text class="record-description">{{ item.description }}</text>
  44. <text class="record-date">{{ item.date }}</text>
  45. </view>
  46. <text class="record-amount" :class="{ income: item.amount > 0, expense: item.amount < 0 }">
  47. {{ item.amount > 0 ? '+' : '' }}{{ item.amount }}
  48. </text>
  49. </u-list-item>
  50. <!-- 空数据状态 -->
  51. <u-empty
  52. v-if="filteredRecords.length === 0"
  53. icon="document"
  54. text="暂无积分记录"
  55. mode="page"
  56. ></u-empty>
  57. <!-- 加载更多 -->
  58. <u-loadmore
  59. v-if="filteredRecords.length > 0"
  60. :status="loading ? 'loading' : (hasMore ? 'more' : 'nomore')"
  61. loading-text="加载中..."
  62. nomore-text="没有更多记录了"
  63. @loadmore="loadMore"
  64. ></u-loadmore>
  65. </u-list>
  66. </view>
  67. </view>
  68. </view>
  69. </template>
  70. <script>
  71. import {mapState} from "vuex";
  72. export default {
  73. name: "billPage",
  74. data() {
  75. return {
  76. // 标签数据
  77. tabs: [
  78. { key: 'all', name: '明细' },
  79. { key: 'income', name: '收入' },
  80. { key: 'expense', name: '支出' }
  81. ],
  82. // 当前选中的标签
  83. activeTab: 'all',
  84. // 积分记录数据
  85. pointRecords: [
  86. { id: 1, type: 'order', description: '订单消费', amount: 10, date: '2026.10.1 12:22:54' },
  87. { id: 2, type: 'exchange', description: '购物兑换', amount: -10, date: '2026.10.1 12:22:54' },
  88. { id: 3, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
  89. { id: 4, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' },
  90. { id: 5, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
  91. { id: 6, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' },
  92. { id: 7, type: 'order', description: '订单消费', amount: 10, date: '2026.10.1 12:22:54' },
  93. { id: 8, type: 'exchange', description: '购物兑换', amount: -10, date: '2026.10.1 12:22:54' },
  94. { id: 9, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
  95. { id: 10, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' },
  96. { id: 11, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
  97. { id: 12, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' },
  98. { id: 13, type: 'order', description: '订单消费', amount: 10, date: '2026.10.1 12:22:54' },
  99. { id: 14, type: 'exchange', description: '购物兑换', amount: -10, date: '2026.10.1 12:22:54' },
  100. { id: 15, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
  101. { id: 16, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' },
  102. { id: 17, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' },
  103. { id: 18, type: 'reward', description: '好评奖励', amount: -10, date: '2026.10.1 12:22:54' }
  104. ],
  105. // 分页数据
  106. page: 1,
  107. pageSize: 10,
  108. hasMore: true,
  109. loading: false
  110. }
  111. },
  112. computed: {
  113. ...mapState({
  114. myPoint: state => state.points.myPoint
  115. }),
  116. totalPoints() {
  117. return this.myPoint.totalPoints || 0;
  118. },
  119. earnedPoints() {
  120. return this.myPoint.earnedPoints || 0;
  121. },
  122. expirePoints() {
  123. return this.myPoint.expirePoints || 0;
  124. },
  125. categoryIndex() {
  126. return this.tabs.findIndex(item => item.key === this.activeTab)
  127. },
  128. // 过滤后的积分记录
  129. filteredRecords() {
  130. if (this.activeTab === 'all') {
  131. return this.pointRecords
  132. } else if (this.activeTab === 'income') {
  133. return this.pointRecords.filter(record => record.amount > 0)
  134. } else if (this.activeTab === 'expense') {
  135. return this.pointRecords.filter(record => record.amount < 0)
  136. }
  137. }
  138. },
  139. methods: {
  140. // 切换标签
  141. handleTabChange(data) {
  142. this.activeTab = data.key
  143. // 重置分页数据
  144. this.page = 1
  145. this.hasMore = true
  146. // 重置滚动位置
  147. this.$nextTick(() => {
  148. const list = this.$refs.list
  149. if (list) {
  150. list.scrollTo(0, 0)
  151. }
  152. })
  153. },
  154. // 加载更多数据
  155. loadMore() {
  156. if (this.loading || !this.hasMore) return
  157. this.loading = true
  158. this.page++
  159. // 模拟加载数据
  160. setTimeout(() => {
  161. // 模拟新数据
  162. const newRecords = [
  163. { id: this.pointRecords.length + 1, type: 'order', description: '订单消费', amount: 10, date: '2026.10.1 12:22:54' },
  164. { id: this.pointRecords.length + 2, type: 'exchange', description: '购物兑换', amount: -10, date: '2026.10.1 12:22:54' },
  165. { id: this.pointRecords.length + 3, type: 'order', description: '完成订单', amount: 10, date: '2026.10.1 12:22:54' }
  166. ]
  167. // 添加新数据
  168. this.pointRecords = [...this.pointRecords, ...newRecords]
  169. // 模拟没有更多数据
  170. if (this.page >= 3) {
  171. this.hasMore = false
  172. }
  173. this.loading = false
  174. }, 1000)
  175. }
  176. }
  177. }
  178. </script>
  179. <style scoped lang="scss">
  180. .bill-page{
  181. width: 750rpx;
  182. min-height: 100vh;
  183. background-image: url("@/static/points/pointBg.png");
  184. background-size: 100%;
  185. background-repeat: no-repeat;
  186. background-color: #ffe5ca;
  187. padding-top: 62rpx;
  188. }
  189. .points-header{
  190. display: flex;
  191. justify-content: space-around;
  192. margin-bottom: 42rpx;
  193. .points-item{
  194. display: flex;
  195. flex-direction: column;
  196. align-items: center;
  197. .points-label{
  198. font-family: PingFang SC, PingFang SC;
  199. font-weight: 500;
  200. font-size: 24rpx;
  201. color: #FFFFFF;
  202. margin-bottom: 24rpx;
  203. }
  204. .points-value{
  205. font-weight: 500;
  206. font-size: 40rpx;
  207. color: #FFFFFF;
  208. line-height: 32rpx;
  209. }
  210. }
  211. }
  212. .container{
  213. width: 686rpx;
  214. height: 83vh;
  215. background: #FFFFFF;
  216. border-radius: 20rpx;
  217. margin: 0 auto;
  218. padding: 10rpx 0;
  219. .tabs-container{
  220. display: flex;
  221. overflow: hidden;
  222. margin-bottom: 32rpx;
  223. }
  224. }
  225. .records-container{
  226. .record-item{
  227. display: flex;
  228. justify-content: space-between;
  229. align-items: center;
  230. padding: 16rpx 32rpx;
  231. flex-direction: row;
  232. .record-info{
  233. .record-description{
  234. font-family: PingFang SC, PingFang SC;
  235. font-weight: 500;
  236. font-size: 28rpx;
  237. color: #333333;
  238. line-height: 28rpx;
  239. display: block;
  240. margin-bottom: 12rpx;
  241. }
  242. .record-date{
  243. font-family: PingFang SC, PingFang SC;
  244. font-size: 24rpx;
  245. color: #999999;
  246. line-height: 28rpx;
  247. }
  248. }
  249. .record-amount{
  250. font-family: PingFang SC, PingFang SC;
  251. font-weight: 500;
  252. font-size: 28rpx;
  253. line-height: 28rpx;
  254. &.income{
  255. color: #34c7c2;
  256. }
  257. &.expense{
  258. color: #f53e54;
  259. }
  260. }
  261. }
  262. }
  263. </style>