symbol-list.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="symbol-list">
  3. <view class="title fn-18 p-md color-light">{{ title||$t("exchange.f5") }}</view>
  4. <van-search
  5. background="transparent"
  6. :value="filterText"
  7. :action-text="$t('common.cancelButtonText')"
  8. @change="filterText = $event.detail"
  9. :placeholder="$t('exchange.f6')"
  10. />
  11. <van-tabs :active="active">
  12. <van-tab
  13. :title="parentItem.coin_name"
  14. v-for="parentItem in showMarketList"
  15. :key="parentItem.coin_name"
  16. >
  17. <view class="p-x-xs">
  18. <table class="w-max a">
  19. <thead>
  20. <tr class="fn-sm">
  21. <th class="p-l-md p-y-xs fn-left">{{ $t("exchange.f7") }}</th>
  22. <th class="fn-left">{{ $t("exchange.f8") }}</th>
  23. <th class="p-r-md p-y-xs fn-right">{{ $t("exchange.f9") }}</th>
  24. </tr>
  25. </thead>
  26. <tbody class="table-list">
  27. <tr
  28. class="link-active"
  29. v-for="item in parentItem.marketInfoList"
  30. :key="item.symbol"
  31. v-show="isShow(item.pair_name)"
  32. @click="$emit('check-symbol', item)"
  33. >
  34. <td class="p-l-md p-y-xs rounded-tl-xs rounded-bl-xs">
  35. <template v-if="parentItem.isCollect">
  36. <span class="color-light">{{ item.pair_name }}</span>
  37. </template>
  38. <template v-else>
  39. <span class="color-light">{{ item.coin_name||item.symbol }}</span>
  40. <span class="fn-sm">/{{ parentItem.coin_name }}</span>
  41. </template>
  42. </td>
  43. <td :class="item.increase < 0 ? 'color-sell' : 'color-buy'">
  44. {{ item.price }}
  45. </td>
  46. <td
  47. :class="item.increase < 0 ? 'color-sell' : 'color-buy'"
  48. class="p-r-md p-y-xs fn-right rounded-tr-xs rounded-br-xs"
  49. >
  50. {{ item.increaseStr }}
  51. </td>
  52. </tr>
  53. </tbody>
  54. </table>
  55. </view>
  56. </van-tab>
  57. </van-tabs>
  58. </view>
  59. </template>
  60. <script>
  61. export default {
  62. props: {
  63. marketList: {
  64. default() {
  65. return [];
  66. },
  67. type: Array,
  68. required: false,
  69. },
  70. collect: {
  71. default() {
  72. return [];
  73. },
  74. type: Array,
  75. required: false,
  76. },
  77. title:{
  78. default:''
  79. }
  80. },
  81. computed: {
  82. showMarketList() {
  83. let collect = this.collect.map((item) => item.pair_name);
  84. let collects = [];
  85. this.marketList.forEach((parentItem) => {
  86. parentItem.marketInfoList.forEach((item) => {
  87. if (collect.includes(item.pair_name)) {
  88. collects.push(item);
  89. }
  90. });
  91. });
  92. let arr = [
  93. {
  94. coin_name: this.$t("exchange.g0"),
  95. isCollect: true,
  96. marketInfoList: collects,
  97. },
  98. ...this.marketList,
  99. ];
  100. console.log(arr)
  101. return arr;
  102. },
  103. },
  104. data() {
  105. return {
  106. active: 0,
  107. filterText: "",
  108. };
  109. },
  110. methods: {
  111. isShow(str) {
  112. return (
  113. str.toLocaleLowerCase().indexOf(this.filterText.toLocaleLowerCase()) !=
  114. -1
  115. );
  116. },
  117. },
  118. created() {},
  119. };
  120. </script>
  121. <style lang="scss" scoped>
  122. .a{
  123. margin-bottom: 120rpx;
  124. }
  125. .table-list {
  126. tr:nth-of-type(2n-1) {
  127. td {
  128. background: $panel-3;
  129. }
  130. }
  131. }
  132. </style>