contract-miao.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <v-page>
  3. <view class="head_info p-t-xl" style="padding-bottom:60px">
  4. <view class="w-12/12 p-b-lg">
  5. <view class="d-flex align-center p-l-md p-b-md">
  6. <view class="w-6/12 p-l-md d-flex justify-center">{{$t("base.g7")}}</view>
  7. <view class="w-3/12">{{$t("base.g8")}}</view>
  8. <view class="w-3/12 ">{{$t("base.g9")}}</view>
  9. </view>
  10. <view class="fn-center w-max">
  11. <v-link :to="{
  12. path: '/pages/exchange/contract-miao-detail',
  13. query: { code: item.coin_name },
  14. }"
  15. class="m-b-md m-x-md rounded-sm bg-panel-7 box-shadow link-active d-flex align-center p-r-md p-y-md box-size"
  16. v-for="item in marketList" :key="item.coin_name">
  17. <view class="fn-18 w-2/12 d-flex align-center justify-center">
  18. <!-- app.imgUrl+'/'+ -->
  19. <image class="d-block h-30 w-30" :src="item.logo" alt="" mode="widthFix"></image>
  20. </view>
  21. <view class="color-light fn-left w-4/12">
  22. <view class="d-flex align-end fn-bold">{{
  23. item.coin_name
  24. }}</view>
  25. <view class="" style="font-size: 24rpx;" v-if="item.monovalent&&item.monovalent.vol">
  26. {{$t('base.f8')}}:{{Number(parseFloat(item.monovalent.vol).toFixed(0)).toLocaleString('en-US')}}
  27. </view>
  28. </view>
  29. <view class="fn-left align-end color-light w-3/12">
  30. <view class="d-flex align-end fn-bold " style="margin-left: 23%;">{{
  31. item.monovalent.close
  32. }}</view>
  33. </view>
  34. <view style=" margin-left: 10%; width:120rpx;height: 45rpx; border-radius: 5rpx;"
  35. :style="item.monovalent.increase * 1 < 0 ? 'background-color: #df3f73;':'background-color:#1ec692'">
  36. <view class="fn-bold " style="margin-top: 4%; color:ivory ">
  37. {{ item.monovalent.increaseStr }}
  38. </view>
  39. </view>
  40. </v-link>
  41. </view>
  42. </view>
  43. </view>
  44. </v-page>
  45. </template>
  46. <script>
  47. import Contract from "@/api/contract";
  48. import app from "@/app.js"
  49. import {
  50. mapState
  51. } from "vuex";
  52. export default {
  53. data() {
  54. return {
  55. marketList: [],
  56. app
  57. };
  58. },
  59. computed: {
  60. ...mapState({
  61. ws: "ws"
  62. }),
  63. },
  64. onLoad() {
  65. console.log(123)
  66. this.getMaketList()
  67. },
  68. methods: {
  69. // 链接socket
  70. linkSocket() {
  71. this.getMaketList()
  72. let msg = "indexMarketList";
  73. this.ws.send({
  74. cmd: "sub",
  75. msg: "indexMarketList",
  76. });
  77. this.ws.on("message", (res) => {
  78. let {
  79. data,
  80. sub
  81. } = res;
  82. if (sub == "indexMarketList") {
  83. res = data[0]['marketInfoList'];
  84. for (var i=0;i<res.length;i++) {
  85. for (var a=0;a<this.marketList.length;a++) {
  86. if(this.marketList[a].coin_name == res[i].pair_name){
  87. this.marketList[a].monovalent.increaseStr = res[i].increaseStr
  88. this.marketList[a].monovalent.close = res[i].close
  89. this.marketList[a].monovalent.vol = res[i].vol
  90. this.marketList[a].logo = res[i].coin_icon
  91. }
  92. }
  93. }
  94. this.$forceUpdate()
  95. }
  96. });
  97. },
  98. destroyed() {
  99. this.ws.send({
  100. cmd: "unsub",
  101. msg: "indexMarketList",
  102. });
  103. },
  104. getMaketList(){
  105. Contract.marketListM().then((res)=>{
  106. this.marketList = res.data
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss">
  113. </style>