fiat-list.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.fiat"
  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.fiat);$emit('close')"
  13. >
  14. <view>{{item.fiat}}</view>
  15. <!-- <view class="color-light">{{item.country}}</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. fiatList: [],
  34. taskHeight:0
  35. };
  36. },
  37. computed: {
  38. showList() {
  39. return this.fiatList.filter((item) => this.isShow(item.fiat));
  40. },
  41. },
  42. methods: {
  43. getCoinList() {
  44. Wallet.fundFiat()
  45. .then((res) => {
  46. console.log(res)
  47. this.fiatList = res.data;
  48. if (!this.value) {
  49. this.$emit("input", this.fiatList[0].fiat);
  50. }
  51. })
  52. .catch(() => {});
  53. },
  54. isShow(str) {
  55. return (
  56. str.toLocaleLowerCase().indexOf(this.filterName.toLocaleLowerCase()) !=
  57. -1
  58. );
  59. },
  60. getTaskHeight(){
  61. uni.getSystemInfo({
  62. success:(obj)=>{
  63. this.taskHeight = obj.statusBarHeight
  64. }
  65. })
  66. },
  67. search(e){
  68. this.filterName = e.detail
  69. }
  70. },
  71. created() {
  72. this.getTaskHeight()
  73. this.getCoinList();
  74. },
  75. };
  76. </script>
  77. <style lang="scss" scoped>
  78. .coin-list {
  79. position: fixed;
  80. left: 0;
  81. top: 0;
  82. right: 0;
  83. bottom: 0;
  84. z-index: 9;
  85. animation: coinList 0.3s;
  86. }
  87. @keyframes coinList {
  88. from {
  89. transform: translateY(100%);
  90. }
  91. to {
  92. transform: translateY(0);
  93. }
  94. }
  95. </style>