marketplace.vue 6.6 KB

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