fd-gulp-convert-encoding
Version:
convert file to assigned charset
147 lines (124 loc) • 4.37 kB
JavaScript
define('detail.modules.logisticsInfo.View',
['jQuery', 'Class','lofty.ui.timer',
'detail.core.Event',
'detail.lib.pageDialog.PageDialog',
'detail.lib.orderValidator.OrderValidator',
'detail.lib.amountControl.AmountControl',
'detail.modules.logisticsInfo.FreightCost'],
function($, Class,Timer,Event,PageDialog,OrderValidator,AmountControl,FreightCost){
return Class({
init: function(view, config) {
this.onEvent = $.os.supportsTouch ? 'tap' : 'click';
this.div = view,
this.config = config;
this.bindEvent();
this.initCountdown();
this.initPopup();
this.initFreightCost();
this.initAmount();
this.cityName = $('#d-logistics-cityname');
},
bindEvent:function(){
var self = this;
Event.on('logisticsChange',function(data){
var province = data.pContent.split('_'),
city = data.content.split('_');
self.cityName.html(province[0]+city[0]);
self.config.provinceCode = province[1];
self.config.cityCode = city[1];
self.pageDialog.closeDialog();
self.handleFreightCost();
}).on('freightCostRender',function(data){
self.renderCost(data);
}).on('back',function(){
if (self.openDialog){
Event.trigger('areaList.closeDialog');
return false;
}
}).on('areaList.closeDialog',function(){
self.pageDialog.closeDialog();
self.openDialog = false;
});
this.div.on('click','span.d-logistics-cityname',function(){
self.openDialog = true;
self.pageDialog.showDialog();
Event.trigger('setCurPageDialog', self.pageDialog, self.config.action.module);
});
},
initPopup:function(){
var self = this;
if($('#d-logistics-cityname').length==0){return;}
this.pageDialog = new PageDialog({
module: 'areaList',
actionType: 'areaList',
afterClose: function(){
Event.trigger('resetCurPageDialog');
}
});
},
initCountdown:function(){
if($('#d-logistics-timer').length!=0){
var today = new Date().getTime();
new Timer({
to: this.config.countdown+today,
el: '#d-logistics-timer'
});
}
},
initAmount:function(){
var self = this,
elm = $('dl.booknum',this.div),
validator = new OrderValidator(this.config),
amountControl,
amount = $('input.amount-input').val()-0;
if(elm.length==0){return;}
amountControl = new AmountControl(elm, this.config, validator);
amountControl.setCallback(function(val,flag){
if(flag){
self.handleFreightCost();
}
});
self.handleFreightCost();
},
initFreightCost:function(){
var freightCost,config;
config = {
url:this.config.laputaServer+'/offer/ajax/CalculateFreight.do',
countryCode:1001,
provinceCode:this.config.provinceCode,
cityCode:this.config.cityCode,
beginAmount : this.config.beginAmount,
unitWeight : this.config.freightInfo.unitWeight,
refPrice : this.config.price,
freightTemplateId : this.config.freightInfo.freightTemplateId,
memberId : this.config.memberId,
volume : 0, // 体积目前没有
offerId : this.config.offerId
};
freightCost = new FreightCost(config);
freightCost.setCallback(function(o){
self.renderCost(o);
})
},
handleFreightCost:function(){
var param = {},
amount = $('input.amount-input').val()-0;
param.provinceCode = this.config.provinceCode;
param.cityCode = this.config.cityCode;
param.beginAmount= amount;
Event.trigger('freightCalculation',param);
},
renderCost:function(costs){
var priceinfo = $('div.priceinfo',this.div),
html = [],
temp;
for (var i = 0; i < costs.length; i++) {
temp = costs[i]
if(!(temp.subTemplate == '货到付款' && this.config.cashOnDeliveryOffer!=="true")){
html.push(temp.subTemplate+':<span class="fd-cny">¥ '+ temp.cost +'</span>')
}
};
priceinfo.html(html.join());
}
});
});