recharge.vue 14 KB

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