chongzhi.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="content">
  3. <view class="trc-tit">
  4. 一、TRC20充值地址
  5. </view>
  6. <view class="code-content">
  7. <tki-qrcode :cid="cid" ref="qrcode" :val="val" :size="size" :unit="unit" :background="background"
  8. :foreground="foreground" :pdground="pdground" :iconSize="iconSize" :lv="lv" :onval="onval"
  9. :loadMake="loadMake" :usingComponents="usingComponents" @result="qrR" />
  10. </view>
  11. <text style="padding-left: 15rpx;display: inline-block;word-break: break-all;text-align: center;">
  12. </text>
  13. <view class="" style="width: 750rpx;text-align: center;">
  14. {{val}}
  15. </view>
  16. <view class="trc-dz flex" style="justify-content: flex-start;align-items: flex-start;">
  17. <!-- <text class="" style="width: 100rpx;display: inline-block;flex-shrink: 0;">
  18. 地址:
  19. </text> -->
  20. </view>
  21. <view class="copy-btn" @click="comfirm(val)">
  22. 复制地址
  23. </view>
  24. <view class="trc-tit" style="margin-top: 50rpx;">
  25. 二、上传支付凭证
  26. </view>
  27. <view class="up-img" @click="imgsub">
  28. <image :src="upimg" mode="" v-if="upimg"></image>
  29. <image src="../../static/img/add.png" mode="" v-else></image>
  30. </view>
  31. <!-- <view class="" style="text-align: center;font-size: 28rpx;">
  32. 请输入充值金额
  33. </view> -->
  34. <input type="text" v-model="payNum" placeholder="请输入充值金额"
  35. style="text-align: center;display: block;width: 350rpx;margin:20rpx auto 40rpx;border: 1rpx solid #d9ad7c;line-height: 70rpx;height: 70rpx;border-radius: 10rpx;">
  36. <view class="up-btn" @click="upPz">
  37. 提交凭证
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import tkiQrcode from '@/components/tki-qrcode/tki-qrcode.vue';
  43. import {
  44. upload
  45. } from '@/api/order.js';
  46. import {
  47. upPz,
  48. getQr,
  49. } from '@/api/index.js'
  50. export default {
  51. comments: {
  52. tkiQrcode
  53. },
  54. data() {
  55. return {
  56. cid: 'tki-qrcode-canvas', //canvasId,页面存在多个二维码组件时需设置不同的ID
  57. size: 300, //生成的二维码大小
  58. unit: 'upx', //大小单位尺寸
  59. show: true, //默认使用组件中的image标签显示二维码
  60. val: '', //要生成的内容
  61. background: '#ffffff', //二维码背景色
  62. foreground: '#333333', //二维码前景色
  63. pdground: '#333333', //二维码角标色
  64. icon: '', //二维码图标URL(必须是本地图片,网络图需要先下载至本地)
  65. iconSize: 40, //二维码图标大小
  66. lv: 3, //容错级别
  67. onval: true, //监听val值变化自动重新生成二维码
  68. loadMake: true, //组件初始化完成后自动生成二维码,val需要有值
  69. usingComponents: false, //是否使用了自定义组件模式(主要是为了修复非自定义组件模式时 v-if 无法生成二维码的问题)
  70. showLoading: false, //是否显示loading
  71. loadingText: '二维码生成中', //loading文字
  72. src: '', // 二维码生成后的图片地址或base64
  73. ratio: 1, //页面比例用于计算
  74. ctxSrc: '', //要显示的图片
  75. loading: true, //是否载入图片中
  76. canHeight: '', //画布高度
  77. canWeidth: '', //画布宽度
  78. upimg: '', //凭证
  79. payNum: '', //充值金额
  80. loading: false
  81. }
  82. },
  83. onLoad() {
  84. this.getQr()
  85. },
  86. onShow() {
  87. },
  88. onReachBottom() {
  89. },
  90. onReady() {
  91. },
  92. methods: {
  93. // 上传图片
  94. imgsub() {
  95. console.log('imgsub');
  96. upload({
  97. filename: ''
  98. }).then(data => {
  99. this.upimg = data[0].url;
  100. console.log(data[0].url)
  101. });
  102. },
  103. comfirm(text) {
  104. console.log(text);
  105. const result = this.uniCopy(text);
  106. if (result === false) {
  107. uni.showToast({
  108. title: '不支持'
  109. });
  110. } else {
  111. uni.showToast({
  112. title: '复制成功',
  113. icon: 'none'
  114. });
  115. }
  116. this.$refs.popupkf.close();
  117. },
  118. uniCopy(content) {
  119. /**
  120. * 小程序端 和 app端的复制逻辑
  121. */
  122. //#ifndef H5
  123. uni.setClipboardData({
  124. data: content,
  125. success: function() {
  126. console.log('success');
  127. return true;
  128. }
  129. });
  130. //#endif
  131. /**
  132. * H5端的复制逻辑
  133. */
  134. // #ifdef H5
  135. if (!document.queryCommandSupported('copy')) {
  136. //为了兼容有些浏览器 queryCommandSupported 的判断
  137. // 不支持
  138. return false;
  139. }
  140. let textarea = document.createElement('textarea');
  141. textarea.value = content;
  142. textarea.readOnly = 'readOnly';
  143. document.body.appendChild(textarea);
  144. textarea.select(); // 选择对象
  145. textarea.setSelectionRange(0, content.length); //核心
  146. let result = document.execCommand('copy'); // 执行浏览器复制命令
  147. textarea.remove();
  148. return result;
  149. // #endif
  150. },
  151. // 获取地址
  152. getQr() {
  153. let obj = this
  154. getQr().then(res => {
  155. console.log(res)
  156. obj.val = res.data[0]
  157. })
  158. },
  159. qrR() {
  160. },
  161. // 上传凭证
  162. upPz() {
  163. let obj = this
  164. if (obj.upimg == '') {
  165. return obj.$api.msg('请选择要上传的凭证')
  166. }
  167. if (obj.payNum == '') {
  168. return obj.$api.msg('请输入充值金额')
  169. }
  170. if (obj.loading) {
  171. return
  172. }
  173. obj.loading = true
  174. upPz({
  175. image: obj.upimg,
  176. money: obj.payNum
  177. }).then(res => {
  178. console.log(res)
  179. uni.showToast({
  180. title: '提交成功',
  181. duration: 2000
  182. });
  183. obj.loading = false
  184. })
  185. },
  186. }
  187. }
  188. </script>
  189. <style lang="scss">
  190. page {
  191. background: #fff;
  192. height: 100%;
  193. }
  194. .copy-btn {
  195. width: 200rpx;
  196. border-radius: 50rpx;
  197. height: 50rpx;
  198. border: 1rpx solid #eccca2;
  199. margin: auto;
  200. text-align: center;
  201. color: #d9ad7c;
  202. font-size: 32rpx;
  203. line-height: 50rpx;
  204. }
  205. .content {
  206. background-color: #fff;
  207. }
  208. .code-content {
  209. width: 300rpx;
  210. height: 300rpx;
  211. // background-color: red;
  212. margin: 0 auto;
  213. }
  214. .trc-tit {
  215. padding: 30rpx 0 30rpx 20rpx;
  216. text-align: left;
  217. font-size: 38rpx;
  218. font-weight: bold;
  219. }
  220. .trc-dz {
  221. // margin: auto;
  222. padding: 0 20rpx;
  223. // width: 750rpx;
  224. text-align: justify;
  225. // border: 1px #f1d4ab solid;
  226. line-height: 50rpx;
  227. font-size: 32rpx;
  228. padding-top: 20rpx;
  229. }
  230. .up-btn {
  231. width: 200rpx;
  232. border-radius: 50rpx;
  233. height: 50rpx;
  234. border: 1rpx solid #eccca2;
  235. margin: auto;
  236. text-align: center;
  237. color: #fff;
  238. background-color: #eccca2;
  239. font-size: 32rpx;
  240. line-height: 50rpx;
  241. }
  242. .up-img {
  243. width: 300rpx;
  244. height: 300rpx;
  245. margin: 50rpx auto 60rpx;
  246. image {
  247. width: 300rpx;
  248. height: 300rpx;
  249. }
  250. }
  251. </style>