小说小程序前端代码仓库(小程序)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

363 lines
8.0 KiB

  1. <!-- 钱包流水页面 -->
  2. <template>
  3. <view class="walletflow-page">
  4. <!-- 顶部导航栏 -->
  5. <navbar title="钱包流水" leftClick @leftClick="$utils.navigateBack" />
  6. <!-- 账户余额卡片 -->
  7. <view class="balance-card">
  8. <view class="balance-label">账户</view>
  9. <view class="balance-row">
  10. <text class="balance-amount">{{ accountBalance }}</text>
  11. <button class="recharge-btn" @click="goRecharge">充值</button>
  12. </view>
  13. </view>
  14. <!-- tab和流水列表卡片 -->
  15. <view class="flow-card">
  16. <uv-tabs
  17. :list="tabList"
  18. :current="activeTab"
  19. @change="switchTab"
  20. :scrollable="false"
  21. activeColor="#223a7a"
  22. inactiveColor="#888"
  23. lineColor="#223a7a"
  24. lineWidth="44rpx"
  25. lineHeight="4rpx"
  26. :itemStyle="{
  27. height: '88rpx',
  28. fontSize: '30rpx',
  29. fontWeight: 'bold'
  30. }"
  31. ></uv-tabs>
  32. <scroll-view scroll-y class="flow-list" @scrolltolower="loadMore">
  33. <view v-if="activeTab === 0">
  34. <view class="flow-item" v-for="(item, idx) in rechargeList" :key="idx">
  35. <view class="flow-item-row">
  36. <view class="flow-item-left">
  37. <view class="flow-title">{{ item.title || item.type || '充值' }}</view>
  38. <view class="flow-date">{{ formatDate(item.createTime) }}</view>
  39. </view>
  40. <view class="flow-amount plus">+{{ item.num }}</view>
  41. </view>
  42. </view>
  43. <view v-if="rechargeList.length === 0 && !loading" class="empty-tip">暂无充值记录</view>
  44. </view>
  45. <view v-else>
  46. <view class="flow-item" v-for="(item, idx) in payList" :key="idx">
  47. <view class="flow-item-row">
  48. <view class="flow-item-left">
  49. <view class="flow-title">{{ item.title || item.type || '支付' }}</view>
  50. <view class="flow-date">{{ formatDate(item.createTime) }}</view>
  51. </view>
  52. <view class="flow-amount minus">-{{ item.num }}</view>
  53. </view>
  54. </view>
  55. <view v-if="payList.length === 0 && !loading" class="empty-tip">暂无支付记录</view>
  56. </view>
  57. <view v-if="loading" class="loading-tip">加载中...</view>
  58. <view v-if="noMore && (rechargeList.length > 0 || payList.length > 0)" class="no-more-tip">没有更多了</view>
  59. </scroll-view>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import mixinsList from '@/mixins/list.js'
  65. export default {
  66. mixins: [mixinsList],
  67. components: {
  68. },
  69. data() {
  70. return {
  71. accountBalance: 0,
  72. activeTab: 0,
  73. rechargeList: [],
  74. payList: [],
  75. loading: false,
  76. noMore: false,
  77. pageNo: 1,
  78. pageSize: 20,
  79. tabList: [
  80. {
  81. name: '充值',
  82. value: 0
  83. },
  84. {
  85. name: '支付',
  86. value: 1
  87. }
  88. ]
  89. }
  90. },
  91. onLoad() {
  92. this.getAccountBalance();
  93. this.getFlowList();
  94. },
  95. methods: {
  96. // 获取账户余额
  97. getAccountBalance() {
  98. this.$fetch('getMyMoneyNum').then(res => {
  99. this.accountBalance = res || 0;
  100. }).catch(err => {
  101. console.error('获取账户余额失败:', err);
  102. this.accountBalance = 0;
  103. });
  104. },
  105. // 切换tab
  106. switchTab(tab) {
  107. // uv-tabs组件传递的可能是对象,需要获取index
  108. const tabIndex = typeof tab === 'object' ? tab.index : tab;
  109. if (this.activeTab === tabIndex) return;
  110. this.activeTab = tabIndex;
  111. this.pageNo = 1;
  112. this.noMore = false;
  113. // 清空对应列表
  114. if (tabIndex === 0) {
  115. this.rechargeList = [];
  116. } else {
  117. this.payList = [];
  118. }
  119. this.getFlowList();
  120. },
  121. // 获取流水列表
  122. getFlowList() {
  123. if (this.loading || this.noMore) return;
  124. this.loading = true;
  125. // 根据当前tab确定流水类型:0-充值,1-支付
  126. const logType = this.activeTab === 0 ? 0 : 1;
  127. this.$fetch('getMyMoneyLogPage', {
  128. pageNo: this.pageNo,
  129. pageSize: this.pageSize,
  130. status: logType // 0-充值记录,1-支付记录
  131. }).then(res => {
  132. const records = res.records || [];
  133. if (records.length === 0) {
  134. this.noMore = true;
  135. } else {
  136. if (this.activeTab === 0) {
  137. // 充值记录
  138. if (this.pageNo === 1) {
  139. this.rechargeList = records;
  140. } else {
  141. this.rechargeList = [...this.rechargeList, ...records];
  142. }
  143. } else {
  144. // 支付记录
  145. if (this.pageNo === 1) {
  146. this.payList = records;
  147. } else {
  148. this.payList = [...this.payList, ...records];
  149. }
  150. }
  151. // 如果返回的记录数少于pageSize,说明没有更多了
  152. if (records.length < this.pageSize) {
  153. this.noMore = true;
  154. }
  155. }
  156. this.loading = false;
  157. }).catch(err => {
  158. console.error('获取流水列表失败:', err);
  159. this.loading = false;
  160. uni.showToast({
  161. title: '获取流水失败',
  162. icon: 'none'
  163. });
  164. });
  165. },
  166. // 加载更多
  167. loadMore() {
  168. if (this.loading || this.noMore) return;
  169. this.pageNo++;
  170. this.getFlowList();
  171. },
  172. // 格式化日期
  173. formatDate(dateString) {
  174. if (!dateString) return '';
  175. const date = new Date(dateString);
  176. const year = date.getFullYear();
  177. const month = (date.getMonth() + 1).toString().padStart(2, '0');
  178. const day = date.getDate().toString().padStart(2, '0');
  179. return `${year}.${month}.${day}`;
  180. },
  181. goRecharge() {
  182. uni.navigateTo({
  183. url: '/pages_order/mine/recharge'
  184. })
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .walletflow-page {
  191. min-height: 100vh;
  192. background: linear-gradient(180deg, #f8f8fc 0%, #fff 100%);
  193. padding-bottom: 30rpx;
  194. }
  195. .balance-card {
  196. background: linear-gradient(90deg, #f7f2fa 0%, #fbeaf2 100%);
  197. border-radius: 18rpx;
  198. margin: 24rpx 12rpx 0 12rpx;
  199. padding: 18rpx 24rpx 14rpx 24rpx;
  200. box-shadow: none;
  201. border: 1rpx solid #ede7ef;
  202. position: relative;
  203. display: flex;
  204. flex-direction: column;
  205. min-height: 130rpx;
  206. justify-content: center;
  207. .balance-label {
  208. color: #bbb;
  209. font-size: 26rpx;
  210. margin-bottom: 8rpx;
  211. }
  212. .balance-row {
  213. display: flex;
  214. align-items: center;
  215. margin-top: 0;
  216. position: relative;
  217. .balance-amount {
  218. color: #e94f7a;
  219. font-size: 48rpx;
  220. font-weight: bold;
  221. }
  222. .recharge-btn {
  223. position: absolute;
  224. right: 0;
  225. top: 50%;
  226. transform: translateY(-50%);
  227. background: linear-gradient(90deg, #ffb6c1 0%, #fa5a99 100%);
  228. color: #fff;
  229. font-size: 28rpx;
  230. border-radius: 32rpx;
  231. padding: 0 40rpx;
  232. height: 56rpx;
  233. line-height: 56rpx;
  234. font-weight: 500;
  235. border: none;
  236. box-shadow: none;
  237. display: flex;
  238. align-items: center;
  239. justify-content: center;
  240. }
  241. }
  242. }
  243. .flow-card {
  244. background: #fff;
  245. border-radius: 20rpx;
  246. margin: 32rpx 16rpx 0 16rpx;
  247. box-shadow: 0 4rpx 24rpx 0 rgba(0, 0, 0, 0.06);
  248. padding-bottom: 8rpx;
  249. overflow: hidden;
  250. // uv-tabs组件样式调整
  251. :deep(.uv-tabs) {
  252. background: #fff;
  253. border-top-left-radius: 20rpx;
  254. border-top-right-radius: 20rpx;
  255. }
  256. :deep(.uv-tabs__wrapper__nav__line) {
  257. border-radius: 2rpx !important;
  258. }
  259. }
  260. .flow-list {
  261. margin: 0;
  262. padding: 0 16rpx;
  263. max-height: calc(75vh - 88rpx);
  264. background: #fff;
  265. }
  266. .flow-item {
  267. border-bottom: 1px solid #f5f5f5;
  268. padding: 18rpx 0 8rpx 0;
  269. &:last-child {
  270. border-bottom: none;
  271. }
  272. .flow-item-row {
  273. display: flex;
  274. align-items: flex-start;
  275. justify-content: space-between;
  276. padding-right: 45rpx;
  277. padding-left: 15rpx;
  278. }
  279. .flow-item-left {
  280. display: flex;
  281. flex-direction: column;
  282. align-items: flex-start;
  283. .flow-title {
  284. font-size: 28rpx;
  285. color: #222;
  286. font-weight: 500;
  287. margin-bottom: 2rpx;
  288. }
  289. .flow-date {
  290. color: #bbb;
  291. font-size: 22rpx;
  292. margin-top: 0;
  293. }
  294. }
  295. .flow-amount {
  296. font-size: 26rpx;
  297. font-weight: 500;
  298. margin-left: 24rpx;
  299. margin-top: 2rpx;
  300. &.plus {
  301. color: #223a7a;
  302. }
  303. &.minus {
  304. color: #e94f7a;
  305. }
  306. }
  307. }
  308. // 提示文字样式
  309. .empty-tip,
  310. .loading-tip,
  311. .no-more-tip {
  312. text-align: center;
  313. padding: 40rpx 0;
  314. color: #999;
  315. font-size: 26rpx;
  316. }
  317. .loading-tip {
  318. color: #666;
  319. }
  320. </style>