info.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <!-- 公共组件 -->
  3. <div class="info">
  4. <v-head :title="'Deposit'"></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_symbol }}</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.token_chain }}</span> -->
  20. <span>BNB Smart Chain (BEP20)</span>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="info">
  25. <canvas id="canvas"></canvas>
  26. <div class="txt">{{ state.token_address }}</div>
  27. <div class="copy-btn" :data-clipboard-text="state.token_address">Copy</div>
  28. </div>
  29. <div class="tips">
  30. <div class="tips-icon">
  31. <img :src="require('@/assets/svg/icon-top-up-tips-warning.svg')" alt="">
  32. </div>
  33. <div class="tips-content">
  34. <p>Make sure you also selected </p>
  35. <p style="color: red;">BNB Smart Chain (BEP20) </p>
  36. <p>as the Network on the platform where you are withdrawing funds for this deposiit. Otherwise,
  37. you'll lose your assets.</p>
  38. </div>
  39. </div>
  40. </div>
  41. <!-- 底部 -->
  42. <div class="footer">
  43. <a-button class="confirm-btn" type="primary" shape="circle" :loading="state.loading" @click="clickDone">Done
  44. </a-button>
  45. </div>
  46. </div>
  47. </template>
  48. <script setup>
  49. import { onMounted, reactive, inject } from "vue";
  50. import VHead from '@/view/popup/components/head.vue'
  51. import { useRouter } from "vue-router";
  52. import { getTokenRechargeAddress } from "@/http/pay";
  53. import { message } from 'ant-design-vue';
  54. import { syncChainTokenRechargeRecord } from "@/http/publishApi";
  55. let top_up_info = inject('top_up_info')
  56. const router = useRouter()
  57. var QRCode = require('qrcode')
  58. var ClipboardJS = require('clipboard')
  59. let state = reactive({
  60. token_address: ''
  61. })
  62. const asyncTokenRechRecord = (cb) => {
  63. syncChainTokenRechargeRecord({
  64. params: {
  65. currencyCode: top_up_info.currency_code
  66. }
  67. }).then(res => {
  68. state.loading = false
  69. switch (res.code.toString()) {
  70. case "0":
  71. router.back()
  72. break
  73. default:
  74. // message.error(res.msg)
  75. break
  76. }
  77. })
  78. }
  79. const clickDone = () => {
  80. state.loading = true
  81. asyncTokenRechRecord()
  82. }
  83. const createQRCode = (str) => {
  84. var canvas = document.getElementById('canvas')
  85. QRCode.toCanvas(canvas, str, {
  86. width: 150,
  87. height: 150,
  88. scale: 10, color: {
  89. dark: '#000', // 二维码前景颜色
  90. light: '#F7F7F7' // 二维码背景颜色
  91. }
  92. }, function (error) {
  93. if (error) console.error(error)
  94. console.log('success!');
  95. })
  96. }
  97. const copyToken = () => {
  98. var clipboard = new ClipboardJS('.copy-btn');
  99. clipboard.on('success', function (e) {
  100. console.log(1)
  101. message.success('copy success');
  102. console.info('Action:', e.action);
  103. console.info('Text:', e.text);
  104. console.info('Trigger:', e.trigger);
  105. e.clearSelection();
  106. });
  107. clipboard.on('error', function (e) {
  108. message.error('copy error');
  109. console.error('Action:', e.action);
  110. console.error('Trigger:', e.trigger);
  111. });
  112. }
  113. onMounted(() => {
  114. getTokenRechargeAddress({
  115. params: {
  116. "tokenChain": top_up_info.token_chain
  117. },
  118. }).then((res) => {
  119. switch (res.code.toString()) {
  120. case '0':
  121. if (res.data && res.data.rechargeAddress) {
  122. state.token_address = res.data.rechargeAddress
  123. createQRCode(state.token_address)
  124. copyToken()
  125. }
  126. break;
  127. default:
  128. break;
  129. }
  130. })
  131. })
  132. </script>
  133. <style lang='scss' scoped>
  134. .info {
  135. position: relative;
  136. height: 100%;
  137. overflow-y: auto;
  138. .content {
  139. padding: 12px 16px 0 16px;
  140. .area-input-1 {
  141. .token {
  142. }
  143. .net {
  144. margin-top: 12px;
  145. }
  146. .token,
  147. .net {
  148. .title {
  149. font-weight: 500;
  150. font-size: 12px;
  151. margin-bottom: 6px;
  152. color: #8B8B8B;
  153. }
  154. .box {
  155. border: 1px solid #DBDBDB;
  156. border-radius: 8px;
  157. height: 44px;
  158. display: flex;
  159. align-items: center;
  160. padding: 0 15px 0 10px;
  161. display: flex;
  162. flex-wrap: nowrap;
  163. justify-content: space-between;
  164. img {
  165. width: 20px;
  166. height: 20px;
  167. }
  168. .up {
  169. width: 13px;
  170. height: 12px;
  171. cursor: pointer;
  172. }
  173. span {
  174. flex: 1;
  175. margin-left: 6px;
  176. font-size: 14px;
  177. font-weight: 500;
  178. }
  179. }
  180. }
  181. }
  182. .info {
  183. display: flex;
  184. flex-wrap: wrap;
  185. justify-content: center;
  186. background: #F7F7F7;
  187. border-radius: 18px;
  188. padding-bottom: 20px;
  189. margin-top: 12px;
  190. canvas {
  191. margin-top: 17px;
  192. }
  193. .txt {
  194. margin-top: 5px;
  195. font-weight: 400;
  196. font-size: 15px;
  197. width: 100%;
  198. text-align: center;
  199. word-break: break-all;
  200. }
  201. .copy-btn {
  202. cursor: pointer;
  203. margin-top: 5px;
  204. width: 160px;
  205. height: 40px;
  206. line-height: 38px;
  207. text-align: center;
  208. font-size: 16px;
  209. color: #1D9BF0;
  210. border: 1px solid #1D9BF0;
  211. border-radius: 100px;
  212. }
  213. }
  214. .tips {
  215. margin-top: 12px;
  216. font-size: 13px;
  217. height: 118;
  218. overflow: auto;
  219. background: #FCF5E5;
  220. display: flex;
  221. padding: 10px;
  222. border-radius: 10px;
  223. .tips-icon {
  224. width: 30px;
  225. img {
  226. width: 20px;
  227. height: 20px;
  228. }
  229. }
  230. .tips-content {
  231. flex: 1;
  232. }
  233. p {
  234. margin: 0;
  235. padding: 0;
  236. }
  237. }
  238. }
  239. .footer {
  240. height: 80px;
  241. width: 100%;
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. // position: absolute;
  246. // bottom: 0;
  247. .confirm-btn {
  248. width: 335px;
  249. height: 46px;
  250. text-align: center;
  251. border-radius: 100px;
  252. background: #1D9BF0;
  253. font-weight: 600;
  254. font-size: 18px;
  255. color: #fff;
  256. cursor: pointer;
  257. }
  258. }
  259. }
  260. </style>