transfer.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <template>
  2. <view class="container">
  3. <view class="listBox">
  4. <view class="titleTetx">{{$t('user.收款地址')}}</view>
  5. <view class="flex listTpl">
  6. <input type="text" class="inputBox" v-model="address" :placeholder="$t('user.请输入收款地址')" />
  7. </view>
  8. </view>
  9. <view class="listBox" style="padding-top: 0rpx;">
  10. <view class="titleTetx">{{$t('user.转账数量')}}</view>
  11. <view class="listTpl flex">
  12. <input type="number" class="inputBox" v-model="number" :placeholder="$t('user.请输入转账金额')" />
  13. <view class="listAll" @click="number=money">{{$t('user.全部')}}</view>
  14. </view>
  15. <view class="flex tipBox">
  16. <view class="tip1">{{$t('user.可用余额')}}{{money||0}}{{type}}</view>
  17. </view>
  18. </view>
  19. <view class="submission">
  20. <button class="golden" type="golden" hover-class="none" @click="submission">{{$t('user.确认转账')}}</button>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. trade
  27. } from '@/api/index.js';
  28. import {
  29. getUserInfo
  30. } from '@/api/user.js';
  31. import {
  32. mapState,
  33. } from "vuex";
  34. export default {
  35. data() {
  36. return {
  37. address: '',
  38. number: '',
  39. money: 0,
  40. type: '',
  41. };
  42. },
  43. computed: {
  44. ...mapState("user", ['userInfo']),
  45. },
  46. onLoad(option) {
  47. this.type = option.type;
  48. this.getUserInfo();
  49. },
  50. methods: {
  51. getUserInfo() {
  52. const that = this;
  53. getUserInfo({}).then(
  54. (res) => {
  55. that.money = +res.data[that.type];
  56. }
  57. ).catch(
  58. (res) => {
  59. console.log(res)
  60. }
  61. )
  62. },
  63. submission() {
  64. const that = this;
  65. const USER_TRADE = 'USER_TRADE' + (new Date()).getTime();
  66. ethereum.request({
  67. "method": "personal_sign",
  68. "params": [
  69. USER_TRADE,
  70. that.userInfo.address
  71. ]
  72. }).then((res) => {
  73. trade({
  74. token: that.type,
  75. num: that.number,
  76. address: that.address,
  77. sign: res,
  78. msg: USER_TRADE,
  79. }).then((res) => {
  80. uni.showToast({
  81. title: res.msg,
  82. duration: 1500,
  83. });
  84. that.number = '';
  85. that.address='';
  86. that.getUserInfo();
  87. }).catch(
  88. (res) => {
  89. }
  90. )
  91. });
  92. }
  93. }
  94. };
  95. </script>
  96. <style lang="scss">
  97. .container {
  98. padding: 25rpx 25rpx;
  99. background-color: rgb(12, 8, 21);
  100. min-height: 100vh;
  101. }
  102. .listBox {
  103. padding: 46rpx 25rpx;
  104. background: rgba(255, 255, 255, .09);
  105. border-radius: 10rpx;
  106. .titleTetx {
  107. font-weight: bold;
  108. font-size: 24rpx;
  109. color: #FFFFFF;
  110. padding-bottom: 25rpx;
  111. }
  112. .tipBox {
  113. padding-top: 15rpx;
  114. font-size: 24rpx;
  115. .tip1 {
  116. font-family: PingFang SC;
  117. font-weight: 500;
  118. font-size: 26rpx;
  119. color: #0C5AFA;
  120. line-height: 45rpx;
  121. }
  122. }
  123. }
  124. .listTpl {
  125. border-bottom: 1rpx solid #6A7288;
  126. padding-bottom: 25rpx;
  127. .inputBox {
  128. font-size: 35rpx;
  129. color: #FFFFFF;
  130. }
  131. .listTip {}
  132. .listAll {
  133. padding-left: 30rpx;
  134. font-size: 30rpx;
  135. color: #0C5AFA;
  136. }
  137. }
  138. .input-placeholder {
  139. font-family: PingFang SC;
  140. font-weight: 500;
  141. font-size: 26rpx;
  142. color: #666666;
  143. }
  144. .submission {
  145. padding: 80rpx 25rpx;
  146. padding-bottom: 25rpx;
  147. .golden {
  148. background: linear-gradient(90deg, #7D32FF, #3EE0FF);
  149. color: #ffffff;
  150. }
  151. }
  152. </style>