list.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <cwg-page-wrapper :isHeaderFixed="true">
  3. <view class="bank-transaction-page">
  4. <cwg-header color="#000" :title="pageTitle" />
  5. <!-- Tabs -->
  6. <view class="tabs-container" :style="{ top: statusBarHeight + 60 + 'px' }">
  7. <view :class="['tab-item', { 'tab-active': activeTab === 'recharge' }]" @click="activeTab = 'recharge'">
  8. <cwg-icon class="icons" name="plus-filled" :size="18"
  9. :color="activeTab === 'recharge' ? '#ea002a' : '#9ca3af'" />
  10. <view :class="['tab-text', { 'tab-text-active': activeTab === 'recharge' }]">{{ t('card.Status.t18') }}</view>
  11. <view v-if="activeTab === 'recharge'" class="tab-indicator" />
  12. </view>
  13. <view :class="['tab-item', { 'tab-active': activeTab === 'transaction' }]" @click="activeTab = 'transaction'">
  14. <cwg-icon class="icons" name="list" :size="18" :color="activeTab === 'transaction' ? '#ea002a' : '#9ca3af'" />
  15. <view :class="['tab-text', { 'tab-text-active': activeTab === 'transaction' }]">{{ t('Shop.Index.Transaction')
  16. }}</view>
  17. <view v-if="activeTab === 'transaction'" class="tab-indicator" />
  18. </view>
  19. <view :class="['tab-item', { 'tab-active': activeTab === 'deduction' }]" @click="activeTab = 'deduction'">
  20. <cwg-icon class="icons" name="trending-down" :size="18"
  21. :color="activeTab === 'deduction' ? '#ea002a' : '#9ca3af'" />
  22. <view :class="['tab-text', { 'tab-text-active': activeTab === 'deduction' }]">{{ t('card.tab20') }}
  23. </view>
  24. <view v-if="activeTab === 'deduction'" class="tab-indicator" />
  25. </view>
  26. </view>
  27. <view class="filters-scroll">
  28. <view class="filters-container" :style="{ top: statusBarHeight + 113 + 'px' }">
  29. <view class="filter-item">
  30. <text class="filter-label">{{ t('card.Form.f52') }}</text>
  31. <cwg-filter-select v-model="currentTypeIndex" :options="currentTypeOptions" />
  32. </view>
  33. <view class="filter-item" v-if="activeTab !== 'deduction'">
  34. <text class="filter-label">{{ t('card.Form.f45') }}</text>
  35. <cwg-filter-select v-model="statusFilterIndex" :options="statusOptions" />
  36. </view>
  37. <view class="filter-item">
  38. <text class="filter-label">{{ t('card.Form.f51') }}</text>
  39. <cwg-filter-picker v-model="dateFilter"
  40. :returnType="activeTab == 'deduction' ? 'timestamp' : 'string'"></cwg-filter-picker>
  41. </view>
  42. <view class="reset-btn" @click="resetFilters">
  43. <uni-icons type="loop" size="16" color="#ea002a" />
  44. </view>
  45. </view>
  46. </view>
  47. <!-- Content -->
  48. <view class="content">
  49. <!-- Recharge Records -->
  50. <RechargeList v-if="activeTab === 'recharge'" ref="rechargeListRef" :cardNumber="cardNumber"
  51. :typeIndex="currentTypeIndex" :statusIndex="statusFilterIndex" :dateFilter="dateFilter"
  52. :typeOptions="currentTypeOptions" />
  53. <!-- Transaction Records -->
  54. <TransactionList v-if="activeTab === 'transaction'" ref="transactionListRef" :cardNumber="cardNumber"
  55. :typeIndex="currentTypeIndex" :statusIndex="statusFilterIndex" :dateFilter="dateFilter"
  56. :typeOptions="currentTypeOptions" />
  57. <!-- Deduction Records -->
  58. <DeductionList v-if="activeTab === 'deduction'" ref="deductionListRef" :cardNumber="cardNumber"
  59. :typeIndex="currentTypeIndex" :statusIndex="statusFilterIndex" :dateFilter="dateFilter"
  60. :typeOptions="currentTypeOptions" />
  61. </view>
  62. </view>
  63. </cwg-page-wrapper>
  64. </template>
  65. <script setup lang="ts">
  66. import { ref, computed, watch } from 'vue';
  67. import { onLoad } from '@dcloudio/uni-app';
  68. import { useI18n } from 'vue-i18n';
  69. import useGlobalStore from '@/stores/use-global-store';
  70. import RechargeList from './components/RechargeList.vue';
  71. import TransactionList from './components/TransactionList.vue';
  72. import DeductionList from './components/DeductionList.vue';
  73. import { rechargeType, transactionTypeMap, WITHDRAW_TYPE_MAP, transactionStatusMap, rechargeStatusMap } from '@/utils/dataMap';
  74. const globalStore = useGlobalStore()
  75. const statusBarHeight = computed(() => globalStore.statusBarHeight);
  76. const { t } = useI18n();
  77. const activeTab = ref<'recharge' | 'transaction' | 'deduction'>('recharge');
  78. const cardNumber = ref('');
  79. onLoad((options) => {
  80. cardNumber.value = options.cardNumber || '';
  81. });
  82. const currentTypeOptions = computed(() => {
  83. if (activeTab.value === 'recharge') {
  84. return rechargeType;
  85. } else if (activeTab.value === 'transaction') {
  86. return transactionTypeMap;
  87. } else {
  88. return WITHDRAW_TYPE_MAP;
  89. }
  90. });
  91. const statusOptions = computed(() => {
  92. if (activeTab.value === 'recharge') {
  93. return rechargeStatusMap;
  94. } else if (activeTab.value === 'transaction') {
  95. return transactionStatusMap;
  96. } else {
  97. return [];
  98. }
  99. });
  100. console.log(statusOptions, 1212);
  101. // const statusOptions = ['全部', '成功', '处理中', '失败'];
  102. const currentTypeIndex = ref(-1);
  103. const statusFilterIndex = ref(-1);
  104. const dateFilter = ref([]);
  105. const pageTitle = computed(() => {
  106. if (activeTab.value === 'recharge') {
  107. return t('card.tab7'); // 充值记录
  108. } else if (activeTab.value === 'transaction') {
  109. return t('card.tab2'); // 交易记录
  110. } else {
  111. return t('card.tab20'); // 扣款记录
  112. }
  113. });
  114. const resetFilters = () => {
  115. currentTypeIndex.value = -1;
  116. statusFilterIndex.value = -1;
  117. dateFilter.value = [];
  118. };
  119. // 监听 tab 切换,重置查询条件
  120. watch(activeTab, () => {
  121. resetFilters();
  122. });
  123. </script>
  124. <style scoped lang="scss">
  125. @import "@/uni.scss";
  126. .page-wrapper {
  127. padding: 0;
  128. border: 0;
  129. }
  130. .bank-transaction-page {
  131. // background-color: #f9fafb;
  132. }
  133. .wallet-header {
  134. background: #fff;
  135. color: #000 !important;
  136. .header {
  137. color: #000 !important;
  138. }
  139. }
  140. /* Header */
  141. .header {
  142. background: linear-gradient(90deg, #ea002a 0%, #eb4e6b 100%);
  143. padding: px2rpx(16);
  144. padding-bottom: px2rpx(20);
  145. }
  146. .header-content {
  147. display: flex;
  148. flex-direction: column;
  149. gap: px2rpx(16);
  150. }
  151. .header-title {
  152. display: flex;
  153. align-items: center;
  154. gap: px2rpx(8);
  155. }
  156. .title-text {
  157. color: #ffffff;
  158. font-size: px2rpx(20);
  159. }
  160. .stats-container {
  161. display: flex;
  162. gap: px2rpx(12);
  163. }
  164. .stat-card {
  165. flex: 1;
  166. background-color: rgba(255, 255, 255, 0.15);
  167. backdrop-filter: blur(px2rpx(10));
  168. border-radius: px2rpx(12);
  169. padding: px2rpx(12);
  170. }
  171. .stat-header {
  172. display: flex;
  173. align-items: center;
  174. gap: px2rpx(6);
  175. margin-bottom: px2rpx(8);
  176. }
  177. .icons {
  178. width: px2rpx(20);
  179. height: px2rpx(20);
  180. }
  181. .stat-label {
  182. font-size: px2rpx(12);
  183. color: rgba(255, 255, 255, 0.9);
  184. }
  185. .stat-value {
  186. font-size: px2rpx(20);
  187. color: #ffffff;
  188. display: block;
  189. margin-bottom: px2rpx(4);
  190. }
  191. .stat-count {
  192. font-size: px2rpx(11);
  193. color: rgba(255, 255, 255, 0.8);
  194. }
  195. /* Tabs */
  196. .tabs-container {
  197. background-color: #ffffff;
  198. display: flex;
  199. border-bottom: 1px solid #e5e7eb;
  200. position: sticky;
  201. top: 0;
  202. z-index: 10;
  203. }
  204. .tab-item {
  205. flex: 1;
  206. display: flex;
  207. align-items: center;
  208. justify-content: center;
  209. gap: px2rpx(6);
  210. padding: px2rpx(16);
  211. position: relative;
  212. transition: all 0.3s;
  213. }
  214. .tab-text {
  215. font-size: px2rpx(15);
  216. color: #9ca3af;
  217. transition: color 0.3s;
  218. }
  219. .tab-text-active {
  220. color: #ea002a;
  221. }
  222. .tab-indicator {
  223. position: absolute;
  224. bottom: 0;
  225. left: 0;
  226. right: 0;
  227. height: px2rpx(3);
  228. background-color: #ea002a;
  229. border-radius: px2rpx(3);
  230. }
  231. /* Content */
  232. .content {
  233. padding: 0;
  234. }
  235. .filters-container {
  236. display: flex;
  237. align-items: center;
  238. gap: px2rpx(8);
  239. padding: px2rpx(12) px2rpx(6);
  240. background-color: #ffffff;
  241. position: sticky;
  242. top: 0;
  243. z-index: 10;
  244. // overflow-x: auto;
  245. // overflow-y: visible;
  246. -webkit-overflow-scrolling: touch;
  247. }
  248. .filter-item {
  249. display: flex;
  250. align-items: center;
  251. gap: px2rpx(4);
  252. flex-shrink: 0;
  253. min-width: 0;
  254. }
  255. .filter-label {
  256. font-size: px2rpx(12);
  257. color: #6b7280;
  258. white-space: nowrap;
  259. flex-shrink: 0;
  260. }
  261. .reset-btn {
  262. background-color: #ffffff;
  263. border: 1px solid #e5e7eb;
  264. border-radius: px2rpx(8);
  265. padding: px2rpx(6) 0;
  266. display: flex;
  267. align-items: center;
  268. justify-content: center;
  269. flex-shrink: 0;
  270. min-width: px2rpx(36);
  271. }
  272. </style>