capital-switch.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <view class="">
  3. <switchPopup ref="switchPopupRef" :availableMoney="getBiMoney(from_field)" :from_field="from_field" :to_field="to_field">
  4. <template #accountbox>
  5. <view class="account-item" @click.stop="from_field !== 'change' ? selectBiType(from_field) : ''">
  6. <text class="account-item-lable">{{ getBiName(from_field) }}账户</text>
  7. <text class="iconfont" v-show="from_field !== 'change'">&#xe601;</text>
  8. </view>
  9. <view class="account-link" @click.stop="switchBiType">
  10. <text class="iconfont">&#xe607;</text>
  11. <text>划转</text>
  12. </view>
  13. <view class="account-item" @click.stop="to_field !== 'change' ? selectBiType(to_field) : ''">
  14. <text class="account-item-lable">{{ getBiName(to_field) }}账户</text>
  15. <text class="iconfont" v-show="to_field !== 'change'">&#xe601;</text>
  16. </view>
  17. </template>
  18. </switchPopup>
  19. <settingBi ref="settingBiRef" :activeBiType.sync="activeBiType"/>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. mapGetters
  25. } from 'vuex'
  26. import {
  27. biName
  28. } from "../card.js"
  29. import settingBi from "./setting-bi.vue"
  30. import switchPopup from "../switch.vue"
  31. // 合约 - 币币
  32. // 币币 - 合约 / 法币
  33. export default {
  34. name: "capitalSwitchModules",
  35. data() {
  36. return {
  37. from_field: 'change',
  38. to_field: 'lever',
  39. activeBiType: ''
  40. };
  41. },
  42. watch: {
  43. activeBiType: {
  44. handler(newType, oldType) {
  45. if (oldType === this.from_field) {
  46. this.from_field = newType
  47. }
  48. if (oldType === this.to_field) {
  49. this.to_field = newType
  50. };
  51. },
  52. immediate: true
  53. }
  54. },
  55. components: {
  56. settingBi,
  57. switchPopup
  58. },
  59. computed: {
  60. ...mapGetters([
  61. 'contractAccount',
  62. 'bibiAccount',
  63. 'legalAccount'
  64. ]),
  65. getBiName() {
  66. return function(key) {
  67. return biName[key]
  68. }
  69. },
  70. getBiMoney() {
  71. return function(key) {
  72. let nums = 0;
  73. switch (key) {
  74. case 'lever':
  75. nums = this.contractAccount.usdt_totle
  76. break;
  77. case 'change':
  78. nums = this.bibiAccount.usdt_totle
  79. break;
  80. case 'legal':
  81. nums = this.legalAccount.usdt_totle
  82. break;
  83. };
  84. return nums || 0
  85. }
  86. }
  87. },
  88. mounted() {
  89. },
  90. methods: {
  91. // 切换币
  92. switchBiType() {
  93. const k = this.from_field;
  94. this.from_field = this.to_field;
  95. this.to_field = k;
  96. // this.from_field:'legal',
  97. // to_field:'change'
  98. },
  99. open() {
  100. this.$nextTick(() => {
  101. this.$refs.switchPopupRef.open();
  102. })
  103. },
  104. selectBiType(val) {
  105. this.activeBiType = val
  106. console.log('selectBiType = ', this.activeBiType)
  107. this.$nextTick(() => {
  108. this.$refs.settingBiRef.open()
  109. })
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss" scoped>
  115. @import "~./../switch.scss";
  116. </style>