info.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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 Report from "@/logcenter/log";
  55. import { syncChainTokenRechargeRecord } from "@/http/publishApi";
  56. let top_up_info = inject('top_up_info')
  57. const router = useRouter()
  58. var QRCode = require('qrcode')
  59. var ClipboardJS = require('clipboard')
  60. let state = reactive({
  61. token_address: ''
  62. })
  63. const asyncTokenRechRecord = (cb) => {
  64. syncChainTokenRechargeRecord({
  65. params: {
  66. currencyCode: top_up_info.currency_code
  67. }
  68. }).then(res => {
  69. state.loading = false
  70. switch (res.code.toString()) {
  71. case "0":
  72. router.back()
  73. break
  74. default:
  75. // message.error(res.msg)
  76. break
  77. }
  78. })
  79. }
  80. const clickDone = () => {
  81. state.loading = true
  82. asyncTokenRechRecord()
  83. }
  84. const createQRCode = (str) => {
  85. var canvas = document.getElementById('canvas')
  86. QRCode.toCanvas(canvas, str, {
  87. width: 150,
  88. height: 150,
  89. scale: 10, color: {
  90. dark: '#000', // 二维码前景颜色
  91. light: '#F7F7F7' // 二维码背景颜色
  92. }
  93. }, function (error) {
  94. if (error) console.error(error)
  95. console.log('success!');
  96. })
  97. }
  98. const copyToken = () => {
  99. var clipboard = new ClipboardJS('.copy-btn');
  100. clipboard.on('success', function (e) {
  101. console.log(1)
  102. message.success('copy success');
  103. console.info('Action:', e.action);
  104. console.info('Text:', e.text);
  105. console.info('Trigger:', e.trigger);
  106. e.clearSelection();
  107. });
  108. clipboard.on('error', function (e) {
  109. message.error('copy error');
  110. console.error('Action:', e.action);
  111. console.error('Trigger:', e.trigger);
  112. });
  113. }
  114. onMounted(() => {
  115. Report.reportLog({
  116. pageSource: Report.pageSource.denetSelector,
  117. businessType: Report.businessType.pageView,
  118. });
  119. getTokenRechargeAddress({
  120. params: {
  121. "tokenChain": top_up_info.token_chain
  122. },
  123. }).then((res) => {
  124. switch (res.code.toString()) {
  125. case '0':
  126. if (res.data && res.data.rechargeAddress) {
  127. state.token_address = res.data.rechargeAddress
  128. createQRCode(state.token_address)
  129. copyToken()
  130. }
  131. break;
  132. default:
  133. break;
  134. }
  135. })
  136. })
  137. </script>
  138. <style lang='scss' scoped>
  139. .info {
  140. position: relative;
  141. height: 100%;
  142. overflow-y: auto;
  143. .content {
  144. padding: 12px 16px 0 16px;
  145. .area-input-1 {
  146. .token {
  147. }
  148. .net {
  149. margin-top: 12px;
  150. }
  151. .token,
  152. .net {
  153. .title {
  154. font-weight: 500;
  155. font-size: 12px;
  156. margin-bottom: 6px;
  157. color: #8B8B8B;
  158. }
  159. .box {
  160. border: 1px solid #DBDBDB;
  161. border-radius: 8px;
  162. height: 44px;
  163. display: flex;
  164. align-items: center;
  165. padding: 0 15px 0 10px;
  166. display: flex;
  167. flex-wrap: nowrap;
  168. justify-content: space-between;
  169. img {
  170. width: 20px;
  171. height: 20px;
  172. }
  173. .up {
  174. width: 13px;
  175. height: 12px;
  176. cursor: pointer;
  177. }
  178. span {
  179. flex: 1;
  180. margin-left: 6px;
  181. font-size: 14px;
  182. font-weight: 500;
  183. }
  184. }
  185. }
  186. }
  187. .info {
  188. display: flex;
  189. flex-wrap: wrap;
  190. justify-content: center;
  191. background: #F7F7F7;
  192. border-radius: 18px;
  193. padding-bottom: 20px;
  194. margin-top: 12px;
  195. canvas {
  196. margin-top: 17px;
  197. }
  198. .txt {
  199. margin-top: 5px;
  200. font-weight: 400;
  201. font-size: 15px;
  202. width: 100%;
  203. text-align: center;
  204. word-break: break-all;
  205. }
  206. .copy-btn {
  207. cursor: pointer;
  208. margin-top: 5px;
  209. width: 160px;
  210. height: 40px;
  211. line-height: 38px;
  212. text-align: center;
  213. font-size: 16px;
  214. color: #1D9BF0;
  215. border: 1px solid #1D9BF0;
  216. border-radius: 100px;
  217. }
  218. }
  219. .tips {
  220. margin-top: 12px;
  221. font-size: 13px;
  222. height: 118;
  223. overflow: auto;
  224. background: #FCF5E5;
  225. display: flex;
  226. padding: 10px;
  227. border-radius: 10px;
  228. .tips-icon {
  229. width: 30px;
  230. img {
  231. width: 20px;
  232. height: 20px;
  233. }
  234. }
  235. .tips-content {
  236. flex: 1;
  237. }
  238. p {
  239. margin: 0;
  240. padding: 0;
  241. }
  242. }
  243. }
  244. .footer {
  245. height: 80px;
  246. width: 100%;
  247. display: flex;
  248. align-items: center;
  249. justify-content: center;
  250. // position: absolute;
  251. // bottom: 0;
  252. .confirm-btn {
  253. width: 335px;
  254. height: 46px;
  255. text-align: center;
  256. border-radius: 100px;
  257. background: #1D9BF0;
  258. font-weight: 600;
  259. font-size: 18px;
  260. color: #fff;
  261. cursor: pointer;
  262. }
  263. }
  264. }
  265. </style>