recharge.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <view class="container">
  3. <view class="list-box">
  4. <view class="list flex">
  5. <view class="flex_item list-item">
  6. <image :src="logo"></image>
  7. <view>{{name}}</view>
  8. </view>
  9. <view class="flex_item list-tpl">
  10. <view class="content" @click="useOutClickSide">
  11. <selectss ref="easySelect" :options='moneyTypeList' :value="name" @selectOne="selectOne">
  12. </selectss>
  13. </view>
  14. <image src="../../static/img/img23.png"></image>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="image-box" v-if="charge != 0">
  19. <view class="tuijianbox" >
  20. <view class="item" @click="gogo()" >
  21. <image v-if="idx == 2" src="../../static/img/befor.png"></image>
  22. <image v-else src="../../static/img/after.png"></image>
  23. </view>
  24. </view>
  25. <!-- <view class="way-wrapper">
  26. <view class="way" v-for="item in way" :key="item" @click="goway(item)">
  27. {{item}}
  28. </view>
  29. </view> -->
  30. <tki-qrcode
  31. :cid="cid"
  32. ref="qrcode"
  33. :val="address"
  34. :size="size"
  35. :unit="unit"
  36. :background="background"
  37. :foreground="foreground"
  38. :pdground="pdground"
  39. :iconSize="iconSize"
  40. :lv="lv"
  41. :onval="onval"
  42. :loadMake="loadMake"
  43. :usingComponents="usingComponents"
  44. @result="qrR"
  45. />
  46. <!-- <image :src="qr" mode="aspectFit"></image> -->
  47. </view>
  48. <view class="from-box" v-if="charge != 0">
  49. <view class="from-title">充币地址</view>
  50. <view class="flex input-tpl">
  51. <input class="input-box" disabled="disabled" type="text" v-model="address" />
  52. <view class="all" @click="copy(address)">复制</view>
  53. </view>
  54. <!-- <view class="from-title">充币数量</view>
  55. <input class="input-box" type="text" v-model="num" placeholder="请输入充币数量" /> -->
  56. <!-- <view class="submit" v-if="showBtn" @click="bangidng">绑定钱包</view> -->
  57. <!-- <view class="" v-if="orderShow == true">
  58. <view class="from-title">订单号</view>
  59. <view class="flex input-tpl">
  60. <input class="input-box" disabled="disabled" type="text" v-model="order_id" />
  61. <view class="all" @click="copy(order_id)">复制</view>
  62. </view>
  63. <view class="add-img-item" @click.stop="scImg()">
  64. <image class="add-img" :src="image" mode="aspectFit"></image>
  65. </view>
  66. <view class="addr-text" @click="moneyList">上传凭证</view>
  67. </view> -->
  68. <view class="text-box">{{mark}}</view>
  69. </view>
  70. <view class="qidai" v-else>
  71. {{mark}}
  72. </view>
  73. <uni-popup ref="popup" type="center">
  74. <view class="popup">
  75. <view class="cancel flex" @click="close">
  76. <view></view>
  77. <view class="tip">x</view>
  78. </view>
  79. <view class="list-boxs">
  80. <view class="popup-text">绑定地址:</view>
  81. <view class="password"><input type="text" v-model="keysAddr" placeholder="请输入绑定地址"></view>
  82. <view class="confirm-btn" @click="bd"><text>确认绑定</text></view>
  83. </view>
  84. </view>
  85. </uni-popup>
  86. </view>
  87. </template>
  88. <script>
  89. import {
  90. recharge,edit
  91. } from '@/api/finance.js';
  92. import {
  93. upload,
  94. money
  95. } from '@/api/finance.js';
  96. import selectss from '@/components/select.vue';
  97. import uniCopy from '@/js_sdk/xb-copy/uni-copy.js'
  98. import {
  99. moneyType
  100. } from '@/api/index.js';
  101. import tkiQrcode from '@/components/tki-qrcode/tki-qrcode.vue';
  102. export default {
  103. components: {
  104. selectss,
  105. tkiQrcode
  106. },
  107. data() {
  108. return {
  109. way: [],
  110. moneyTypeList: [],
  111. charge: 0,
  112. logo: '',
  113. name: '',
  114. code: '',
  115. qr: '',
  116. address: '',
  117. image: '../../static/img/add.png',
  118. order_id:'',
  119. id:'',
  120. orderShow:false,
  121. mark:'',
  122. addr:'',
  123. ids:'',
  124. num: '',
  125. password: '',
  126. keysAddr:'',
  127. showBtn:false,
  128. idx: 1,
  129. cid: 'cid',
  130. size: 150,
  131. unit: '150',
  132. background: '#FFFFFF',
  133. foreground: '#000000',
  134. pdground: '#000000',
  135. icon: '',
  136. iconSize: 40,
  137. lv: 3,
  138. onval: true,
  139. loadMake: true,
  140. usingComponents: true,
  141. wayAddress: []
  142. };
  143. },
  144. onLoad(option) {
  145. console.log(option)
  146. if (option.name) {
  147. this.way = option.way.split(",")
  148. this.charge = option.charge;
  149. this.name = option.name;
  150. this.logo = option.logo;
  151. this.code = option.code;
  152. this.mark = option.mark;
  153. this.ids = option.ids;
  154. this.keysAddr = option.keysAddr;
  155. this.qr = option._address_qr;
  156. this.address = option.address
  157. this.ids = option.ids;
  158. this.addr = option.keysAddr;
  159. this.wayAddress = JSON.parse(option.waypath)
  160. if (this.addr == null || this.addr == '') {
  161. this.showBtn = true;
  162. }
  163. }
  164. this.moneyType();
  165. },
  166. onShow() {
  167. },
  168. methods: {
  169. // 所有币种
  170. async moneyType() {
  171. let obj = this;
  172. moneyType({}).then(({
  173. data
  174. }) => {
  175. obj.moneyTypeList = data;
  176. if (obj.logo == '') {
  177. this.charge = obj.moneyTypeList[0].charge;
  178. obj.logo = obj.moneyTypeList[0].LOGO;
  179. obj.name = obj.moneyTypeList[0].name;
  180. obj.code = obj.moneyTypeList[0].code;
  181. obj.money = obj.moneyTypeList[0].price;
  182. if(obj.way[0] === "NO"){
  183. obj.address = ''
  184. }else {
  185. obj.address = obj.moneyTypeList[0].wallet['address'+obj.way[0]]
  186. }
  187. obj.qr = obj.moneyTypeList[0]._address_qr;
  188. obj.mark = obj.moneyTypeList[0].mark;
  189. obj.addr = obj.moneyTypeList[0].wallet.address;
  190. if(obj.addr == null || obj.addr == ''){
  191. obj.showBtn = true
  192. }
  193. obj.ids = obj.moneyTypeList[0].wallet.id;
  194. }
  195. });
  196. },
  197. //单张上传图片
  198. scImg() {
  199. let obj = this;
  200. upload({
  201. file: ''
  202. }).then(function(e) {
  203. if (e[0] == undefined || e[0] == '') {
  204. obj.$api.msg('图片上传失败!');
  205. } else {
  206. obj.image = e[0].url;
  207. obj.$api.msg('图片上传成功!');
  208. }
  209. })
  210. },
  211. close() {
  212. this.$refs.popup.close();
  213. },
  214. bd(){
  215. let obj = this;
  216. edit({
  217. key: obj.keysAddr
  218. },obj.ids).then(e => {
  219. obj.showBtn = false;
  220. obj.$api.msg(e.msg);
  221. obj.$refs.popup.close();
  222. });
  223. },
  224. bangidng(){
  225. let obj = this;
  226. obj.$refs.popup.open();
  227. },
  228. moneyList() {
  229. let obj = this;
  230. if (obj.image == '../../static/img/add.png') {
  231. obj.$api.msg('请上传凭证!');
  232. return;
  233. }
  234. money({
  235. proof: obj.image
  236. }, obj.id).then(e => {
  237. obj.$api.msg(e.msg);
  238. setTimeout(function() {
  239. uni.switchTab({
  240. url: '/pages/finance/index'
  241. })
  242. }, 1000);
  243. });
  244. },
  245. //复制
  246. copy(item) {
  247. let obj = this;
  248. let content = item; //需要复制的内容
  249. content = typeof content === 'string' ? content : content.toString() // 复制内容,必须字符串,数字需要转换为字符串
  250. const result = uniCopy(content)
  251. if (result === false) {
  252. uni.showToast({
  253. title: '不支持',
  254. })
  255. } else {
  256. uni.showToast({
  257. title: '复制成功',
  258. icon: 'none'
  259. })
  260. }
  261. },
  262. recharge() {
  263. let obj = this;
  264. if (obj.num == '') {
  265. obj.$api.msg('请输入充币数量!');
  266. return;
  267. }
  268. recharge({
  269. money_type: obj.code,
  270. num: obj.num,
  271. }).then((data) => {
  272. obj.order_id = data.data.order_id;
  273. obj.id = data.data.id;
  274. obj.num = '';
  275. obj.$api.msg(data.msg);
  276. obj.orderShow = true;
  277. });
  278. },
  279. selectOne(options) {
  280. this.logo = options.LOGO;
  281. this.charge = options.charge;
  282. this.name = options.name;
  283. this.code = options.code;
  284. this.money = options.price;
  285. // this.address = options.wallet.address_TRC20;
  286. this.qr = options._address_qr;
  287. this.qr = options._address_qr;
  288. this.mark = options.mark;
  289. this.addr = options.wallet.address;
  290. this.ids = options.wallet.id;
  291. this.way = options.way.split(',');
  292. if(this.way[0] === "NO"){
  293. this.wayAddress = []
  294. }else {
  295. this.way.forEach((item)=> {
  296. this.wayAddress[item] = options.wallet['address_'+item]
  297. })
  298. this.address = this.wayAddress[this.way[0]]
  299. console.log(this.wayAddress)
  300. }
  301. },
  302. useOutClickSide() {
  303. this.$refs.easySelect.hideOptions && this.$refs.easySelect.hideOptions()
  304. },
  305. sub() {
  306. this.idx = 2;
  307. this.$api.msg('敬请期待!');
  308. },
  309. gogo() {
  310. this.idx = 1;
  311. },
  312. qrR(res) {
  313. this.src = res;
  314. },
  315. creatQrcode() {
  316. this.$refs.qrcode._makeCode();
  317. },
  318. goway(data) {
  319. this.address = this.wayAddress[data],
  320. console.log(this.wayAddress[data])
  321. // this.address = 'www.baudu.com'
  322. }
  323. }
  324. };
  325. </script>
  326. <style lang="scss">
  327. page {
  328. min-height: 100%;
  329. background-color: #ffffff;
  330. .container {
  331. width: 100%;
  332. }
  333. }
  334. .list-box {
  335. padding: 60rpx 30rpx;
  336. height: 350rpx;
  337. background-color: #5771DF;
  338. .list {
  339. background-color: #FFFFFF;
  340. border-radius: 15rpx;
  341. padding: 15rpx 23rpx;
  342. .list-item {
  343. font-size: 30rpx;
  344. font-weight: bold;
  345. color: #333333;
  346. image {
  347. width: 43rpx;
  348. height: 43rpx;
  349. margin-right: 15rpx;
  350. }
  351. }
  352. .list-tpl {
  353. image {
  354. width: 15rpx;
  355. height: 25rpx;
  356. margin-left: 20rpx;
  357. }
  358. }
  359. }
  360. }
  361. .image-box {
  362. position: relative;
  363. top: -100rpx;
  364. padding: 50rpx 0rpx;
  365. text-align: center;
  366. image {
  367. width: 300rpx;
  368. height: 300rpx;
  369. border-radius: 15rpx;
  370. }
  371. .item {
  372. margin-left: 40rpx;
  373. font-size: 20rpx;
  374. position: relative;
  375. line-height: 40rpx;
  376. color: #FFFFFF;
  377. image {
  378. width: 150rpx;
  379. height: 100rpx;
  380. }
  381. .way {
  382. text-align: center;
  383. line-height: 80rpx;
  384. height: 80rpx;
  385. width: 100rpx;
  386. border: 1 solid #000000;
  387. }
  388. }
  389. }
  390. .from-box {
  391. margin: 30rpx 30rpx;
  392. padding: 44rpx 25rpx;
  393. background-color: #FFFFFF;
  394. border-radius: 15rpx;
  395. position: relative;
  396. top: -180rpx;
  397. .from-title {
  398. font-size: 24rpx;
  399. font-weight: bold;
  400. color: #333333;
  401. }
  402. .input-box {
  403. font-size: 26rpx;
  404. font-weight: 500;
  405. color: #666666;
  406. margin: 35rpx 0rpx;
  407. width: 85%;
  408. }
  409. .all {
  410. font-size: 30rpx;
  411. font-weight: 500;
  412. color: #5771DF;
  413. }
  414. .all-num {
  415. font-size: 24rpx;
  416. font-weight: bold;
  417. color: #333333;
  418. text {
  419. font-size: 26rpx;
  420. padding: 0rpx 10rpx;
  421. color: #5771DF;
  422. }
  423. }
  424. .submit {
  425. background-color: #5771DF;
  426. margin-top: 160rpx;
  427. margin-bottom: 80rpx;
  428. color: #FFFFFF;
  429. text-align: center;
  430. padding: 26rpx 0rpx;
  431. border-radius: 15rpx;
  432. }
  433. .tpl-box {
  434. text-align: left;
  435. font-size: 28rpx;
  436. font-weight: 500;
  437. color: #FB3A2F;
  438. margin-top: 26rpx;
  439. }
  440. }
  441. .add-img-item {
  442. text-align: center;
  443. width: 100%;
  444. padding: 80rpx 0rpx;
  445. .add-img {
  446. width: 280rpx;
  447. height: 280rpx;
  448. }
  449. }
  450. .image {
  451. text-align: center;
  452. padding: 77rpx 0rpx 36rpx 0rpx;
  453. font-size: 30rpx;
  454. font-weight: bold;
  455. color: #333333;
  456. .addr-img {
  457. width: 188rpx;
  458. height: 188rpx;
  459. margin-top: 18rpx;
  460. }
  461. }
  462. .addr-text {
  463. text-align: center;
  464. width: 500rpx;
  465. margin: 0rpx auto;
  466. line-height: 80rpx;
  467. color: #FFFFFF;
  468. background-color: #5771DF;
  469. border-radius: 50rpx;
  470. margin-bottom: 114rpx;
  471. }
  472. .text-box{
  473. font-size: 24rpx;
  474. padding: 25rpx 0rpx;
  475. line-height: 50rpx;
  476. }
  477. //弹窗
  478. .popup{
  479. background-color: #FFFFFF;
  480. border-radius: 25rpx;
  481. font-size: 30rpx;
  482. .cancel{
  483. text-align: center;
  484. width: 100%;
  485. line-height: 60rpx;
  486. .tip{
  487. background-color: #5771DF;
  488. color: #FFFFFF;
  489. width:70rpx;
  490. height: 70rpx;
  491. border-top-right-radius:25rpx ;
  492. }
  493. }
  494. .list-boxs{
  495. padding: 0rpx 80rpx;
  496. .password{
  497. padding: 50rpx 0rpx;
  498. width: 100%;
  499. input{
  500. width: 90%;
  501. height: 80rpx;
  502. border: 2rpx solid #999999;
  503. padding-left: 25rpx;
  504. box-shadow:0px 3px 5px 0px rgba(0, 0, 0, 0.27);
  505. border-radius:11rpx;
  506. }
  507. }
  508. .confirm-btn{
  509. margin-left: 80rpx;
  510. padding-bottom: 120rpx;
  511. padding-top: 30rpx;
  512. text{
  513. background-color: #5771DF;
  514. color: #FFFFFF;
  515. width: 100%;
  516. text-align: center;
  517. padding:25rpx 90rpx;
  518. border-radius: 15rpx;
  519. }
  520. }
  521. }
  522. }
  523. .tuijianbox{
  524. width: 100%;
  525. display: flex;
  526. height: 40rpx;
  527. margin-bottom: 60rpx;
  528. .item {
  529. margin-left: 40rpx;
  530. font-size: 20rpx;
  531. position: relative;
  532. line-height: 40rpx;
  533. color: #FFFFFF;
  534. image {
  535. width: 150rpx;
  536. height: 100rpx;
  537. }
  538. .way {
  539. text-align: center;
  540. line-height: 1;
  541. height: 80rpx;
  542. width: 100rpx;
  543. border: 1 solid #FFFFFF;
  544. }
  545. }
  546. }
  547. .qidai {
  548. width: 100%;
  549. font-size: 100rpx;
  550. text-align: center;
  551. }
  552. .way-wrapper {
  553. width: 90%;
  554. padding: 0 5%;
  555. display: flex;
  556. height: 40rpx;
  557. margin-bottom: 60rpx;
  558. justify-content: start;
  559. .way {
  560. width: 120rpx;
  561. height: 75rpx;
  562. line-height: 75rpx;
  563. text-align: center;
  564. border: 1px solid #7c90e3;
  565. border-radius: 10rpx 10rpx 10rpx 10rpx;
  566. color: #7c90e3;
  567. background-color: #eff2ff;
  568. font-size: 36rpx;
  569. font-weight: bold;
  570. margin-right: 30rpx;
  571. }
  572. }
  573. </style>