Initial commit (code only without large binaries)
This commit is contained in:
38
EdgeUser/web/views/@default/anti-ddos/packages/confirm.html
Normal file
38
EdgeUser/web/views/@default/anti-ddos/packages/confirm.html
Normal file
@@ -0,0 +1,38 @@
|
||||
{$layout}
|
||||
|
||||
<!-- 步骤 -->
|
||||
<div class="ui steps fluid">
|
||||
<div class="step">
|
||||
<a href="/anti-ddos/packages">选择实例规格</a>
|
||||
</div>
|
||||
<div class="step active">
|
||||
<strong>支付</strong>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
|
||||
<input type="hidden" name="packageId" :value="packageId"/>
|
||||
<input type="hidden" name="periodId" :value="periodId"/>
|
||||
<input type="hidden" name="count" :value="count"/>
|
||||
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">高防实例</td>
|
||||
<td>[{{packageSummary}} / {{periodName}}] x {{count}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>价格</td>
|
||||
<td>¥{{amount}}元</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>支付方式</td>
|
||||
<td>
|
||||
<pay-method-selector></pay-method-selector>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<submit-btn v-show="amount > 0">确定购买</submit-btn><span class="red" v-if="amount == 0">参数错误,请返回重新选择。</span> <a href="/anti-ddos/packages">上一步</a>
|
||||
</form>
|
||||
23
EdgeUser/web/views/@default/anti-ddos/packages/confirm.js
Normal file
23
EdgeUser/web/views/@default/anti-ddos/packages/confirm.js
Normal file
@@ -0,0 +1,23 @@
|
||||
Tea.context(function () {
|
||||
this.goBack = function () {
|
||||
window.history.back()
|
||||
}
|
||||
|
||||
this.success = function (resp) {
|
||||
if (resp.data.success) {
|
||||
teaweb.success("实例购买成功", function () {
|
||||
window.location = "/anti-ddos/instances"
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (resp.data.orderCode.length > 0) {
|
||||
window.location = "/finance/pay?code=" + resp.data.orderCode + "&from=" + window.escape(window.location.toString()) + "&returnURL=/anti-ddos/instances"
|
||||
}
|
||||
}
|
||||
|
||||
this.methodCode = "@balance"
|
||||
this.changePayMethod = function (methodCode) {
|
||||
this.methodCode = methodCode
|
||||
}
|
||||
})
|
||||
62
EdgeUser/web/views/@default/anti-ddos/packages/index.html
Normal file
62
EdgeUser/web/views/@default/anti-ddos/packages/index.html
Normal file
@@ -0,0 +1,62 @@
|
||||
{$layout}
|
||||
|
||||
<!-- 步骤 -->
|
||||
<div class="ui steps fluid">
|
||||
<div class="step active">
|
||||
<a href="/anti-ddos/packages">选择实例规格</a>
|
||||
</div>
|
||||
<div class="step">支付</div>
|
||||
</div>
|
||||
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
|
||||
<input type="hidden" name="packageId" :value="selectedPackageId"/>
|
||||
<input type="hidden" name="periodId" :value="selectedPeriodId"/>
|
||||
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">选择线路 *</td>
|
||||
<td>
|
||||
<a v-for="network in allNetworks" class="ui label basic" :class="{blue: network.id == selectedNetworkId}" @click.prevent="selectNetwork(network.id)">{{network.name}}</a>
|
||||
<p class="comment" v-for="network in allNetworks" v-if="network.id == selectedNetworkId && network.description.length > 0">{{network.name}}:{{network.description}}</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>选择防护带宽 *</td>
|
||||
<td>
|
||||
<a v-for="protectionBandwidth in allProtectionBandwidthSizes" v-if="hasProtectionBandwidth(protectionBandwidth)" class="ui label basic" :class="{blue: protectionBandwidth == selectedProtectionBandwidth}" @click.prevent="selectProtectionBandwidth(protectionBandwidth)">{{protectionBandwidth}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>选择业务带宽 *</td>
|
||||
<td>
|
||||
<a v-for="serverBandwidth in allServerBandwidthSizes" v-if="hasServerBandwidth(serverBandwidth)" class="ui label basic" :class="{blue: serverBandwidth == selectedServerBandwidth}" @click.prevent="selectServerBandwidth(serverBandwidth)">{{serverBandwidth}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>选择有效期 *</td>
|
||||
<td>
|
||||
<a v-for="period in allPeriods" class="ui label basic" v-if="hasPeriod(period.id)" :class="{blue: period.id == selectedPeriodId}" @click.prevent="selectPeriod(period.id)">{{period.count}}{{period.unitName}}</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>选择实例数量 *</td>
|
||||
<td>
|
||||
<div class="ui input">
|
||||
<select class="ui dropdown" name="count" v-model="count" @change="changeCount(this.count)">
|
||||
<option v-for="i in max" :value="i">{{i}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>价格</td>
|
||||
<td>
|
||||
<span v-if="amount == 0" class="disabled">没有找到对应价格</span>
|
||||
<span v-if="amount > 0">{{amount}}元</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button class="ui button primary" type="button" :class="{disabled: amount <= 0}" @click.prevent="goNext()">下一步</button>
|
||||
</form>
|
||||
219
EdgeUser/web/views/@default/anti-ddos/packages/index.js
Normal file
219
EdgeUser/web/views/@default/anti-ddos/packages/index.js
Normal file
@@ -0,0 +1,219 @@
|
||||
Tea.context(function () {
|
||||
this.selectedNetworkId = 0
|
||||
this.selectedProtectionBandwidth = ""
|
||||
this.selectedServerBandwidth = ""
|
||||
this.selectedPackageId = 0
|
||||
this.selectedPeriodId = 0
|
||||
this.amount = -1
|
||||
this.max = 1
|
||||
this.count = 1
|
||||
this.selectedPrice = null
|
||||
|
||||
this.$delay(function () {
|
||||
if (this.allNetworks.length > 0) {
|
||||
this.selectNetwork(this.allNetworks[0].id)
|
||||
}
|
||||
})
|
||||
|
||||
this.selectNetwork = function (networkId) {
|
||||
this.selectedNetworkId = networkId
|
||||
this.selectedProtectionBandwidth = ""
|
||||
this.selectedServerBandwidth = ""
|
||||
this.selectedPeriodId = 0
|
||||
this.amount = -1
|
||||
|
||||
// 选择第一个防护带宽
|
||||
let that = this
|
||||
let found = false
|
||||
this.prices.sort(function (v1, v2) {
|
||||
return that.compareBits(v1.protectionBandwidth, v2.protectionBandwidth)
|
||||
}).forEach(function (v) {
|
||||
if (!found && v.networkId == that.selectedNetworkId) {
|
||||
that.selectProtectionBandwidth(v.protectionBandwidth)
|
||||
found = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.selectProtectionBandwidth = function (protectionBandwidth) {
|
||||
this.selectedProtectionBandwidth = protectionBandwidth
|
||||
this.selectedServerBandwidth = ""
|
||||
this.selectedPeriodId = 0
|
||||
this.amount = -1
|
||||
|
||||
// 选择第一个业务带宽
|
||||
let that = this
|
||||
let found = false
|
||||
this.prices.sort(function (v1, v2) {
|
||||
return that.compareBits(v1.serverBandwidth, v2.serverBandwidth)
|
||||
}).forEach(function (v) {
|
||||
if (!found && v.networkId == that.selectedNetworkId && v.protectionBandwidth == protectionBandwidth) {
|
||||
that.selectServerBandwidth(v.serverBandwidth)
|
||||
found = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.selectServerBandwidth = function (serverBandwidth) {
|
||||
this.selectedServerBandwidth = serverBandwidth
|
||||
this.selectedPeriodId = 0
|
||||
this.amount = -1
|
||||
|
||||
// 选择第一个有效期
|
||||
let that = this
|
||||
let found = false
|
||||
|
||||
this.prices.sort(function (v1, v2) {
|
||||
let periodId1 = v1.periodId
|
||||
let periodId2 = v2.periodId
|
||||
return (that.toPeriodMonths(that.findPeriodWithId(periodId1)) > that.toPeriodMonths(that.findPeriodWithId(periodId2))) ? 1 : -1
|
||||
}).forEach(function (v) {
|
||||
if (!found && v.networkId == that.selectedNetworkId && v.protectionBandwidth == that.selectedProtectionBandwidth && v.serverBandwidth == serverBandwidth) {
|
||||
that.selectPeriod(v.periodId)
|
||||
found = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
this.selectPeriod = function (periodId) {
|
||||
this.selectedPeriodId = periodId
|
||||
|
||||
let price = null
|
||||
let found = false
|
||||
let that = this
|
||||
this.prices.forEach(function (v) {
|
||||
if (!found && v.networkId == that.selectedNetworkId
|
||||
&& v.protectionBandwidth == that.selectedProtectionBandwidth
|
||||
&& v.serverBandwidth == that.selectedServerBandwidth
|
||||
&& v.periodId == that.selectedPeriodId) {
|
||||
price = v
|
||||
found = true
|
||||
}
|
||||
})
|
||||
if (price == null) {
|
||||
teaweb.warn("数据错误,请刷新页面后重试,如果仍然没有恢复,请联系管理员。")
|
||||
return
|
||||
}
|
||||
|
||||
this.selectedPrice = price
|
||||
|
||||
this.selectedPackageId = price.packageId
|
||||
this.count = 1
|
||||
this.max = price.maxInstances
|
||||
this.changeCount(this.count)
|
||||
}
|
||||
|
||||
this.hasProtectionBandwidth = function (protectionBandwidth) {
|
||||
if (this.prices == null) {
|
||||
return
|
||||
}
|
||||
|
||||
let found = false
|
||||
let that = this
|
||||
this.prices.forEach(function (v) {
|
||||
if (v.networkId == that.selectedNetworkId && v.protectionBandwidth == protectionBandwidth) {
|
||||
found = true
|
||||
}
|
||||
})
|
||||
return found
|
||||
}
|
||||
|
||||
this.hasServerBandwidth = function (serverBandwidth) {
|
||||
if (this.prices == null) {
|
||||
return
|
||||
}
|
||||
|
||||
let found = false
|
||||
let that = this
|
||||
this.prices.forEach(function (v) {
|
||||
if (v.networkId == that.selectedNetworkId
|
||||
&& v.protectionBandwidth == that.selectedProtectionBandwidth
|
||||
&& v.serverBandwidth == serverBandwidth) {
|
||||
found = true
|
||||
}
|
||||
})
|
||||
return found
|
||||
}
|
||||
|
||||
this.hasPeriod = function (periodId) {
|
||||
if (this.prices == null) {
|
||||
return
|
||||
}
|
||||
|
||||
let found = false
|
||||
let that = this
|
||||
this.prices.forEach(function (v) {
|
||||
if (v.networkId == that.selectedNetworkId
|
||||
&& v.protectionBandwidth == that.selectedProtectionBandwidth
|
||||
&& v.serverBandwidth == that.selectedServerBandwidth
|
||||
&& v.periodId == periodId) {
|
||||
found = true
|
||||
}
|
||||
})
|
||||
return found
|
||||
}
|
||||
|
||||
this.changeCount = function () {
|
||||
if (this.selectedPrice == null) {
|
||||
this.amount = -1
|
||||
return
|
||||
}
|
||||
this.amount = this.selectedPrice.price * this.count
|
||||
|
||||
// 从服务器获取最新价格
|
||||
this.$post(".price")
|
||||
.params({
|
||||
packageId: this.selectedPackageId,
|
||||
periodId: this.selectedPeriodId,
|
||||
count: this.count
|
||||
})
|
||||
.success(function (resp) {
|
||||
this.amount = resp.data.amount
|
||||
})
|
||||
}
|
||||
|
||||
this.goNext = function () {
|
||||
if (this.selectedPackageId > 0 && this.selectedPeriodId > 0 && this.count > 0 && this.amount > 0) {
|
||||
window.location = "/anti-ddos/packages/confirm?packageId=" + this.selectedPackageId + "&periodId=" + this.selectedPeriodId + "&count=" + this.count
|
||||
}
|
||||
}
|
||||
|
||||
this.toBits = function (b) {
|
||||
let m = b.match(/^(\d+)(\w+)$/)
|
||||
let n = parseInt(m[1])
|
||||
switch (m[2]) {
|
||||
case "bps":
|
||||
return n
|
||||
case "Kbps":
|
||||
return n * 1024
|
||||
case "Mbps":
|
||||
return n * Math.pow(1024, 2)
|
||||
case "Gbps":
|
||||
return n * Math.pow(1024, 3)
|
||||
case "Tbps":
|
||||
return n * Math.pow(1024, 4)
|
||||
case "Pbps":
|
||||
return n * Math.pow(1024, 5)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
this.compareBits = function (b1, b2) {
|
||||
return (this.toBits(b1) > this.toBits(b2)) ? 1 : -1
|
||||
}
|
||||
|
||||
this.findPeriodWithId = function (periodId) {
|
||||
return this.allPeriods.$find(function (k, v) {
|
||||
return v.id == periodId
|
||||
})
|
||||
}
|
||||
|
||||
this.toPeriodMonths = function (period) {
|
||||
switch (period.unit) {
|
||||
case "year":
|
||||
return period.count * 12
|
||||
default:
|
||||
return period.count
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user