usercontroller.php
public function assetAction()
{
$isLogin = parent::sessionGet ( 'portalLogin', false );
if (! $isLogin) {
return parent::buildResponse ( 10400 );
}
$userId = parent::sessionGet ( 'userId', 0 );
$userAsset = $this->get ( 'user_asset_service' )->getByUserId ( $userId );
$amountAvailable = $userAsset->getAmountAvailable ();
$result = array (
'userId' => $userId,
'amountAvailable' => $amountAvailable
);
return $this->render('MirrorMarketBundle:User:asset.html.twig', $result);
}
assetRecharge.html.twig
{% block user %}
<div class='info_back'>
<div id="main_right_title">
</div>
<div class='block'>
<div class="block_title">
充值
</div>
<div class='block_content'>
<form id='recharge_form' class='classic_form' action='rechargeConfirm' method='post' οnsubmit='return checkRechargeForm(this)'>
<table class='form_tbl'>
<tr>
<td>支付方式:</td>
<td>
<div id='mopList'>
{% for mop in mops %}
<input type="radio" id="input_mop_{{mop.code}}" name="mop" value="{{mop.code}}" />{{ asset('bundles/mirrormarket/images/unionpay_logo.png') }}{{mop.name}}
{% endfor %}
</div>
</td>
</tr>
<tr>
<td>充值金额:</td>
<td><input type='text' id='input_rechargeAmount' name='rechargeAmount' /></td>
</tr>
<tr>
<td colspan='2'><input type='checkbox' class='_checkbox' name='service_protocol' id='input_service_protocol' />我已阅读并同意《充值服务条款》</td>
</tr>
<tr>
<td colspan='2'><input type='submit' name='btn_recharge' id='btn_recharge' class='action_btn' value='下一步' /></td>
</tr>
</table>
</form>
</div>
</div>
</div>
{% endblock %}
assetRecharge.js
function validate_required(field,alerttxt){
with (field){
if (value==null||value==""){
alert(alerttxt);
return false;
}
else{
return true;
}
}
}
function checkRechargeForm(thisform){
with (thisform){
if (validate_required(mop, "请选择支付方式!")==false){
mop.focus();
return false;
}
if (validate_required(rechargeAmount, "请输入充值金额!")==false){
rechargeAmount.focus();
return false;
}
if (validate_required(service_protocol, "尊敬的客户,为了您的权益,请阅读并同意我们的服务条款!")==false){
service_protocol.focus();
return false;
}
}
return true;
}