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.

consumption-record.vue 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view class='content'>
  3. <view class='search_wrap'>
  4. <input type="text" v-model='state.value' placeholder='搜索ETC卡号' @confirm="doSearch" /><button size='mini'
  5. @click='search()'>搜索</button>
  6. </view>
  7. <view class='item' v-for="(item,index) in state.newList">
  8. <view class='time'><text>时间:{{item.tradeConfirmTime}}</text><text>¥{{item.fee}}</text></view>
  9. <view>ETC卡号:{{item.bankCardId}}</view>
  10. </view>
  11. </view>
  12. </template>
  13. <script lang="ts" setup>
  14. import { reactive } from "vue";
  15. import { request } from "@/utils/network/request.js";
  16. import { transactionRecord } from "@/utils/network/api.js";
  17. import { stringToJson } from "@/utils/network/encryption.js";
  18. import { onLoad } from "@dcloudio/uni-app";
  19. const state = reactive({
  20. list: '', //所有数据
  21. newList: '', //最终展示的
  22. name: '',
  23. value: '',//input框里的值
  24. })
  25. onLoad((option : any) => {
  26. console.log("option", option)
  27. state.name = option.name;
  28. getList();
  29. })
  30. const getList = () => {
  31. const options = {
  32. type: 2,
  33. data: {
  34. 'accountId': state.name
  35. },
  36. method: "POST",
  37. showLoading: true,
  38. };
  39. request(transactionRecord, options).then((res) => {
  40. const data = stringToJson(res.bizContent);
  41. state.list = data.qtkCorporateAccountDetails;
  42. for (var i = 0; i < state.list.length; i++) {
  43. state.list[i].tradeConfirmTime = state.list[i].tradeConfirmTime.split('T').join(' ');
  44. }
  45. state.newList = state.list;
  46. console.log("交易记录", data)
  47. })
  48. }
  49. const search = () => {
  50. state.newList = [];
  51. for (var i = 0; i < state.list.length; i++) {
  52. if (state.list[i].cardId.indexOf(state.value) >= 0) {
  53. state.newList.push(state.list[i]);
  54. }
  55. }
  56. console.log("state.newList", state.newList)
  57. }
  58. const doSearch = () => {
  59. search();
  60. }
  61. </script>
  62. <style scoped>
  63. .content {
  64. background-color: #EEF7F7;
  65. min-height: 100vh;
  66. padding: 0 30rpx;
  67. overflow: hidden;
  68. font-size: 32rpx;
  69. }
  70. .search_wrap {
  71. display: flex;
  72. margin: 20rpx 0;
  73. }
  74. .search_wrap>input {
  75. background-color: white;
  76. width: 76%;
  77. height: 40rpx;
  78. line-height: 40rpx;
  79. padding: 10rpx 10rpx;
  80. border-radius: 10rpx 0 0 10rpx;
  81. }
  82. .item {
  83. width: 100%;
  84. border-radius: 10rpx;
  85. box-sizing: border-box;
  86. padding: 30rpx 20rpx;
  87. margin-top: 30rpx;
  88. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  89. color: white;
  90. }
  91. .time {
  92. display: flex;
  93. margin-bottom: 16rpx;
  94. justify-content: space-between;
  95. }
  96. </style>