recharge.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view class="all">
  3. <view class="top">
  4. <view class="topO"> {{$t('userinfo.u4')}} </view>
  5. <view class="topT">
  6. <view class="tt">USDT-TRC20</view>
  7. </view>
  8. <view class="topS">
  9. <view class="S">{{$t('userinfo.u1')}}</view>
  10. <view
  11. class="SS"
  12. >{{ address }}</view
  13. >
  14. <image
  15. class="SSS"
  16. src="/static/icon/cz.png"
  17. mode=""
  18. @click="copy(address)">
  19. </image>
  20. </view>
  21. <!-- 根据地址生成二维码 -->
  22. <view class="topF">
  23. <view class="qr">
  24. <canvas
  25. id="qrcode"
  26. canvas-id="qrcode"
  27. style="width: 120px; height: 120px"></canvas>
  28. </view>
  29. </view>
  30. <view class="last">
  31. <view class="le" @click="savePic">
  32. <view class="lef">{{$t('userinfo.u2')}}</view>
  33. </view>
  34. <view class="le" style="margin-left: 30rpx;">
  35. <view class="lef" @click="copy(address)">{{$t('userinfo.u3')}}</view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="buttom">
  40. <view class="but">
  41. {{$t('userinfo.u5')}}
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import {qianBao} from "@/api/wallet.js"
  48. import UQRCode from "@/components/uqrcodejs/uqrcode.js"; // npm install uqrcodejs
  49. export default {
  50. data() {
  51. return {
  52. address: '',
  53. };
  54. },
  55. mounted() {},
  56. onReady() {
  57. // 获取uQRCode实例
  58. var qr = new UQRCode();
  59. // 设置二维码内容
  60. qr.data = this.address;
  61. // 设置二维码大小,必须与canvas设置的宽高一致
  62. qr.size = 120;
  63. // 调用制作二维码方法
  64. qr.make();
  65. // 获取canvas上下文
  66. var canvasContext = uni.createCanvasContext("qrcode", this); // 如果是组件,this必须传入
  67. // 设置uQRCode实例的canvas上下文
  68. qr.canvasContext = canvasContext;
  69. // 调用绘制方法将二维码图案绘制到canvas上
  70. qr.drawCanvas();
  71. },
  72. onLoad() {
  73. uni.setNavigationBarTitle({
  74. title: this.$t("tab.a3"),
  75. });
  76. uni.setNavigationBarColor({
  77. frontColor: '#ffffff',
  78. backgroundColor: '#000000',
  79. });
  80. this.qianBao()
  81. },
  82. methods: {
  83. // 二维码地址
  84. async qianBao() {
  85. const res = await qianBao()
  86. console.log('qian', res);
  87. this.address = res.data.back.USDT.address
  88. },
  89. // 复制地址
  90. copy(value) {
  91. uni.setClipboardData({
  92. data: value,
  93. success: function () {
  94. //调用方法成功
  95. console.log("success");
  96. },
  97. });
  98. },
  99. savePic(Url){
  100. Url = this.address //图片路径,也可以传值进来
  101. var triggerEvent = "touchstart"; //指定下载方式
  102. var blob=new Blob([''], {type:'application/octet-stream'}); //二进制大型对象blob
  103. var url = URL.createObjectURL(blob); //创建一个字符串路径空位
  104. var a = document.createElement('a'); //创建一个 a 标签
  105. a.href = Url; //把路径赋到a标签的href上
  106. //正则表达式,这里是把图片文件名分离出来。拿到文件名赋到a.download,作为文件名来使用文本
  107. a.download = Url.replace(/(.*\/)*([^.]+.*)/ig,"$2").split("?")[0];
  108. var e = new MouseEvent('click', ( true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null));
  109. //派遣后,它将不再执行任何操作。执行保存到本地
  110. a.dispatchEvent(e);
  111. //释放一个已经存在的路径(有创建createObjectURL就要释放revokeObjectURL)
  112. URL.revokeObjectURL(url);
  113. },
  114. },
  115. };
  116. </script>
  117. <style lang="scss">
  118. .all {
  119. width: 750rpx;
  120. height: 1416rpx;
  121. background-color: $page-color-base;
  122. }
  123. .top {
  124. margin-left: 28rpx;
  125. padding-top: 50rpx;
  126. width: 690rpx;
  127. height: 720rpx;
  128. background: #191a1f;
  129. border-radius: 20rpx;
  130. display: flex;
  131. flex-direction: column;
  132. }
  133. .topO {
  134. height: 31rpx;
  135. font-size: 32rpx;
  136. font-family: PingFang SC;
  137. font-weight: bold;
  138. color: #ffffff;
  139. line-height: 24rpx;
  140. margin-left: 21rpx;
  141. margin-top: 37rpx;
  142. }
  143. .topT {
  144. margin-left: 20rpx;
  145. margin-top: 30rpx;
  146. width: 218rpx;
  147. height: 68rpx;
  148. border: 2px solid #ddba82;
  149. border-radius: 10rpx;
  150. }
  151. .tt {
  152. width: 168rpx;
  153. height: 20rpx;
  154. font-size: 26rpx;
  155. font-weight: bold;
  156. color: #feb041;
  157. line-height: 24rpx;
  158. margin-top: 20rpx;
  159. margin-left: 23rpx;
  160. }
  161. .topS {
  162. display: flex;
  163. justify-content: start;
  164. }
  165. .S {
  166. height: 31rpx;
  167. font-size: 32rpx;
  168. font-weight: bold;
  169. color: #ffffff;
  170. line-height: 24rpx;
  171. margin-left: 23rpx;
  172. margin-top: 26rpx;
  173. }
  174. .SS {
  175. height: 20rpx;
  176. font-size: 26rpx;
  177. font-weight: 500;
  178. color: #ffffff;
  179. line-height: 24rpx;
  180. margin-left: 23rpx;
  181. margin-top: 26rpx;
  182. }
  183. .SSS {
  184. width: 29rpx;
  185. height: 29rpx;
  186. margin-left: 23rpx;
  187. margin-top: 24rpx;
  188. }
  189. .buttom {
  190. margin-left: 30rpx;
  191. margin-top: 30rpx;
  192. width: 690rpx;
  193. // height: 100vh;
  194. background: #191a1f;
  195. border-radius: 20rpx;
  196. }
  197. .but {
  198. margin-left: 27rpx;
  199. padding-top: 50rpx;
  200. padding-bottom: 50rpx;
  201. width: 625rpx;
  202. // height: 114rpx;
  203. font-size: 26rpx;
  204. font-weight: 500;
  205. color: #ffffff;
  206. line-height: 45rpx;
  207. }
  208. .topF {
  209. // flex: 1;
  210. margin-top: 34rpx;
  211. display: flex;
  212. align-items: center;
  213. justify-content: center;
  214. }
  215. .qr{
  216. width: 275rpx;
  217. height: 275rpx;
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. background-color: #fff;
  222. }
  223. .last {
  224. display: flex;
  225. justify-content: center;
  226. }
  227. .le {
  228. margin-top: 43rpx;
  229. width: 201rpx;
  230. height: 59rpx;
  231. border: 2px solid #DDBA82;
  232. border-radius: 10rpx;
  233. }
  234. .lef {
  235. margin-top: 12rpx;
  236. margin-left: 49rpx;
  237. height: 25rpx;
  238. font-size: 26rpx;
  239. font-family: PingFang SC;
  240. font-weight: bold;
  241. color: #FEB041;
  242. line-height: 24rpx;
  243. }
  244. </style>