coin-list.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view class="coin-list layout-page">
  3. <view :style="{height:taskHeight+'px'}"></view>
  4. <view>
  5. <van-search background="transparent" :action-text="$t('common.cancelButtonText')" v-model="filterName" show-action @cancel="$emit('close')" @search="search" :placeholder="$t('assets.b5')" />
  6. </view>
  7. <view class="layout-main">
  8. <view
  9. v-for="item in showList"
  10. :key="item.coin_name"
  11. class="p-md align-center justify-between d-flex link-active m-md bg-panel-4 rounded box-shadow"
  12. @click="$emit('input',item.coin_name);$emit('close')"
  13. >
  14. <view>{{item.coin_name}}</view>
  15. <view class="color-light">{{item.usable_balance}}</view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import Wallet from "@/api/wallet";
  22. export default {
  23. props: {
  24. value: {
  25. default: "",
  26. type: String,
  27. required: false,
  28. },
  29. },
  30. data() {
  31. return {
  32. filterName: "",
  33. coinList: [],
  34. taskHeight:0
  35. };
  36. },
  37. computed: {
  38. showList() {
  39. return this.coinList.filter((item) => this.isShow(item.coin_name));
  40. },
  41. },
  42. methods: {
  43. search(e){
  44. this.filterName = e.detail
  45. },
  46. getCoinList() {
  47. Wallet.fundAccount()
  48. .then((res) => {
  49. this.coinList = res.data.list;
  50. if (!this.value) {
  51. this.$emit("input", this.coinList[0].coin_name);
  52. }
  53. })
  54. .catch(() => {});
  55. },
  56. isShow(str) {
  57. return (
  58. str.toLocaleLowerCase().indexOf(this.filterName.toLocaleLowerCase()) !=
  59. -1
  60. );
  61. },
  62. getTaskHeight(){
  63. uni.getSystemInfo({
  64. success:(obj)=>{
  65. this.taskHeight = obj.statusBarHeight
  66. }
  67. })
  68. }
  69. },
  70. created() {
  71. this.getTaskHeight()
  72. this.getCoinList();
  73. },
  74. };
  75. </script>
  76. <style lang="scss" scoped>
  77. .coin-list {
  78. position: fixed;
  79. left: 0;
  80. top: 0;
  81. right: 0;
  82. bottom: 0;
  83. z-index: 9;
  84. animation: coinList 0.3s;
  85. }
  86. @keyframes coinList {
  87. from {
  88. transform: translateY(100%);
  89. }
  90. to {
  91. transform: translateY(0);
  92. }
  93. }
  94. </style>