mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-03-29 16:48:02 +08:00
在面板上显示余额和剩余时长
This commit is contained in:
@@ -2,6 +2,7 @@ _ = require 'underscore'
|
||||
|
||||
config = require '../config'
|
||||
api = require './index'
|
||||
billing = require '../billing'
|
||||
|
||||
mAccount = require '../model/account'
|
||||
|
||||
@@ -11,12 +12,16 @@ module.exports =
|
||||
res.redirect '/panel/'
|
||||
|
||||
'/panel/': api.accountAuthenticateRender (req, res, account, renderer) ->
|
||||
plans = []
|
||||
billing.calcBilling account, (account) ->
|
||||
plans = []
|
||||
|
||||
for name, info of config.plans
|
||||
plans.push _.extend info,
|
||||
name: name
|
||||
isEnable: name in account.attribute.plans
|
||||
for name, info of config.plans
|
||||
plans.push _.extend info,
|
||||
name: name
|
||||
isEnable: name in account.attribute.plans
|
||||
|
||||
renderer 'panel',
|
||||
plans: plans
|
||||
account.attribute.remaining_time = Math.ceil(billing.calcRemainingTime(account) / 24)
|
||||
|
||||
renderer 'panel',
|
||||
account: account
|
||||
plans: plans
|
||||
|
||||
@@ -25,3 +25,15 @@ exports.calcBilling = (account, callback) ->
|
||||
mAccount.update _id: account._id, modifier, {}, ->
|
||||
mAccount.findId account._id, (account) ->
|
||||
callback account
|
||||
|
||||
exports.calcRemainingTime = (account) ->
|
||||
price = 0
|
||||
|
||||
for planName in account.attribute.plans
|
||||
plan = config.plans[planName]
|
||||
|
||||
price += plan.price / 30 / 24
|
||||
|
||||
console.log price
|
||||
|
||||
return account.attribute.balance / price
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
"logout": "注销"
|
||||
},
|
||||
"panel": {
|
||||
"": "管理面板"
|
||||
"": "管理面板",
|
||||
"overview": "概况"
|
||||
},
|
||||
"ticket": {
|
||||
"": "工单",
|
||||
@@ -42,11 +43,21 @@
|
||||
"members": "成员"
|
||||
},
|
||||
"plan": {
|
||||
"": "套餐"
|
||||
"": "套餐",
|
||||
"subscribe": "订购",
|
||||
"unsubscribe": "退订",
|
||||
"balance": "余额",
|
||||
"remaining_time": "剩余时长",
|
||||
"currency": {
|
||||
"cny": "CNY"
|
||||
}
|
||||
},
|
||||
"admin": {
|
||||
"admin_panel": "管理员面板"
|
||||
},
|
||||
"time": {
|
||||
"day": "天"
|
||||
},
|
||||
"view": {
|
||||
"layout": {
|
||||
"navigation": "展开导航"
|
||||
|
||||
@@ -19,10 +19,13 @@ block content
|
||||
a(href='/ticket/list/')
|
||||
span.glyphicon.pull-right.glyphicon-edit
|
||||
| #{t('ticket.')}
|
||||
|
||||
|
||||
.col-md-9
|
||||
.row
|
||||
header 概况
|
||||
header= t('panel.overview')
|
||||
p
|
||||
| #{t('plan.balance')}: #{account.attribute.balance.toFixed(2)} #{t('plan.currency.cny')}
|
||||
| #{t('plan.remaining_time')}: #{account.attribute.remaining_time} #{t('time.day')}
|
||||
|
||||
.row
|
||||
header= t('plan.')
|
||||
@@ -35,7 +38,6 @@ block content
|
||||
td= plan.t_resources
|
||||
td
|
||||
if plan.isEnable
|
||||
button.btn.btn-danger.btn-sm 退订
|
||||
button.btn.btn-danger.btn-sm= t('plan.unsubscribe')
|
||||
else
|
||||
button.btn.btn-success.btn-sm 订购
|
||||
|
||||
button.btn.btn-success.btn-sm= t('plan.subscribe')
|
||||
|
||||
Reference in New Issue
Block a user