Authored by weiqingting

订单确认

... ... @@ -2,4 +2,144 @@
* @description: 订单保存
* @time: 2015/12/21
*/
var $ = require('yoho.jquery');
var Order={
Data:{
product:0,
activity:0,
carriage:0,
juan:0,
yohocoin:0
},
UI:{
e:{
$pan: $('.pan'),
$jc: $("#juancode"),
$bp:$("#biprice"),
$statistics:$("li",".play-total"),
$tobi:$("p em",".play-bi-pan .play-pan"),
$cancel:$(".cancel",".btn-group")
},
init:function(){
var e=this.e;
/*初始化价格*/
this.render();
/*点击pan dt 打开dd*/
e.$pan.find("dt").click(function () {
var pan=$(this).parent("dl.pan");
if(pan.find("dd").is(":hidden")){
pan.find("dd").show();
if(pan.attr("class").match(/(-bi-)|(-juan-)/g)){
$(this).hide();
}
}else{
pan.find("dd").hide();
}
});
/*使用优惠卷支付 下面的文本框*/
e.$jc.focus(function(){
$(this).prev("label").prev(":radio").attr("checked",true);
}).change(function(){
$(this).prev("label").prev(":radio").val($(this).val());
});
/*使用YOHO币支付*/
e.$bp.data("tobi",e.$tobi.html())
e.$bp.keyup(function(){
var bi=Order.Common.enterNUM($(this).val(),$(this).data("tobi"));
$(this).val(bi);
}).change(function(){
var bi=Order.Common.enterNUM($(this).val(),$(this).data("tobi"));
$(this).val(bi);
});
/*取消关闭小窗口*/
e.$cancel.click(function(){
var p=$(this).parents(".pan");
p.find("dt").show();
p.find("dd").hide();
});
},
render:function(){
var e=this.e,d=Order.Data;
e.$statistics.slice(3,5).hide();
e.$statistics.slice(2,5).find("em").html("0.00");
if(d.carriage){
e.$statistics.eq(2).find("em").html(d.carriage);
}
if(d.juan){
e.$statistics.eq(3).show().find("em").html(d.juan);
}
if(d.yohocoin){
e.$statistics.eq(4).show().find("em").html(d.yohocoin);
}
}
},
Common:{
enterNUM:function(str1,str2){
str1=str1.replace(/[^\d]/g,'');
if(str1&&str2){
str1=parseInt(str1);
str2=parseInt(str2);
if(str1>str2){
str1=str2;
}
}
return str1;
},
calucate:function(){
var p=Order.Data;
$.each(Order.Data,function(key,index){
p[key]=parseFloat(Order.Data[key]);
});
return p.product-p.activity+p.carriage-p.juan-p.yohocoin;
}
},
Submit:{
e:{
$juanok:$("#juansubmit"),
$juantip:$(".errtip",".play-juan-pan"),
$biok:$("#juansubmit")
},
init:function(){
var e=this.e;
e.$juanok.click(function(){
$jgroup=$('input[name="juangroup"]:checked');
var pan=$(this).parents(".pan");
if($jgroup.val()){
var options={
url:'/Order/save/priceByCode',
type:'post',
data:{code:$jgroup.val()},
success:function(data){
if(data.code===200){
if(data.price){
Order.Data.juan=data.price;
}
Order.UI.render();
pan.hide();
}
e.$juantip.html(data.msg);
},
error:function(){
e.$juantip.html(data.msg);
}
}
$.ajax(options);
}
});
}
}
}
Order.UI.init();
Order.Submit.init();
... ...
@import "save";
\ No newline at end of file
@import "save";
@import "pay";
\ No newline at end of file
... ...
.order-pay{
font-size: 12px;
line-height: 150%;
.pay-wapper{
border: 1px solid #ccc;
}
table{
width: 100%;
td{
border: 1px solid #ccc;
border-left: 0 none;
padding: 10px;
text-align: center;
}
}
thead{
background: #000;
th{
height: 32px;
line-height: 32px;
color: #fff;
vertical-align: middle;
text-align: center;
font-weight: bold;
}
.clo1{
width: 10%;
}
.clo2{
width: 20%;
}
.clo4{
width: 40%;
}
}
.pay-pro{
.pay-pro-icon{
float: left;
display: inline;
width: 60px;
height: 60px;
display: block;
}
.pay-pro-info{
color: #999;
margin-left:70px;
padding-top: 15px;
text-align: left;
a{
color: #468fa2;
text-decoration: none;
display: block;
&:hover{
text-decoration: underline;
}
}
}
}
.play-content{
padding: 10px;
.red{
color: #e8044f!important;
}
.orange{
color: #f60!important;
}
.strong{
font-weight: bold;
color: #000;
}
.pan{
dt{
width: 105px;
height: 30px;
padding: 0px 0px 0px 30px;
line-height: 30px;
text-align: left;
border: 0px;
color: #fff;
display: inline-block;
cursor: pointer;
background: url(http://static.yohobuy.com/images/btn_openclose.png) no-repeat 0px -60px;
margin-bottom:5px;
}
dd{
display: none;
border: 1px #ccc solid;
padding: 10px 15px;
margin-bottom: 10px;
}
}
.textbox{
height: 20px;
line-height: 20px;
color: #333;
border: 1px #c9c9c9 solid;
vertical-align: top;
}
.dropdown{
height: 20px;
line-height: 20px;
color: #333;
border: 1px #c9c9c9 solid;
vertical-align: top;
}
.btn-group{
text-align: right;
input{
display: inline-block;
background: none;
border: 1px solid #ccc;
border-radius: 2px;
height: 20px;
}
.ok{
background-color: #000;
color:#fff;
}
}
.play-left{
float: left;
width: 405px;
.pan{
text-align: left;
dt{
color: #000;
background: url(http://static.yohobuy.com/images/btn_openclose.png) no-repeat 0px 0px;
}
}
}
.play-piao-pan{
li{
height: 25px;
padding: 10px 0px;
line-height: 22px;
label{
width: 65px;
display: inline-block;
}
.textbox{
width: 200px;
}
}
}
.play-remark-pan{
.textbox{
width: 369px;
height: 70px;
}
.note{
padding: 5px 0;
color: #999;
}
}
.play-right{
float: right;
width: 50%;
width: 405px;
.play-total{
text-align: right;
padding-bottom: 20px;
label{
padding-right: 10px;
}
em{
width: 80px;
text-align: left;
display: inline-block;
}
}
.pan{
text-align: right;
}
}
.play-juan-pan{
dd{
text-align: left;
}
.play-juan{
padding: 10px 0;
.textbox{
width: 70px;
}
}
}
.play-bi-pan{
dd{
text-align: right;
}
.textbox{
width: 70px;
}
p{
padding: 10px 0;
}
}
}
.to-play{
p{
padding: 10px 0px;
font-size: 14px;
text-align: right;
color: #000;
em{
color: #e8044f;
font-size: 24px;
}
}
.btn-group{
padding: 10px 0px 40px 0px;
.submit{
float: right;
width: 133px;
height: 33px;
padding: 0px;
text-align: center;
border: 0px;
line-height: 33px;
font-size: 14px;
color: #fff;
font-weight: bold;
background: url(http://static.yohobuy.com/images/btns.png) no-repeat 0px -33px;
display: inline-block;
cursor: pointer;
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -10,10 +10,33 @@ class SaveController extends AbstractAction
public function indexAction()
{
$data = array(
'orderSavePage' => true
'orderSavePage' => true,
'orderSave'=>array(
'orderProducts'=>array(
array('name' =>"Eight Guys 破洞束口牛仔裤",'tip'=>"颜色:蓝色 尺码:L",'unitprice'=>'179.00','currency'=>'0','count'=>'0'),
array('name' =>"Eight Guys 破洞束口牛仔裤",'tip'=>"颜色:蓝色 尺码:L",'unitprice'=>'179.00','currency'=>'0','count'=>'0')
)
)
);
$this->_view->display('index', $data);
}
/*获取优惠卷的面额*/
public function priceByCodeAction()
{
$result = array();
do {
$result=array(
'code'=>200,
'msg'=>'成功',//卷不存在,过期等等
'price'=>'10'
);
} while (false);
$this->echoJson($result);
}
}
\ No newline at end of file
... ...