-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblindModal.vue
878 lines (857 loc) · 30.2 KB
/
blindModal.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
<template>
<div class="bindmodalbox">
<div>
<div class="payment none">
<div class="payment-container flex">
<div class="payment-page flex">
<div
class="payment-page-close payment-close-pc"
onclick="paymentClose()"
>
<img src="./images/Close.png" />
</div>
<div class="payment-page-top none flex">
<div class="payment-page-right-tit">
{{ chEnTextHtml[lang].pay }}
</div>
<div class="payment-close-mobile">
<img src="./images/Close.png" />
</div>
</div>
<div class="payment-page-left">
<div class="payment-page-left-tit order-title">
{{ chEnTextHtml[lang].orderTit }}
</div>
<div class="payment-page-left-creator flex">
<div class="details-right-creator-img">
<img src="./images/t8.png" />
</div>
<span>@ATTA</span>
</div>
<div class="payment-page-left-img order-img">
<img
src="/upload/v2data/2021-08-19/a410d1ae-890a-41b5-ab2f-205ec88b00d0.jpg"
/>
</div>
</div>
<div class="payment-page-right">
<div class="payment-page-right-tit">
{{ chEnTextHtml[lang].pay }}
</div>
<div
class="
payment-page-left-tit
none
payment-page-left-tit-mobile
order-title
"
>
----
</div>
<div
class="
payment-page-left-creator
none
payment-page-left-creator-mobile
flex
"
>
<div class="details-right-creator-img">
<img src="./images/t8.png" />
</div>
<span>@ATTA</span>
</div>
<div class="payment-page-right-order none">
<p class="order-number">Order #:<span>----</span></p>
<p class="payment-page-right-order-tit">
{{ chEnTextHtml[lang].paid }}
</p>
<p class="payment-page-right-order-je"><span>----</span></p>
<p class="payment-page-right-order-by">
<span>{{ chEnTextHtml[lang].byCreditCard }}</span>
</p>
<p class="payment-page-right-order-card none">----</p>
</div>
<div class="payment-page-right-pay flex">
<span
v-for="(item, index) in payTabs"
:key="index"
:class="selectedPayMethod == index ? 'cur' : ''"
@click="togglePayMethod(index)"
>{{ item }}</span
>
</div>
<div class="payment-page-right-total">
<p>{{ chEnTextHtml[lang].pendingPayment }}</p>
<p class="order-price">
<span class="order-price-hdk hkdPrice">HK$388 </span
><span class="order-price-busd none busdPrice">BUSD 50 </span>
</p>
</div>
<div class="payment-page-right-select modify-ipt-fream">
<form
id="payment-form"
method="POST"
action="https://merchant.com/charge-card"
>
<div class="payment-form-ipt">
<div
class="input-container card-number"
style="margin-bottom: 20px !important"
>
<div class="icon-container">
<img
id="icon-card-number"
src="images/card-icons/card.svg"
alt="PAN"
/>
</div>
<div class="card-number-frame"></div>
<div class="icon-container payment-method">
<img id="logo-payment-method" />
</div>
<div class="icon-container">
<img
id="icon-card-number-error"
src="images/card-icons/error.svg"
/>
</div>
</div>
<div class="date-and-code">
<div>
<div class="input-container expiry-date">
<div class="icon-container">
<img
id="icon-expiry-date"
src="images/card-icons/exp-date.svg"
alt="Expiry date"
/>
</div>
<div class="expiry-date-frame"></div>
<div class="icon-container">
<img
id="icon-expiry-date-error"
src="images/card-icons/error.svg"
/>
</div>
</div>
</div>
<div>
<div class="input-container cvv">
<div class="icon-container">
<img
id="icon-cvv"
src="images/card-icons/cvv.svg"
alt="CVV"
/>
</div>
<div class="cvv-frame"></div>
<div class="icon-container">
<img
id="icon-cvv-error"
src="images/card-icons/error.svg"
/>
</div>
</div>
</div>
</div>
</div>
<p class="flex pay-save">
<input id="save" type="checkbox" /><label for="save">{{
chEnTextHtml[lang].saveFor
}}</label>
</p>
<div
style="
color: #ff1313;
display: flex;
align-items: center;
margin-top: 10px;
"
>
<input
id="savetips"
@click="enablePay"
type="checkbox"
/><span>{{ chEnTextHtml[lang].purchasing }}</span>
</div>
<div>
<div class="pay-button">
<button id="pay-button" @click="creditPay">
{{ chEnTextHtml[lang].payment }} >
</button>
</div>
<span
class="error-message error-message__card-number"
></span>
<span
class="error-message error-message__expiry-date"
></span>
<span class="error-message error-message__cvv"></span>
</div>
</form>
</div>
<div class="wallet-payment-desc none">
{{ chEnTextHtml[lang].notStore }}
</div>
<div
class="payment-page-right-balance"
style="
color: #ff1313;
display: flex;
align-items: center;
margin-top: 10px;
"
>
<input
id="saveBalance"
@click="toggleBalanceCheck"
type="checkbox"
/>
<span>{{ chEnTextHtml[lang].purchasing }}</span>
</div>
<div
class="payment-page-right-btn none"
style="border-bottom: none !important"
>
<button
id="balanceBtn"
@click="payBalance"
disabled=""
type="button"
>
{{ chEnTextHtml[lang].payment }} >
</button>
</div>
</div>
</div>
</div>
</div>
<div class="pre-mask none"></div>
</div>
<!-- 播放视频 -->
<div class="video-mask none"></div>
<div class="video-model none">
<div class="video-model-container flex">
<video
webkit-playsinline="true"
src="http://47.118.74.48:8081/upload/other/one_draw.mp4"
autoplay
muted
></video>
</div>
</div>
<div class="payment-result-modal none">
<div class="payment-container flex">
<div class="payment-page flex">
<div
class="payment-page-close payment-close-pc"
@click="paymentResultClose"
>
<img src="./images/Close.png" />
</div>
<div class="payment-page-top none flex">
<div class="payment-page-right-tit">
{{ chEnTextHtml[lang].pay }}
</div>
<div class="payment-close-mobile">
<img src="./images/Close.png" />
</div>
</div>
<div class="payment-page-left">
<div class="payment-page-left-tit order-title success-titl">
{{ chEnTextHtml[lang].orderTit }}
</div>
<div class="payment-page-left-creator flex">
<div class="details-right-creator-img">
<img src="./images/t8.png" />
</div>
<span>@ATTA</span>
</div>
<div class="user-result-imgs">
<img
v-for="(item, idx) in blindBoxData.list"
:key="idx"
@click="playVideo(item.primaryPic)"
:src="item.secondPic"
:class="[
blindBoxData.list.length > 1 ? 'ten-imgs' : 'one-imgs',
]"
/>
</div>
</div>
<div class="payment-page-right">
<div class="payment-page-right-tit">
{{ chEnTextHtml[lang].accomplish }}
</div>
<div
class="
payment-page-left-tit
none
payment-page-left-tit-mobile
order-title
"
>
{{ chEnTextHtml[lang].orderTit }}
</div>
<div
class="
payment-page-left-creator
none
payment-page-left-creator-mobile
flex
"
>
<div class="details-right-creator-img">
<img src="./images/t8.png" />
</div>
<span>@ATTA</span>
<div class="details-right-creator-edition">
{{ chEnTextHtml[lang].version }}
</div>
</div>
<div class="payment-page-right-total">
<h3>{{ chEnTextHtml[lang].paid }}</h3>
<h3>
<span class="order-price-hdk none hk-Price">HK$388 </span
><span class="order-price-busd none busd-price">BUSD 50 </span>
</h3>
<h4 class="info-desc">
{{ chEnTextHtml[lang].payTip }}
</h4>
<h4 class="user-address user-address-title">
{{ chEnTextHtml[lang].walletPay }}
</h4>
<h4 class="user-address">{{ blindBoxData.address }}</h4>
</div>
<div>
<div>
<button class="assets-button" @click="toAssets">
{{ chEnTextHtml[lang].asset }} >
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
module.exports = {
name: "blindmodal",
data: function () {
return {
chEnTextHtml: {
TC: {
edit: "修改",
clickedit: "點擊修改地址",
transfer: "轉移",
cancel: "取消",
home: "首頁",
auction: "拍賣",
noConnectWallet: "未連接錢包",
login: "登入/註冊",
myaccount: "我的帳戶",
myorders: "我的訂單",
myassets: "我的資產",
mywallet: "我的錢包",
logOut: "登出",
version: "第1版,共1版",
select: "已選第",
versionTxt: "版",
price: "单价:",
purchaseNow: "立即購買 ->",
saleEnds: "銷售結束於:",
details: "更多信息",
pay: "支付",
paySuc: "支付成功",
payErr: "支付失敗",
paid: "您的付款金額為",
byCreditCard: "信用卡支付",
pendingPayment: "這是待付款,您的付款金額為:",
saveFor: "保存以備將來購買",
purchasing: "由於您購買的是數字作品,一經售出概不退換",
payment: "立即付款",
currentUsing: "正在使用",
balance: "餘額",
notStore:
"我們不會儲存您的錢包密鑰,未經您的授權,也無法使用您電子錢包中的貨幣。",
regSuc: "注册成功",
operationFailed: "操作失败",
// js部分
maximum: "已達到最大購買數量",
purchaseSuc: "购买成功",
seconds: "預計10秒內到賬",
comSoon: "即將開售",
start: "銷售開始於:",
end: "銷售結束於:",
salesClosed: "銷售已結束",
sellOut: "已售罄",
balanceInsufficient: "餘額不足",
least: "至少選擇一件噢",
reached: "已達到賬號購買數量限制",
limit: "已達到單次購買數量限制",
moment: "當前剩餘只可選擇1個",
quantity: "已達到最大購買數量",
asset: "去我的資產核對",
confirm: "確認",
cancel: "取消",
recharge: "充值",
noLog: "未登入,請登入",
number: "訂單號 #:",
balancePayment: "餘額支付",
accomplish: "完成",
payment: "立即付款",
walletFirst: "請先連接錢包 ->",
paymentComing: "錢包直連支付功能準備中...",
orderTit: "ATTA x 英雄联盟主播系列NFT盲盒",
payTip:
"您抽中的NFT將在盲盒活動結束後24小時內發送至您的默認錢包。可在我的資產-我的NFT下可查看。",
walletPay: "錢包支付",
loadingText: "支付需耗時10-20秒鐘,請耐心等待~",
orderNoErr: "當前處理繁忙,請再次嘗試。",
switchNet: "請先切換網絡",
},
EN: {
switchNet: "Please switch network first",
orderNoErr: "Server is busy, please try again.",
loadingText:
"Payment takes about 10-20s to process, please be patient.",
walletPay: "Wallet payment",
payTip:
"The NFT you have drawn will be sent to your wallet within 24 hours after the purchase is closed. It can be viewed under My Assets - My NFTs.",
orderTit: "ATTA x LOL Streamer NFT Collection",
edit: "Edit",
clickedit: "Click to edit",
transfer: "Transfer",
cancel: "cancel",
home: "HOME",
auction: "AUCTION",
noConnectWallet: "Connect Wallet",
login: "Login/Sign up",
myaccount: "My Account",
myorders: "My Orders",
myassets: "My Assets",
mywallet: "My Wallet",
logOut: "Log out",
version: "Edition 1 of 1",
select: "Selected",
versionTxt: "th edition",
price: "Price:",
purchaseNow: "Purchase Now ->",
saleEnds: "Sale ends at:",
details: "Details",
pay: "Payment",
paySuc: "Payment successful",
payErr: "Payment failed",
paid: "Your paid",
byCreditCard: "By credit card",
pendingPayment: "Your pending payment is:",
saveFor: "Save for future purchase",
purchasing:
"Since you're purchasing a digital creation, all sales are final.",
currentUsing: "Current using",
payment: "Pay now",
balance: "Balance",
notStore:
"We will not store your wallet key, nor can we use the currency in your wallet without your authorization.",
regSuc: "registration success",
operationFailed: "operation failed",
// js部分
maximum: "Maximum purchase quantity has been reached",
purchaseSuc: "Successful purchase",
seconds: "Expected to arrive within 10 seconds",
comSoon: "Coming soon",
start: "Sales start at:",
end: "Sale ends at:",
salesClosed: "Sold out",
sellOut: "Sold out",
balanceInsufficient: "Insufficient balance",
least: "Choose at least one~",
reached: "The account purchase limit has been reached",
limit: "Reached the single purchase quantity limit",
moment: "Only 1 can be selected at the moment",
quantity: "Maximum purchase quantity has been reached",
asset: "Go to my asset to check",
confirm: "confirm",
cancel: "cancel",
recharge: "Add funds",
noLog: "Not logged in, please log in",
number: "Order #: ",
balancePayment: "Paid by balance",
accomplish: "complete",
payment: "Pay now",
walletFirst: "Please connect your wallet first ->",
paymentComing: "Function coming soon...",
},
},
lang: "",
orderNo: "",
blindBoxData: { list: [] },
address: "",
id: "",
busdPrice: 0,
selectarr: [],
accountBalance: 0,
curUserOwned: 0,
oneUserCountLimit: 0,
onceCountLimit: 0,
payTabs: ["錢包支付"],
// payTabs: ["錢包支付", "信用卡"],
selectedPayMethod: 0,
basicId: 0,
visiable: [],
auctionAddress: "",
auctionContractInstance: null,
userAddress: "",
tokenLimits: [],
chainId: "",
activityId: 1,
success_status: -1,
targetChainId: 0,
};
},
created() {
this.isConnect = getCookie("isConnect") == "false" ? false : true;
this.lang = getCookie("lang") ? getCookie("lang") : "TC";
if (this.lang == "TC") {
this.payTabs = ["錢包支付"];
// this.payTabs = ["錢包支付", "信用卡"];
} else {
this.payTabs = ["Crypto wallet"];
// this.payTabs = ["Crypto wallet", "Credit card"];
}
},
mounted() {
let self = this;
this.initAddress();
this.getCreditInfo();
this.togglePayMethod(0);
},
methods: {
paymentResultClose() {
$(".payment-result-modal").hide();
location.search = "";
},
playVideo(url) {
$(".bindmodalbox .payment").fadeOut("fast");
var videoUrl = url || "";
if (!videoUrl) {
if (window.getCookie("blindNum") < 2) {
videoUrl = "/upload/other/one_draw.mp4";
// videoUrl="https://v-cdn.zjol.com.cn/276982.mp4"
} else {
videoUrl = "/upload/other/ten_draw.mp4";
}
}
$(".bindmodalbox .video-model video").attr("src", videoUrl);
$(".bindmodalbox video").removeClass("video-hidden");
$(".bindmodalbox .video-model video")[0].play();
$(".bindmodalbox .video-mask").fadeIn("fast");
$(".bindmodalbox .video-model").fadeIn("fast");
if (this.selectedPayMethod == 1) {
$(".bindmodalbox .hkd-price").show();
$(".bindmodalbox .busd-price").hide();
} else {
$(".bindmodalbox .hkd-price").hide();
$(".bindmodalbox .busd-price").show();
}
$(".bindmodalbox .video-model video")[0].addEventListener(
"ended",
function () {
$(".bindmodalbox .video-mask").fadeOut("fast");
$(".bindmodalbox .video-model").fadeOut("fast");
$(".bindmodalbox .payment-result-modal").fadeIn("fast");
},
false
);
},
enablePay() {
if ($(".bindmodalbox #savetips").prop("checked")) {
$(".bindmodalbox #pay-button").attr("disabled", false);
} else {
$(".bindmodalbox #pay-button").attr("disabled", true);
}
},
creditPay() {
loading();
},
getQueryString(name) {
let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
let r = window.location.search.substr(1).match(reg);
if (r != null) {
return decodeURIComponent(r[2]);
}
return null;
},
getCreditInfo() {
let self = this;
self.success_status = self.getQueryString("success");
self.orderNo = window.getCookie("orderNo");
if (self.success_status == 1 && self.orderNo) {
success(this.chEnTextHtml[this.lang].paySuc, 1800);
setTimeout(function () {
CHAIN.WALLET.accounts().then(function (accounts) {
self.drawSku(accounts, "", 2);
});
self.playVideo();
}, 1800);
} else if (self.success_status == 0) {
self.cancelSku();
error(this.chEnTextHtml[this.lang].payErr, 1800);
}
},
initAddress() {
let self = this;
if (window.location.href.indexOf("bazhuayu.io") == -1) {
self.targetChainId = 97;
} else {
self.targetChainId = 56;
}
var web3 = new Web3(CHAIN.WALLET.provider());
CHAIN.WALLET.accounts().then(function (accounts) {
self.userAddress = accounts[0];
});
CHAIN.WALLET.chainId().then(function (res) {
let id = "";
self.chainId = web3.utils.hexToNumber(res);
id = web3.utils.hexToNumber(res);
if (id == self.targetChainId) {
self.auctionAddress = contractSetting["vending_machine"][id].address; //网络切换
} else {
tips(self.chEnTextHtml[self.lang].switchNet);
}
var auctionABI = contractSetting["vending_machine"]["abi"];
self.auctionContractInstance = new web3.eth.Contract(
auctionABI,
self.auctionAddress
);
});
},
toggleBalanceCheck() {
var payButton = document.getElementById("balanceBtn");
if ($(".bindmodalbox #saveBalance").prop("checked")) {
payButton.disabled = false;
} else {
if (
$(".bindmodalbox #balanceBtn").text() == "立即付款 >" ||
$(".bindmodalbox #balanceBtn").text() == "Pay now >"
) {
payButton.disabled = true;
}
}
},
//格式化时间
formatDuring(mss) {
var days = parseInt(mss / (1000 * 60 * 60 * 24));
var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
var seconds = parseInt((mss % (1000 * 60)) / 1000);
return days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
},
preSku() {
let self = this;
return new Promise((resolve, reject) => {
$.ajax({
url: base_url + "/v2/activity/preOrder",
type: "POST",
contentType: "application/json",
dataType: "json",
data: JSON.stringify({
activityId: 1,
count: window.blindNum,
}),
success: function (res) {
if (res.data) {
self.orderNo = res.data;
resolve(res.data);
} else {
tips(res.message);
}
},
error: function (err) {
reject(err);
setTimeout(function () {
loadingHide();
}, 1000);
},
});
});
},
saveHash(accounts, hash, type) {
let self = this;
if (self.orderNo) {
$.ajax({
url: base_url + "/v2/activity/saveTxHash",
type: "POST",
contentType: "application/json",
dataType: "json",
data: JSON.stringify({
activityId: 1,
address: accounts[0],
orderNo: self.orderNo,
txhash: hash || "",
type: type,
}),
});
}
},
drawSku(accounts, hash, type) {
let self = this;
if (self.orderNo) {
$.ajax({
url: base_url + "/v2/activity/draw",
type: "POST",
contentType: "application/json",
dataType: "json",
data: JSON.stringify({
activityId: 1,
address: accounts[0],
orderNo: self.orderNo,
txhash: hash || "",
type: type,
}),
success: function (resu) {
self.blindBoxData = resu.data;
if (resu.data.list && resu.data.list.length == 1) {
$(".bindmodalbox .success-titl").text(resu.data.list[0].name);
}
if (type == 2) {
window.setCookie("orderNo", "");
}
},
});
}
},
cancelSku() {
let self = this;
$.ajax({
url: base_url + "/v2/activity/cancelOrder",
type: "POST",
contentType: "application/json",
dataType: "json",
data: JSON.stringify({
orderNo: self.orderNo,
}),
});
},
//支付
payBalance() {
let self = this;
if (self.selectedPayMethod == 0) {
CHAIN.WALLET.accounts().then(function (accounts) {
self.safeCharge(accounts);
loading();
});
}
},
safeCharge(accounts) {
let self = this;
if (accounts.length < 1) {
return false;
}
var cwallet = ""; //收款钱包 地址
if (self.targetChainId == 97) {
cwallet = "0x4Df679A3407E5ab8d547cb22b7f0C98994667558";
} else {
cwallet = "0xC6F6fCce3026f08C668cA09bc5dFB58e596520f4";
}
var web3 = new Web3(CHAIN.WALLET.provider());
var chainId = "";
CHAIN.WALLET.chainId().then(function (res) {
chainId = web3.utils.hexToNumber(res);
// busdAddress 供外界使用
var busdAddress = contractSetting["busd_ERC20"][chainId].address;
var busdABI = contractSetting["busd_ERC20"]["abi"];
busdContractInstance = new web3.eth.Contract(busdABI, busdAddress);
var amount = $(".bindmodalbox .payment .busdPrice")
.text()
.split("BUSD ")[1];
var num = web3.utils.toWei(amount, "ether");
busdContractInstance.methods
.balanceOf(accounts[0])
.call() //查询余额
.then(function (res2) {
loadingHide();
if (Number(res2) >= Number(num)) {
self.preSku();
setTimeout(function () {
busdContractInstance.methods
.transfer(cwallet, num)
.send({
//转账
from: accounts[0],
})
.on("transactionHash", function (hash) {
loading(self.chEnTextHtml[self.lang].loadingText);
if (!self.orderNo) {
tips(self.chEnTextHtml[self.lang].orderNoErr);
return false;
}
self.saveHash(accounts, hash, 3);
if (getCookie("_wallet_") == "WalletConnect") {
self.drawSku(accounts, hash, 3);
$(".bindmodalbox .payment").fadeOut();
self.playVideo();
loadingHide();
}
})
.then((result) => {
if (!self.orderNo) {
tips(self.chEnTextHtml[self.lang].orderNoErr);
return false;
}
self.drawSku(accounts, result.transactionHash, 3);
$(".bindmodalbox .payment").fadeOut();
self.playVideo();
loadingHide();
})
.catch((err) => {
console.log(err);
self.cancelSku();
loadingHide();
});
}, 1000);
} else {
tips(self.chEnTextHtml[self.lang].balanceInsufficient);
}
});
});
},
toAssets() {
window.setCookie("selectedTab", 1);
window.location.href = "myassets.html";
},
togglePayMethod(text) {
this.selectedPayMethod = text;
if (text == 1) {
$(".bindmodalbox .payment-page-right-btn").hide();
$(".bindmodalbox .order-price .order-price-hdk").show();
$(".bindmodalbox .order-price .order-price-busd").hide();
$(".bindmodalbox .payment-page-right-select").show();
$(".bindmodalbox .payment-page-right-busd").hide();
$(".bindmodalbox .payment-page-right-balance").hide();
$(".bindmodalbox .payment-page-right-btn").hide();
$(".bindmodalbox .wallet-payment-desc").hide();
$(".bindmodalbox .payment-page-right-total").show();
}
if (text == 0) {
$(".payment-page-right-balance").show();
$(".bindmodalbox .payment-page-right-btn").show();
$(".bindmodalbox .payment-page-right-total").show();
$(".payment-page .payment-page-right-balance").show();
$(".bindmodalbox .payment-page-right-btn button").addClass("can");
$(".bindmodalbox .payment-page-right-btn button").text(
this.chEnTextHtml[this.lang].payment + " >"
);
$(".bindmodalbox .order-price .order-price-hdk").hide();
$(".bindmodalbox .order-price .order-price-busd").show();
$(".bindmodalbox .payment-page-right-select").hide();
$(".bindmodalbox .payment-page-right-busd").show();
$(".bindmodalbox .wallet-payment-desc").hide();
}
},
},
};
</script>