marketplace.vue 6.6 KB

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