info.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <!-- 公共组件 -->
  3. <div class="info">
  4. <v-head :title="'Top Up'"></v-head>
  5. <!-- 内容 -->
  6. <div class="content">
  7. <div class="area-input-1">
  8. <div class="token">
  9. <div class="title">Token</div>
  10. <div class="box">
  11. <img :src="top_up_info.icon_token" alt="">
  12. <span>{{ top_up_info.token }}</span>
  13. </div>
  14. </div>
  15. <div class="net">
  16. <div class="title">NetWork</div>
  17. <div class="box">
  18. <img :src="top_up_info.icon_net" alt="">
  19. <span>{{ top_up_info.net }}</span>
  20. </div>
  21. </div>
  22. </div>
  23. <div class="info">
  24. <canvas id="canvas"></canvas>
  25. <div class="txt">{{ state.token_address }}</div>
  26. <div class="copy-btn" :data-clipboard-text="'{{ state.token_address }}'">Copy</div>
  27. </div>
  28. <div class="tips">
  29. <div class="tip-title">TIPS</div>
  30. <p>1、请通过客户端或在线钱包将您需要充值的相应币种数目发送到该地址。</p>
  31. <p>2、发送完成后,系统会自动在此交易获得 相应数量确认后将该笔虚拟币充值到您在本站的账户,相应数量的确认需要大约 0.5 到 1 小时时间,请耐心等待</p>
  32. <p>3、同一个地址可多次充值,不影响到账。最小充值金额 0.0001。</p>
  33. </div>
  34. </div>
  35. <!-- 底部 -->
  36. <div class="footer">
  37. <div class="confirm-btn" @click="clickDone">
  38. Done
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script setup>
  44. import { onMounted, reactive, inject } from "vue";
  45. import VHead from '@/view/popup/components/head.vue'
  46. import { useRouter } from "vue-router";
  47. import { useRoute } from "vue-router";
  48. import { getTokenRechargeAddress } from "@/http/pay";
  49. import { message } from 'ant-design-vue';
  50. let top_up_info = inject('top_up_info')
  51. const router = useRouter()
  52. const route = useRoute()
  53. var QRCode = require('qrcode')
  54. var ClipboardJS = require('clipboard')
  55. let state = reactive({
  56. token_address: ''
  57. })
  58. const clickDone = () => {
  59. router.back()
  60. }
  61. const createQRCode = (str) => {
  62. var canvas = document.getElementById('canvas')
  63. QRCode.toCanvas(canvas, str, {
  64. width: 150,
  65. height: 150,
  66. scale: 10, color: {
  67. dark: '#000', // 二维码前景颜色
  68. light: '#F7F7F7' // 二维码背景颜色
  69. }
  70. }, function (error) {
  71. if (error) console.error(error)
  72. console.log('success!');
  73. })
  74. }
  75. const copyToken = () => {
  76. var clipboard = new ClipboardJS('.copy-btn');
  77. clipboard.on('success', function (e) {
  78. console.log(1)
  79. message.success('copy success');
  80. console.info('Action:', e.action);
  81. console.info('Text:', e.text);
  82. console.info('Trigger:', e.trigger);
  83. e.clearSelection();
  84. });
  85. clipboard.on('error', function (e) {
  86. message.error('copy error');
  87. console.error('Action:', e.action);
  88. console.error('Trigger:', e.trigger);
  89. });
  90. }
  91. onMounted(() => {
  92. getTokenRechargeAddress({
  93. params: {
  94. "tokenChain": top_up_info.net
  95. },
  96. }).then((res) => {
  97. switch (res.code.toString()) {
  98. case '0':
  99. if (res.data && res.data.rechargeAddress) {
  100. state.token_address = res.data.rechargeAddress
  101. createQRCode(state.token_address)
  102. copyToken()
  103. }
  104. break;
  105. default:
  106. break;
  107. }
  108. })
  109. })
  110. </script>
  111. <style lang='scss' scoped>
  112. .info {
  113. position: relative;
  114. height: 100%;
  115. .content {
  116. padding: 16px 16px 0 16px;
  117. .area-input-1 {
  118. display: flex;
  119. flex-wrap: nowrap;
  120. justify-content: space-between;
  121. .token,
  122. .net {
  123. width: 165px;
  124. .title {
  125. font-weight: 500;
  126. font-size: 12px;
  127. margin-bottom: 6px;
  128. color: #8B8B8B;
  129. }
  130. .box {
  131. border: 1px solid #DBDBDB;
  132. border-radius: 8px;
  133. height: 44px;
  134. display: flex;
  135. align-items: center;
  136. padding: 0 15px 0 10px;
  137. display: flex;
  138. flex-wrap: nowrap;
  139. justify-content: space-between;
  140. img {
  141. width: 20px;
  142. height: 20px;
  143. }
  144. .up {
  145. width: 13px;
  146. height: 12px;
  147. cursor: pointer;
  148. }
  149. span {
  150. flex: 1;
  151. margin-left: 6px;
  152. font-size: 14px;
  153. font-weight: 500;
  154. }
  155. }
  156. }
  157. }
  158. .info {
  159. display: flex;
  160. flex-wrap: wrap;
  161. justify-content: center;
  162. background: #F7F7F7;
  163. border-radius: 18px;
  164. padding-bottom: 20px;
  165. margin-top: 20px;
  166. canvas {
  167. margin-top: 17px;
  168. }
  169. .txt {
  170. margin-top: 5px;
  171. font-weight: 400;
  172. font-size: 15px;
  173. width: 100%;
  174. text-align: center;
  175. word-break: break-all;
  176. }
  177. .copy-btn {
  178. cursor: pointer;
  179. margin-top: 5px;
  180. width: 160px;
  181. height: 40px;
  182. line-height: 38px;
  183. text-align: center;
  184. font-size: 16px;
  185. color: #389AFF;
  186. border: 1px solid #389AFF;
  187. border-radius: 100px;
  188. }
  189. }
  190. .tips {
  191. margin-top: 14px;
  192. font-size: 13px;
  193. height: 80px;
  194. overflow: auto;
  195. .tip-title {
  196. color: #000000;
  197. }
  198. p {
  199. margin: 0;
  200. padding: 0;
  201. }
  202. }
  203. }
  204. .footer {
  205. height: 80px;
  206. width: 100%;
  207. display: flex;
  208. align-items: center;
  209. justify-content: center;
  210. position: absolute;
  211. bottom: 0;
  212. .confirm-btn {
  213. width: 335px;
  214. height: 46px;
  215. text-align: center;
  216. line-height: 46px;
  217. border-radius: 100px;
  218. background: #389aff;
  219. font-weight: 600;
  220. font-size: 18px;
  221. color: #fff;
  222. cursor: pointer;
  223. }
  224. }
  225. }
  226. </style>