Skip to content

Commit af51498

Browse files
peterpeter
authored andcommitted
v2.0.1
1 parent df7d38c commit af51498

File tree

10 files changed

+232
-210
lines changed

10 files changed

+232
-210
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ yarn.lock
1818
*.js
1919
package-lock.json
2020
.npmignore
21+
_config.yml

app/localWebServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ export default class localServer {
714714
const file = Uuid.v4() + '.mp4'
715715
const viode = Buffer.from ( data, 'base64' )
716716
return Fs.writeFile ( Path.join ( Tool.QTGateVideo, file ), viode, err => {
717-
m.QTDownload = `/videoTemp/${ file }`
717+
m.QTDownload = `/tempfile/videoTemp/${ file }`
718718
console.log (`save video file: [${ file }]`)
719719
return CallBack ()
720720
})

app/public/scripts/CoGate.ts

Lines changed: 59 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
declare const Cleave
22
declare const StripeCheckout
3-
const Stripe_publicKey = 'pk_test_uV27MTvcPM147KFo3HazbunU'
3+
const Stripe_publicKey = 'pk_live_VwEPmqkSAjDyjdia7xn4rAK9'
44

55
class coGateRegion {
66
public QTConnectData = ko.observable ( null )
@@ -452,10 +452,12 @@ class CoGateClass {
452452
self.showCards ( true )
453453
if ( payment ) {
454454
const uuuu = self.QTTransferData()
455-
uuuu.totalMonth = payment.totalMonth
456-
uuuu.productionPackage = payment.productionPackage
457-
uuuu.expire = payment.expire
458-
uuuu.paidAmount = payment.paidAmount
455+
uuuu.totalMonth = payment.totalMonth || uuuu.totalMonth
456+
uuuu.productionPackage = payment.productionPackage || uuuu.productionPackage
457+
uuuu.expire = payment.expire || uuuu.expire
458+
uuuu.paidAmount = payment.paidAmount || uuuu.paidAmount
459+
460+
uuuu.automatically = payment.paidAmount > 0 ? true : uuuu.automatically
459461
self.QTTransferData ( uuuu )
460462
}
461463
return self.CoGateAccount ( uu = null )
@@ -465,107 +467,13 @@ class CoGateClass {
465467

466468
}
467469

468-
interface PlanArray {
469-
name: string
470-
}
471-
472-
const planArray = [
473-
{
474-
name:'free',
475-
showName: ['免费用户','無料ユーザー','FREE USER','免費用戶'],
476-
monthlyPay: '0',
477-
annually: '0',
478-
annuallyMonth: '0',
479-
next:'p1',
480-
share: 0,
481-
internet: 0,
482-
tail: ko.observable ( false ),
483-
multi_gateway:0,
484-
showNote: false,
485-
showButton: ko.observable ( false ),
486-
features: [{
487-
title: ['代理区域','エリア','Region','代理區域'],
488-
detail: ['巴黎','パリ','Paris','巴黎'],
489-
},{
490-
title: ['服务器','サーバー','Server','伺服器'],
491-
detail: ['共享','共有','Share','共享'],
492-
},{
493-
title: ['月流量限制','月データ制限','Bandwidth','月流量限制'],
494-
detail: ['无限制','無制限','Unlimited','無限制'],
495-
},{
496-
title: ['多代理','マルチプロクシ','Multi-Gateway','多代理'],
497-
detail: ['1','1','1','1'],
498-
},{
499-
title: ['客户端数','端末数','Devices','客戶端數'],
500-
detail: ['无限制','無制限','Unlimited','無限制'],
501-
}]
502-
503-
},{
504-
name:'p1',
505-
showName: ['普通用户','普通ユーザー','NORMAL USER','普通用戶'],
506-
monthlyPay: '5.88',
507-
annually: '59.88',
508-
annuallyMonth:'4.99',
509-
next:'p2',
510-
share: 0,
511-
internet: 0,
512-
tail: ko.observable ( false ),
513-
multi_gateway:0,
514-
showNote: false,
515-
showButton: ko.observable ( false ),
516-
features: [{
517-
title: ['代理区域','エリア','Region','代理區域'],
518-
detail: ['全球16区域','グローバル16区域','16 regions worldwide ','全球16區域'],
519-
},{
520-
title: ['服务器','サーバー','Server','伺服器'],
521-
detail: ['共享','共有','Share','共享'],
522-
},{
523-
title: ['月流量限制','月データ制限','Bandwidth','月流量限制'],
524-
detail: ['无限制','無制限','Unlimited','無限制'],
525-
},{
526-
title: ['多代理','マルチプロクシ','Multi-Gateway','多代理'],
527-
detail: ['2','2','2','2'],
528-
},{
529-
title: ['客户端数','端末数','Devices','客戶端數'],
530-
detail: ['无限制','無制限','Unlimited','無限制'],
531-
}]
532-
},{
533-
name:'p2',
534-
showName: ['超级用户','スーパーユーザー','POWER USER','超級用戶'],
535-
monthlyPay: '19.88',
536-
annually: '199.99',
537-
annuallyMonth: '16.67',
538-
share: 0,
539-
internet: 0,
540-
multi_gateway:0,
541-
showNote: false,
542-
tail: ko.observable ( false ),
543-
showButton: ko.observable ( false ),
544-
features: [{
545-
title: ['代理区域','エリア','Region','代理區域'],
546-
detail: ['全球16区域','グローバル16区域','16 regions worldwide ','全球16區域'],
547-
},{
548-
title: ['服务器','サーバー','Server','伺服器'],
549-
detail: ['独占','独占','Dedicated','獨占'],
550-
},{
551-
title: ['月流量限制','月データ制限','Bandwidth','月流量限制'],
552-
detail: ['无限制','無制限','Unlimited','無限制'],
553-
},{
554-
title: ['多代理','マルチプロクシ','Multi-Gateway','多代理'],
555-
detail: ['4','4','4','4'],
556-
},{
557-
title: ['客户端数','端末数','Devices','客戶端數'],
558-
detail: ['无限制','無制限','Unlimited','無限制'],
559-
}]
560-
}
561-
]
562470

563471

564472
class planUpgrade {
565473

566-
public annually: string
567-
public annuallyMonth: string
568-
public totalAmount: KnockoutComputed< string >
474+
public annually: number
475+
public annuallyMonth: number
476+
public totalAmount = ko.observable (0)
569477
public currentPromoIndex: number
570478

571479

@@ -580,10 +488,10 @@ class planUpgrade {
580488

581489

582490
//public annually = this.promo ? Math.round ( this.promoPrice * this.plan.annually * 100 )/100 : this.plan.annually
583-
public planExpiration: string
491+
584492
public monthlyPay = this.plan.monthlyPay
585493
public showCancel = ko.observable ( false )
586-
public showCurrentPlanBalance = null
494+
public CurrentPlanBalance = ko.observable (-1)
587495
public cardNumberFolder_Error = ko.observable ( false )
588496
public cvcNumber_Error = ko.observable ( false )
589497
public postcode_Error = ko.observable ( false )
@@ -607,6 +515,7 @@ class planUpgrade {
607515
public paymentError = ko.observable ( false )
608516
public oldPlanUpgrade = ko.observable ( null )
609517
public paymentData = null
518+
public isAutomaticallyAgain = ko.observable ( false )
610519
private clearPaymentError () {
611520
this.cardNumberFolder_Error ( false )
612521
this.cvcNumber_Error ( false )
@@ -627,44 +536,23 @@ class planUpgrade {
627536
this.currentPromo ( this._promo )
628537
}
629538

630-
this.annually = this.currentPromo() ? ( Math.round (parseInt ( this.plan.annually * 100 ) * this.currentPromo().pricePromo) / 100 ).toString() : this.plan.annually
539+
this.annually = this.currentPromo() ? Math.round ( this.plan.annually * this.currentPromo().pricePromo ) : this.plan.annually
631540
const month = this.currentPromo() ? 12 * this.currentPromo().datePromo : 12
632-
this.annuallyMonth = ( Math.round ( parseInt ( this.annually * 100 ) / month ) / 100 ).toString ()
633-
541+
this.annuallyMonth = Math.round ( this.annually / month )
542+
this.annually = this.annually
634543
this.currentPlan ( planArray [ planArray.findIndex ( function ( n ) {
635544
return n.name === self.dataTransfer.productionPackage
636545
})])
637-
546+
638547
if ( planNumber === 2 ) {
639548
this.showNote ( true )
640-
if ( this.currentPlan().name === 'p1' ) {
641-
const oldPlanUpgrade = {
642-
oldPlanBalanceMonths: getRemainingMonth ( dataTransfer.expire ),
643-
oldPlanMonthlyCost: dataTransfer.paidAmount * 100 / dataTransfer.totalMonth
644-
645-
}
549+
if ( this.currentPlan().name === 'p1' && dataTransfer.isAnnual ) {
550+
646551
}
647552

648553
}
649554
this.samePlan ( this.currentPlan().name === planNumber )
650-
651-
652-
this.showCurrentPlanBalance = ko.computed (function (){
653-
if ( /free/i.test (dataTransfer.productionPackage )) {
654-
return null
655-
}
656-
return getCurrentPlanUpgradelBalance ( dataTransfer.expire, dataTransfer.productionPackage, dataTransfer.isAnnual )
657-
658-
})
659-
660-
this.totalAmount = ko.computed ( function () {
661-
const amount = ( Math.round (( self.payment() - self.showCurrentPlanBalance()) * 100 ) / 100 ).toString ()
662-
if ( !/\./.test( amount )) {
663-
return amount + '.00'
664-
}
665-
return amount
666-
})
667-
555+
668556
socketIo.on ( 'cardToken', function ( err, res: QTGateAPIRequestCommand ) {
669557
const data = res.Args[0]
670558
self.doingPayment ( false )
@@ -684,14 +572,29 @@ class planUpgrade {
684572

685573
public showPayment ( payment: number, annually: boolean ) {
686574
this.detailArea ( false )
687-
this.payment ( payment )
575+
this.payment ( payment/100 )
688576
this.paymentAnnually ( annually )
689577
const currentPro = this.currentPromo().datePromo || 1
690578
let month = annually ? 12 * currentPro : 1
691-
if ( this.currentPlan().name !== 'free' ) {
692-
693-
}
694-
const expir = getExpireWithMonths ( month )
579+
580+
581+
let expir = getExpireWithMonths ( month )
582+
// check is stoped monthly again
583+
if ( this.dataTransfer.productionPackage !== 'free') {
584+
if ( this.dataTransfer.isAnnual ) {
585+
const monthly = this.dataTransfer.paidAmount / this.dataTransfer.totalMonth
586+
this.CurrentPlanBalance ( getRemainingMonth ( this.dataTransfer.expire ) * monthly )
587+
} else {
588+
this.CurrentPlanBalance ( this.currentPlan().monthlyPay )
589+
}
590+
}
591+
592+
if ( !annually ) {
593+
if ( this.plan.name === this.currentPlan().name ) {
594+
this.isAutomaticallyAgain ( true )
595+
expir = new Date ( this.dataTransfer.expire )
596+
}
597+
}
695598
this.newPlanExpirationYear ( expir.getFullYear ().toString())
696599
const _month = expir.getMonth () + 1
697600
if ( _month < 10 ) {
@@ -701,7 +604,12 @@ class planUpgrade {
701604
}
702605

703606
this.newPlanExpirationDay ( expir.getDate ().toString())
704-
607+
if ( this.CurrentPlanBalance() > -1 ) {
608+
this.totalAmount ( this.payment() - this.CurrentPlanBalance()/100)
609+
} else {
610+
this.totalAmount ( this.payment())
611+
}
612+
705613
}
706614

707615
private showWaitPaymentFinished () {
@@ -782,7 +690,7 @@ class planUpgrade {
782690
const self = this
783691
this.clearPaymentError ()
784692
let handler = null
785-
const amount = Math.round (( this.payment() - this.showCurrentPlanBalance()) * 100 )
693+
const amount = this.totalAmount() * 100
786694
if ( StripeCheckout && typeof StripeCheckout.configure === 'function' ){
787695
handler = StripeCheckout.configure ({
788696
key: Stripe_publicKey,
@@ -838,15 +746,15 @@ class planUpgrade {
838746
}
839747

840748
class cancelPlan {
841-
public passedMonth = getPassedMonth ( this.startDay )
749+
public passedMonth = getPassedMonth ( this.startDay ) + 1
842750
public passedCost = this.passedMonth * this.normailMonthPrice
843751
public balance = this.amount - this.passedCost
844752
public cancelProcess = ko.observable ( false )
845753
private doingProcessBarTime = null
846754
public showError = ko.observable ( false )
847755

848756
constructor ( public planName: string, public totalMonth, public amount, private startDay: string, public expir: string, public isAnnual ,
849-
private normailMonthPrice: string, private exit: ( payment ) => void ) {
757+
private normailMonthPrice: number, private exit: ( payment ) => void ) {
850758
const self = this
851759

852760
}
@@ -997,12 +905,17 @@ class CoGateAccount {
997905

998906

999907
let plus1 = 1
1000-
if ( !this.dataTransfer.automatically && this.currentPlan.name !== 'free') {
908+
if ( this.currentPlan.name === 'free') {
1001909
plus1 = 0
1002910
}
911+
1003912
this.planArray()[ 1 + plus1 ].tail ( true )
1004-
for ( let i = plan + plus1; i < planArray.length; i ++ ) {
1005-
this.planArray()[i].showButton ( true )
913+
if ( this.dataTransfer.productionPackage === 'p1') {
914+
this.planArray()[1].showButton (false )
915+
}
916+
if ( this.dataTransfer.productionPackage === 'p2') {
917+
this.planArray()[1].showButton (false )
918+
this.planArray()[2].showButton (false )
1006919
}
1007920
const date = new Date ( dataTransfer.expire )
1008921
this.currentPlanExpirationYear ( date.getFullYear().toString() )
@@ -1014,7 +927,7 @@ class CoGateAccount {
1014927
public selectPlan1 ( n: number ) {
1015928
let uu = null
1016929
const self = this
1017-
this.planUpgrade ( uu = new planUpgrade ( n, this.dataTransfer.isAnnual, this.dataTransfer, function ( payment ) {
930+
return this.planUpgrade ( uu = new planUpgrade ( n, this.dataTransfer.isAnnual, this.dataTransfer, function ( payment ) {
1018931
self.planUpgrade ( uu = null )
1019932
self.exit ( payment )
1020933
}))
@@ -1056,7 +969,6 @@ class CoGateAccount {
1056969

1057970
})
1058971

1059-
return false
1060972
}
1061973

1062974
private showWaitPaymentFinished () {
@@ -1085,7 +997,7 @@ class CoGateAccount {
1085997
let uu = null
1086998
const self = this
1087999
this.doingPayment ( true )
1088-
this.cancelPlanData ( uu = new cancelPlan ( dataTransfer.productionPackage, dataTransfer.totalMonth, dataTransfer.paidAmount, dataTransfer.startDate, dataTransfer.expire, dataTransfer.isAnnual, this.currentPlan.monthlyPay,
1000+
return this.cancelPlanData ( uu = new cancelPlan ( dataTransfer.productionPackage, dataTransfer.totalMonth, dataTransfer.paidAmount, dataTransfer.startDate, dataTransfer.expire, dataTransfer.isAnnual, this.currentPlan.monthlyPay,
10891001
function exit ( payment ) {
10901002
self.cancelPlanData ( uu = null )
10911003
self.exit ( payment )

app/public/scripts/home.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ var view_layout;
272272
if (stage === 4) {
273273
this.connectToCoNET(false);
274274
this.connectedCoNET(true);
275+
if (this.showCoGate()) {
276+
this.homeClick();
277+
}
275278
}
276279
}
277280
}
@@ -441,8 +444,10 @@ var view_layout;
441444
return self.imapSetupClassExit(imapData);
442445
}));
443446
}
447+
this.connectedCoNET(true);
444448
//self.showCoGate ( showCoGate )
445449
if (showCoGate) {
450+
self.showCoGate(true);
446451
return self.homeClick();
447452
}
448453
self.AppList(true);
@@ -456,14 +461,7 @@ var view_layout;
456461
}));
457462
}
458463
reFreshLocalServer() {
459-
const self = this;
460-
socketIo.once('connect', function () {
461-
return location.reload();
462-
});
463-
socketIo.once('connect_error', function () {
464-
return self.refresh();
465-
});
466-
socketIo.connect();
464+
location.reload();
467465
}
468466
homeClick() {
469467
this.AppList(true);

0 commit comments

Comments
 (0)