marketplace.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <uni-table class="table-box" emptyText="暂无更多数据">
  3. <!-- 表头行 -->
  4. <uni-tr>
  5. <uni-th>
  6. <view class="table-th">
  7. 交易对
  8. </view>
  9. </uni-th>
  10. <uni-th>
  11. <view class="table-th table-th-title" @click.stop="alterRankRule(`rankRule`)">
  12. <text>最新价</text>
  13. <view class="title-arrows">
  14. <image class="arrows-icon" :src="rankRule === 1 ? activeRankRuleIcon : rankRuleIcon"
  15. mode="aspectFit"></image>
  16. <image class="arrows-icon" :src="rankRule === 2 ? activeRankRuleIcon : rankRuleIcon"
  17. mode="aspectFit"></image>
  18. </view>
  19. </view>
  20. </uni-th>
  21. <uni-th>
  22. <view class="table-th table-th-title" @click.stop="alterRankRule(`rankRule`)">
  23. <text>日涨跌</text>
  24. <view class="title-arrows">
  25. <image class="arrows-icon" :src="rankRule === 1 ? activeRankRuleIcon : rankRuleIcon"
  26. mode="aspectFit"></image>
  27. <image class="arrows-icon" :src="rankRule === 2 ? activeRankRuleIcon : rankRuleIcon"
  28. mode="aspectFit"></image>
  29. </view>
  30. </view>
  31. </uni-th>
  32. </uni-tr>
  33. <!-- 表格数据行 -->
  34. <view class="" v-for="item in marketplaceList">
  35. <uni-tr v-for="val in item.quotation" :rise-fall="stocksColor">
  36. <uni-td>
  37. <view class="table-title">
  38. <view class="title">
  39. <text>{{ val.currency_name }}</text>
  40. <text class="title-sub">{{ item.legal_name ? `/${item.legal_name}` : '' }}</text>
  41. </view>
  42. <view class="title-num">
  43. 24H额:476.62m
  44. </view>
  45. </view>
  46. </uni-td>
  47. <uni-td>
  48. <view class="title">
  49. <view class="">
  50. {{ val.now_price }}
  51. </view>
  52. <view class="title-num">
  53. ¥{{ val.volume }}
  54. </view>
  55. </view>
  56. </uni-td>
  57. <uni-td class="table-right">
  58. <view :class="['table-btn' , val.change > 0 ? 'rise-btn' : 'fall-btn']">
  59. {{ val.change }}%
  60. </view>
  61. </uni-td>
  62. </uni-tr>
  63. </view>
  64. </uni-table>
  65. </template>
  66. <script>
  67. import {
  68. mapGetters
  69. } from 'vuex'
  70. export default {
  71. name: "marketplace",
  72. props: {
  73. marketplaceList: {
  74. type: Array,
  75. default: () => []
  76. }
  77. },
  78. data() {
  79. return {
  80. rankRule: 0,
  81. rankRuleIcon: require("@/static/images/jiantou.png"),
  82. activeRankRuleIcon: require("@/static/images/jiantou_01.png")
  83. };
  84. },
  85. computed: {
  86. ...mapGetters([
  87. 'stocksColor'
  88. ]),
  89. },
  90. methods: {
  91. alterRankRule(rankRule) {
  92. console.log('alterRankRule', rankRule)
  93. switch (this['rankRule']) {
  94. case 0:
  95. this['rankRule'] = 1;
  96. break;
  97. case 1:
  98. this['rankRule'] = 2;
  99. break;
  100. default:
  101. this['rankRule'] = 0
  102. }
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .table-box {
  109. ::v-deep .uni-table-tr {
  110. display: flex;
  111. .uni-table-th,
  112. .uni-table-td {
  113. padding: 0;
  114. flex-shrink: 0;
  115. display: flex;
  116. flex-direction: column;
  117. justify-content: center;
  118. &:nth-child(3n - 2) {
  119. padding-left: $pages-padding;
  120. flex: 4;
  121. }
  122. &:nth-child(3n - 1) {
  123. text-align: right !important;
  124. flex: 3;
  125. }
  126. &:nth-child(3n) {
  127. flex: 3;
  128. padding-right: $pages-padding;
  129. }
  130. // &:nth-child()
  131. }
  132. .table-th {
  133. padding-top: 20rpx;
  134. padding-bottom: 10rpx;
  135. }
  136. .uni-table-th {
  137. font-size: 22rpx;
  138. border-bottom: none;
  139. .table-th-title {
  140. width: 100%;
  141. display: flex;
  142. justify-content: flex-end;
  143. .title-arrows {
  144. display: flex;
  145. flex-direction: column;
  146. align-items: center;
  147. justify-content: flex-end;
  148. padding-left: 3px;
  149. .arrows-icon {
  150. width: 18rpx;
  151. height: 18rpx;
  152. &:first-child {
  153. transform: rotate(180deg);
  154. margin-bottom: -4rpx;
  155. }
  156. &:last-child {
  157. margin-top: -4rpx;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. .uni-table-td {
  164. padding-top: 20rpx;
  165. padding-bottom: 20rpx;
  166. .table-title {
  167. width: 100%;
  168. line-height: 1.2;
  169. }
  170. .title {
  171. line-height: 1.2;
  172. font-size: 28rpx;
  173. font-family: PingFang SC, PingFang SC-Bold;
  174. font-weight: 700;
  175. .title-sub {
  176. font-size: 24rpx;
  177. font-weight: 400;
  178. }
  179. }
  180. .title-num {
  181. padding-top: 18rpx;
  182. font-size: 24rpx;
  183. }
  184. // <view class="table-title">
  185. // <view class="title">
  186. // <text>BTC</text>
  187. // <text class="title-sub">/USDT</text>
  188. // </view>
  189. // <view class="title-num">
  190. // 24H额:476.62m
  191. // </view>
  192. // </view>
  193. // &:nth-child(3n - 2) {
  194. // padding-left: $pages-padding;
  195. // }
  196. // &:nth-child(3n) {
  197. // padding-right: $pages-padding;
  198. // background-color: yellow;
  199. // text-align: right;
  200. // }
  201. // &:nth-child()
  202. }
  203. .table-btn {
  204. // 138
  205. width: 138rpx;
  206. height: 60rpx;
  207. border-radius: 6rpx;
  208. color: #fff;
  209. font-family: PingFang SC, PingFang SC-Bold;
  210. font-weight: 700;
  211. text-align: center;
  212. line-height: 60rpx;
  213. font-size: 26rpx;
  214. // margin-left: calc(100% - 138rpx);
  215. }
  216. }
  217. .table-right {
  218. display: flex;
  219. justify-content: flex-end;
  220. flex-direction: row;
  221. align-items: flex-end;
  222. }
  223. }
  224. </style>