marketplace.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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 in listArr" :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="iconfont">&#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. uni.switchTab({
  164. url: '/pages/contract/index'
  165. });
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .table-box {
  172. ::v-deep .uni-table-tr {
  173. display: flex;
  174. .uni-table-th,
  175. .uni-table-td {
  176. padding: 0;
  177. flex-shrink: 0;
  178. display: flex;
  179. flex-direction: column;
  180. justify-content: center;
  181. &:nth-child(3n - 2) {
  182. padding-left: $pages-padding;
  183. flex: 4;
  184. }
  185. &:nth-child(3n - 1) {
  186. text-align: right !important;
  187. flex: 3;
  188. }
  189. &:nth-child(3n) {
  190. flex: 3;
  191. padding-right: $pages-padding;
  192. }
  193. // &:nth-child()
  194. }
  195. .table-th {
  196. padding-top: 20rpx;
  197. padding-bottom: 10rpx;
  198. }
  199. .uni-table-th {
  200. font-size: 22rpx;
  201. border-bottom: none;
  202. .table-th-title {
  203. width: 100%;
  204. display: flex;
  205. justify-content: flex-end;
  206. .title-arrows {
  207. display: flex;
  208. flex-direction: column;
  209. align-items: center;
  210. justify-content: flex-end;
  211. padding-left: 3px;
  212. .arrows-icon {
  213. width: 18rpx;
  214. height: 18rpx;
  215. &:first-child {
  216. transform: rotate(180deg);
  217. margin-bottom: -4rpx;
  218. }
  219. &:last-child {
  220. margin-top: -4rpx;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. .uni-table-td {
  227. padding-top: 20rpx;
  228. padding-bottom: 20rpx;
  229. .table-title {
  230. width: 100%;
  231. line-height: 1.2;
  232. }
  233. .title {
  234. line-height: 1.2;
  235. font-size: 28rpx;
  236. font-family: PingFang SC, PingFang SC-Bold;
  237. font-weight: 700;
  238. .title-sub {
  239. font-size: 24rpx;
  240. font-weight: 400;
  241. }
  242. }
  243. .title-num {
  244. padding-top: 18rpx;
  245. font-size: 24rpx;
  246. color: #9f9c9c;
  247. .iconfont {
  248. font-size: 22rpx;
  249. }
  250. }
  251. // <view class="table-title">
  252. // <view class="title">
  253. // <text>BTC</text>
  254. // <text class="title-sub">/USDT</text>
  255. // </view>
  256. // <view class="title-num">
  257. // 24H额:476.62m
  258. // </view>
  259. // </view>
  260. // &:nth-child(3n - 2) {
  261. // padding-left: $pages-padding;
  262. // }
  263. // &:nth-child(3n) {
  264. // padding-right: $pages-padding;
  265. // background-color: yellow;
  266. // text-align: right;
  267. // }
  268. // &:nth-child()
  269. }
  270. .table-btn {
  271. // 138
  272. width: 138rpx;
  273. height: 60rpx;
  274. border-radius: 6rpx;
  275. color: #fff;
  276. font-family: PingFang SC, PingFang SC-Bold;
  277. font-weight: 700;
  278. text-align: center;
  279. line-height: 60rpx;
  280. font-size: 26rpx;
  281. // margin-left: calc(100% - 138rpx);
  282. }
  283. }
  284. .table-right {
  285. display: flex;
  286. justify-content: flex-end;
  287. flex-direction: row;
  288. align-items: flex-end;
  289. }
  290. }
  291. </style>