marketplace.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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('newPrice')">
  12. <text>最新价</text>
  13. <view class="title-arrows">
  14. <image class="arrows-icon" :src="rankRuleNum === 1 ? activeRankRuleIcon : rankRuleIcon"
  15. mode="aspectFit"></image>
  16. <image class="arrows-icon" :src="rankRuleNum === 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="rankRuleNum === 3 ? activeRankRuleIcon : rankRuleIcon"
  26. mode="aspectFit"></image>
  27. <image class="arrows-icon" :src="rankRuleNum === 4 ? 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. </view> -->
  36. <uni-tr v-for="val in listArr" :rise-fall="stocksColor">
  37. <uni-td>
  38. <view class="table-title">
  39. <view class="title">
  40. <text>{{ val.currency_name }}</text>
  41. <text class="title-sub">{{ val.legal_name ? `/${val.legal_name}` : '' }}</text>
  42. </view>
  43. <view class="title-num">
  44. 24H额:{{ val.volume }}m
  45. </view>
  46. </view>
  47. </uni-td>
  48. <uni-td>
  49. <view class="title">
  50. <view class="">
  51. {{ val.now_price }}
  52. </view>
  53. <view class="title-num">
  54. <text class="iconfont">&#xe615;</text> {{ val.volume }}
  55. </view>
  56. </view>
  57. </uni-td>
  58. <uni-td :class="['table-right' , $setColor(val.change)]">
  59. <view class="table-btn bgcolor">
  60. {{ val.change }}%
  61. </view>
  62. </uni-td>
  63. </uni-tr>
  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. manageArr:[],
  81. listArr: [],
  82. rankRuleNum: 0,
  83. rankRuleIcon: require("@/static/images/jiantou.png"),
  84. activeRankRuleIcon: require("@/static/images/jiantou_01.png")
  85. };
  86. },
  87. computed: {
  88. ...mapGetters([
  89. 'stocksColor'
  90. ]),
  91. },
  92. watch: {
  93. marketplaceList: {
  94. handler(newArr , oldArr) {
  95. this.manageArr = JSON.parse(JSON.stringify(newArr))
  96. this.alterRankRule()
  97. },
  98. deep: true
  99. }
  100. },
  101. methods: {
  102. alterRankRule(rankRule) {
  103. if (rankRule) {
  104. // newPrice , rankRule
  105. if (rankRule === 'newPrice') {
  106. switch (this.rankRuleNum) {
  107. case 0:
  108. case 3:
  109. case 4:
  110. this.rankRuleNum = 1;
  111. break;
  112. case 1:
  113. this.rankRuleNum = 2;
  114. break;
  115. default:
  116. this.rankRuleNum = 0
  117. }
  118. }
  119. if (rankRule === 'rankRule') {
  120. switch (this.rankRuleNum) {
  121. case 0:
  122. case 1:
  123. case 2:
  124. this.rankRuleNum = 3;
  125. break;
  126. case 3:
  127. this.rankRuleNum = 4;
  128. break;
  129. default:
  130. this.rankRuleNum = 0
  131. }
  132. }
  133. };
  134. this.setRankList();
  135. },
  136. setRankList() {
  137. switch (this.rankRuleNum) {
  138. case 1:
  139. this.manageArr.sort((x, y) => {
  140. return (x.now_price - y.now_price)
  141. });
  142. break;
  143. case 2:
  144. this.manageArr.sort((x, y) => {
  145. return (y.now_price - x.now_price)
  146. });
  147. break;
  148. case 3:
  149. this.manageArr.sort((x, y) => {
  150. return (x.change - y.change)
  151. });
  152. break;
  153. case 4:
  154. this.manageArr.sort((x, y) => {
  155. return (y.change - x.change)
  156. });
  157. break;
  158. default:
  159. this.manageArr = JSON.parse(JSON.stringify(this.marketplaceList))
  160. };
  161. this.listArr = JSON.parse(JSON.stringify(this.manageArr))
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. .table-box {
  168. ::v-deep .uni-table-tr {
  169. display: flex;
  170. .uni-table-th,
  171. .uni-table-td {
  172. padding: 0;
  173. flex-shrink: 0;
  174. display: flex;
  175. flex-direction: column;
  176. justify-content: center;
  177. &:nth-child(3n - 2) {
  178. padding-left: $pages-padding;
  179. flex: 4;
  180. }
  181. &:nth-child(3n - 1) {
  182. text-align: right !important;
  183. flex: 3;
  184. }
  185. &:nth-child(3n) {
  186. flex: 3;
  187. padding-right: $pages-padding;
  188. }
  189. // &:nth-child()
  190. }
  191. .table-th {
  192. padding-top: 20rpx;
  193. padding-bottom: 10rpx;
  194. }
  195. .uni-table-th {
  196. font-size: 22rpx;
  197. border-bottom: none;
  198. .table-th-title {
  199. width: 100%;
  200. display: flex;
  201. justify-content: flex-end;
  202. .title-arrows {
  203. display: flex;
  204. flex-direction: column;
  205. align-items: center;
  206. justify-content: flex-end;
  207. padding-left: 3px;
  208. .arrows-icon {
  209. width: 18rpx;
  210. height: 18rpx;
  211. &:first-child {
  212. transform: rotate(180deg);
  213. margin-bottom: -4rpx;
  214. }
  215. &:last-child {
  216. margin-top: -4rpx;
  217. }
  218. }
  219. }
  220. }
  221. }
  222. .uni-table-td {
  223. padding-top: 20rpx;
  224. padding-bottom: 20rpx;
  225. .table-title {
  226. width: 100%;
  227. line-height: 1.2;
  228. }
  229. .title {
  230. line-height: 1.2;
  231. font-size: 28rpx;
  232. font-family: PingFang SC, PingFang SC-Bold;
  233. font-weight: 700;
  234. .title-sub {
  235. font-size: 24rpx;
  236. font-weight: 400;
  237. }
  238. }
  239. .title-num {
  240. padding-top: 18rpx;
  241. font-size: 24rpx;
  242. color: #9f9c9c;
  243. .iconfont {
  244. font-size: 22rpx;
  245. }
  246. }
  247. // <view class="table-title">
  248. // <view class="title">
  249. // <text>BTC</text>
  250. // <text class="title-sub">/USDT</text>
  251. // </view>
  252. // <view class="title-num">
  253. // 24H额:476.62m
  254. // </view>
  255. // </view>
  256. // &:nth-child(3n - 2) {
  257. // padding-left: $pages-padding;
  258. // }
  259. // &:nth-child(3n) {
  260. // padding-right: $pages-padding;
  261. // background-color: yellow;
  262. // text-align: right;
  263. // }
  264. // &:nth-child()
  265. }
  266. .table-btn {
  267. // 138
  268. width: 138rpx;
  269. height: 60rpx;
  270. border-radius: 6rpx;
  271. color: #fff;
  272. font-family: PingFang SC, PingFang SC-Bold;
  273. font-weight: 700;
  274. text-align: center;
  275. line-height: 60rpx;
  276. font-size: 26rpx;
  277. // margin-left: calc(100% - 138rpx);
  278. }
  279. }
  280. .table-right {
  281. display: flex;
  282. justify-content: flex-end;
  283. flex-direction: row;
  284. align-items: flex-end;
  285. }
  286. }
  287. </style>