recharge.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. this.qianBao()
  77. },
  78. methods: {
  79. // 二维码地址
  80. async qianBao() {
  81. const res = await qianBao()
  82. console.log('qian', res);
  83. this.address = res.data.back.USDT.address
  84. },
  85. // 复制地址
  86. copy(value) {
  87. uni.setClipboardData({
  88. data: value,
  89. success: function () {
  90. //调用方法成功
  91. console.log("success");
  92. },
  93. });
  94. },
  95. savePic(Url){
  96. Url = this.address //图片路径,也可以传值进来
  97. var triggerEvent = "touchstart"; //指定下载方式
  98. var blob=new Blob([''], {type:'application/octet-stream'}); //二进制大型对象blob
  99. var url = URL.createObjectURL(blob); //创建一个字符串路径空位
  100. var a = document.createElement('a'); //创建一个 a 标签
  101. a.href = Url; //把路径赋到a标签的href上
  102. //正则表达式,这里是把图片文件名分离出来。拿到文件名赋到a.download,作为文件名来使用文本
  103. a.download = Url.replace(/(.*\/)*([^.]+.*)/ig,"$2").split("?")[0];
  104. var e = new MouseEvent('click', ( true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null));
  105. //派遣后,它将不再执行任何操作。执行保存到本地
  106. a.dispatchEvent(e);
  107. //释放一个已经存在的路径(有创建createObjectURL就要释放revokeObjectURL)
  108. URL.revokeObjectURL(url);
  109. },
  110. },
  111. };
  112. </script>
  113. <style lang="scss">
  114. .all {
  115. width: 750rpx;
  116. height: 1416rpx;
  117. background-color: $page-color-base;
  118. }
  119. .top {
  120. margin-left: 28rpx;
  121. padding-top: 50rpx;
  122. width: 690rpx;
  123. height: 720rpx;
  124. background: #191a1f;
  125. border-radius: 20rpx;
  126. display: flex;
  127. flex-direction: column;
  128. }
  129. .topO {
  130. height: 31rpx;
  131. font-size: 32rpx;
  132. font-family: PingFang SC;
  133. font-weight: bold;
  134. color: #ffffff;
  135. line-height: 24rpx;
  136. margin-left: 21rpx;
  137. margin-top: 37rpx;
  138. }
  139. .topT {
  140. margin-left: 20rpx;
  141. margin-top: 30rpx;
  142. width: 218rpx;
  143. height: 68rpx;
  144. border: 2px solid #ddba82;
  145. border-radius: 10rpx;
  146. }
  147. .tt {
  148. width: 168rpx;
  149. height: 20rpx;
  150. font-size: 26rpx;
  151. font-weight: bold;
  152. color: #feb041;
  153. line-height: 24rpx;
  154. margin-top: 20rpx;
  155. margin-left: 23rpx;
  156. }
  157. .topS {
  158. display: flex;
  159. justify-content: start;
  160. }
  161. .S {
  162. height: 31rpx;
  163. font-size: 32rpx;
  164. font-weight: bold;
  165. color: #ffffff;
  166. line-height: 24rpx;
  167. margin-left: 23rpx;
  168. margin-top: 26rpx;
  169. }
  170. .SS {
  171. height: 20rpx;
  172. font-size: 26rpx;
  173. font-weight: 500;
  174. color: #ffffff;
  175. line-height: 24rpx;
  176. margin-left: 23rpx;
  177. margin-top: 26rpx;
  178. }
  179. .SSS {
  180. width: 29rpx;
  181. height: 29rpx;
  182. margin-left: 23rpx;
  183. margin-top: 24rpx;
  184. }
  185. .buttom {
  186. margin-left: 30rpx;
  187. margin-top: 30rpx;
  188. width: 690rpx;
  189. // height: 100vh;
  190. background: #191a1f;
  191. border-radius: 20rpx;
  192. }
  193. .but {
  194. margin-left: 27rpx;
  195. padding-top: 50rpx;
  196. padding-bottom: 50rpx;
  197. width: 625rpx;
  198. // height: 114rpx;
  199. font-size: 26rpx;
  200. font-weight: 500;
  201. color: #ffffff;
  202. line-height: 45rpx;
  203. }
  204. .topF {
  205. // flex: 1;
  206. margin-top: 34rpx;
  207. display: flex;
  208. align-items: center;
  209. justify-content: center;
  210. }
  211. .qr{
  212. width: 275rpx;
  213. height: 275rpx;
  214. display: flex;
  215. align-items: center;
  216. justify-content: center;
  217. background-color: #fff;
  218. }
  219. .last {
  220. display: flex;
  221. justify-content: center;
  222. }
  223. .le {
  224. margin-top: 43rpx;
  225. width: 201rpx;
  226. height: 59rpx;
  227. border: 2px solid #DDBA82;
  228. border-radius: 10rpx;
  229. }
  230. .lef {
  231. margin-top: 12rpx;
  232. margin-left: 49rpx;
  233. height: 25rpx;
  234. font-size: 26rpx;
  235. font-family: PingFang SC;
  236. font-weight: bold;
  237. color: #FEB041;
  238. line-height: 24rpx;
  239. }
  240. </style>