<script type="text/javascript">
var is_enabled = -1;
var checkSubmitFlg = false;
var sExFlag = 0;
var fhFlag = 0;
var shFlag = 0;
//check ABC
function checkABC () {
var ABCtype_id = $("#type_id").val();
if (ABCtype_id == "") {
//alert("请选择快递!");
goTotop('J_selectEx');
$("#J_selectExN").show();
$("#J_buyPrice").html("0.00");
is_enabled = 0;
return false;
}
var ABCaddress_id = $("#address_id").val();
if (ABCaddress_id == "") {
//alert("请选择发货地址!");
$("#address_id").focus();
$("#J_selectSentAddrN").show();
$("#J_buyPrice").html("0.00");
is_enabled = 0;
return false;
}
var ABCaddtext = $('#postscript').val();
if (ABCaddtext == "") {
//alert("请您填写收货地址!");
//$("#postscript").focus();
goTotop('J_shAddress');
$("#J_selectShAddrN").show();
$("#J_buyPrice").html("0.00");
$("#J_buyAmount").html("0");
is_enabled = 0;
return false;
}
}
// function chk_submit() {
checkABC ();
if (!checkSubmitFlg) {
checkSubmitFlg = true;
} else {
alert("双击无效,不能重复提交");
return false;
}
if (is_enabled == -1) {
alert('请先对数据进行校验!');
checkSubmitFlg = false;
$("#postscript").focus();
return false;
}
if (is_enabled != 1) {
alert('有错误数据,请调整后再提交!');
checkSubmitFlg = false;
return false;
}
} $("#J_selectEx li").click(function(){
$this = $(this);
$this.addClass("select-current").siblings().removeClass("select-current");
var $exName = $this.text();
$("#J_exName").html($exName.substring(0,4));
$("#J_selectExN").hide();
//$("#J_currPrice").html('');
$("#single_price").val('');
var type_id = $this.attr("id");
$("#type_id").val(type_id);
if (type_id == '' || type_id == 0) {
$("#current_text").html('');
$("#single_price").val('');
}
$("#order_nums").val('0');
$("#order_money").val('0');
$.post("/Order-getDetail.html", {
id: type_id
}, function(data, status) {
var return_data = data.data;
//alert(return_data.detail);
var datastr = return_data.detail;
var datastrs = new Array();
datastrs = datastr.split("|");
$("#v1").html(datastrs[0]);
$("#v2").html(datastrs[1]);
$("#v3").html(datastrs[2]);
$("#J_exDesc").html(datastrs[4]);
var current_text = return_data.current;
var single_price = return_data.price;
$("#J_currPrice").html(current_text);
$("#single_price").val(single_price);
//alert(single_price + "c");
if (status == 'success') {
//checkAdressList();
submitCalcAcoumt();
}
}, 'json');
//}
//checkisnos();
}); function checkAdressList() {
addtext = $('#postscript').val();
//是否错误标识
//alert(addtext);
isno = 1;
var addtextarr = new Array();
var adddan = new Array();
addtextarr = addtext.split("\n");
addstr = "";
addinputarr = "";
addsum = 0;
//最多一次只能提交100个
if (addtextarr.length <= 100) {
for (i = 0; i < addtextarr.length; i++) {
if (addtextarr[i] && trim(addtextarr[i]) != '') {
addtextarr[i] = addtextarr[i].replace(/\'/g, "");
addtextarr[i] = addtextarr[i].replace(/\,/g, ",");
addinputarr += "<input type='hidden' name='addinputarr[" + addsum + "]' value='" + addtextarr[i] + "' >";
adddan = trim(addtextarr[i]).split(",");
addsum += 1;
//保存表单数据方便提交
if (adddan.length != 5 && adddan.length != 4) {
$("#J_selectShAddrN").show().html("<div class='err-notice' >" + "第" + addsum + " 个收货地址格式有错误,请仔细检查!</div>");
goTotop('J_shAddress');
$("#J_buyAmount").html("0");
$("#J_buyPrice").html("0.00");
is_enabled = 0;
return false;
//alert("第" + addsum + " 个收货地址格式有错误,请仔细检查!"); }
if (adddan.length == 5) {
var shouhuodizhi = adddan[3]; //获取收件地址
} else if (adddan.length == 4) {
var shouhuodizhi = adddan[2]; //获取收件地址
}
var shdz_array = trim(shouhuodizhi).split(" ");
/*if (shdz_array.length < 4) {
$("#J_selectShAddrN").show().html("<div class='err-notice' >" + "第" + addsum + " 个收货地址格式中省、市、县之间应该用空格隔开,请仔细检查!</div>");
goTotop('J_shAddress');
$("#J_buyAmount").html("0");
$("#J_buyPrice").html("0.00");
is_enabled = 0;
return false; }*/
//判断地址之间空格是否是多个
if (exists_multispace(trim(shouhuodizhi))) {
$("#J_selectShAddrN").show().html("<div class='err-notice' >" + "第" + addsum + " 个收货地址格式中省、市、县之间只能用一个空格隔开,请仔细检查!</div>");
goTotop('J_shAddress');
$("#J_buyAmount").html("0");
$("#J_buyPrice").html("0.00");
is_enabled = 0;
return false;
}
$("#J_selectShAddrN").hide();
addstr += "<tr><td width='50' class='addyes'>" + addsum + "</td>";
for (j = 0; j < adddan.length; j++) {
//如果不是四个淘宝的逗号格式提示错误
if (adddan.length != 5 && adddan.length != 4) {
//如果有数据就显示 ,没有显示空
if (adddan[j]) {
addstr += "<td class='adderror'>" + adddan[j] + "</td>";
$("#J_selectShAddrN").show().html("<div class='err-notice' >" + "第" + adddan[j] + " a1!</div>" );
$("#J_buyAmount").html("0");
$("#J_buyPrice").html("0.00");
is_enabled = 0;
return false; } else {
addstr += "<td class='adderror'>" + "</td>";
$("#J_selectShAddrN").show().html("第" + adddan[j] + " a2!");
$("#J_buyAmount").html("0");
$("#J_buyPrice").html("0.00");
is_enabled = 0;
return false; }
} else {
if (adddan.length == 4 && j == 2) {
addstr += "<td class='td-w-" + j + "'>无</td>";
}
if (isno == 0) {
addstr += "<td class='adderror'>" + adddan[j] + "</td>";
$("#J_selectShAddrN").show().html("第" + adddan[j] + " b1!");
$("#J_buyAmount").html("0");
$("#J_buyPrice").html("0.00");
is_enabled = 0;
return false;
} else {
addstr += "<td class='td-w-" + j + "'>" + adddan[j] + "</td>";
}
}
}
addstr += "</tr>";
}
}
} else {
alert("亲,一次最多只能批量下100单,请减少收货地址!");
isno = 0;
} current_price = parseFloat($('#single_price').val());
if (current_price <= 0) {
alert("你选择的快递单价出错!");
return false;
}
//alert("addsum");
//alert(current_price + "dd");
//计算价格
kuaidisum = addsum * current_price; var table_html = '<div class="ct-address-list"><table cellpadding="0" width="100%"" cellspacing="0"><thead><tr><th width="50"><p>编号</p></th><th width="80"><p>名字</p></th><th width="110"><p>手机</p></th><th width="110"><p>电话</p></th><th><p>地址</p></th><th width="70">邮编</th></tr></thead><tbody>' + addstr + '</tbody></table></div>' + " <input type='hidden' value=" + kuaidisum.toFixed(2) + " name='kuaidipicle' id='kuaidipicle' /><input type='hidden' value='0' name='youyuer' id='youyuer'/>";
$('#J_checkTab').html(table_html);
$('#addinputarrs').html(addinputarr);
//alert(isno);
//alert(addsum +"r");
is_enabled = isno;
return (isno); } function calcuAmount() {
$("#order_nums").val(addsum);
$("#order_money").val(kuaidisum);
var yingfuk = kuaidisum.toFixed(2);
$('#J_buyAmount').html(addsum);
$('#J_buyPrice').html(yingfuk);
} function submitCalcAcoumt() {
//alert("subm");
var ABCtype_id = $("#type_id").val();
if (ABCtype_id != "") {
sExFlag = 1;
}
var ABCaddress_id = $("#address_id").val();
if (ABCaddress_id != "") {
fhFlag = 1;
}
checkAdressList();
if(sExFlag == 1 && fhFlag == 1 && isno == 1){
calcuAmount();
}else{
$("#J_buyPrice").html("0.00");
}
}
function trim(str) {
str = str.replace(/^(\s|\u00A0)+/, '');
for (var i = str.length - 1; i >= 0; i--) {
if (/\S/.test(str.charAt(i))) {
str = str.substring(0, i + 1);
break;
}
}
return str;
} function exists_multispace(str) {
var rtn_result = false;
var str_length_old = str.length;
str = str.replace(/\ /g, " ");
var str_length = str.length;
if (str_length_old != str_length) {
rtn_result = true;
}
return rtn_result;
}
//
function goTotop(obj){
var _targetTop = $('#'+obj).offset().top;//获取位置
jQuery("html,body").animate({scrollTop:_targetTop},300);//跳转
}
//
$("#address_id").change(function(){ var ABCaddress_id = $("#address_id").val();
if (ABCaddress_id != "") {
$("#J_selectSentAddrN").hide();
fhFlag = 1;
submitCalcAcoumt();
}else{
$("#J_selectSentAddrN").show();
}
});
$("#postscript").bind("keyup paste",function(){
submitCalcAcoumt();
});
</script>

  

buy的更多相关文章

  1. [LeetCode] Best Time to Buy and Sell Stock with Cooldown 买股票的最佳时间含冷冻期

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  2. [LeetCode] Best Time to Buy and Sell Stock IV 买卖股票的最佳时间之四

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  3. [LeetCode] Best Time to Buy and Sell Stock III 买股票的最佳时间之三

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  4. [LeetCode] Best Time to Buy and Sell Stock II 买股票的最佳时间之二

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  5. [LeetCode] Best Time to Buy and Sell Stock 买卖股票的最佳时间

    Say you have an array for which the ith element is the price of a given stock on day i. If you were ...

  6. Best Time to Buy and Sell Stock1,2,3,4

    找到最低值和最高值 int maxProfit(vector<int>& prices) { ); ; ]; ;i<prices.size();i++) { profit=m ...

  7. [LeetCode] Best Time to Buy and Sell Stock II

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  8. 4 Best Time to Buy and Sell Stock III_Leetcode

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  9. [LintCode] Best Time to Buy and Sell Stock II 买股票的最佳时间之二

    Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...

  10. [LintCode] Best Time to Buy and Sell Stock 买卖股票的最佳时间

    Say you have an array for which the ith element is the price of a given stock on day i. If you were ...

随机推荐

  1. javascript闭包和作用域链

    最近在学习前端知识,看到javascript闭包这里总是云里雾里.于是翻阅了好多资料记录下来本人对闭包的理解. 首先,什么是闭包?看了各位大牛的定义和描述各式各样,我个人认为最容易一种说法: 外部函数 ...

  2. linux下动态链接库解决方案(二)

    以前写过一个关于linux下用c++写动态链接库无法通过的解决方案,今天看到<linux C程序设计-王者归来>这本书,书中有个更容易的解决方案,特此记录下来 书中使用的是c语言,我改用c ...

  3. October 19th Week 43rd Wednesday, 2016

    I find that the harder I work, the more luck I seem to have. 越努力,越幸运. However, I find that the harde ...

  4. hive创建索引

    索引是hive0.7之后才有的功能,创建索引需要评估其合理性,因为创建索引也是要磁盘空间,维护起来也是需要代价的 创建索引 hive> create index [index_studentid ...

  5. C++ 基础知识复习(三)

    43. 继承的几种方式: 答:共有继承public,保护继承protected,私有继承private.其中后两种继承会改变原有的访问级别. 44. 深复制与浅复制: 答:简单理解,深复制自己申请了内 ...

  6. 再谈通过http访问SSAS

    问题: 在有些场景下,数据中心会分为不同的服务器场:数据库场和应用程序场.服务器场间有严格的防火墙控制,其中数据库场只能建立从应用程序场的防火墙穿越,也就是说不允许任何客户端直接连接到防火墙. 这种策 ...

  7. Win7+Ubuntu双系统安装完成后时间不一致相差大概8小时

    Win7+Ubuntu双系统时间不一致 解决方法: 第一种在Windows下进行如下修改: 在 注册表项:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Con ...

  8. [译]:Orchard入门——给网站添加新博客

    原文链接:Adding a Blog to Your Site 文章内容基于Orchard 1.8版本 Orchard提供一个博客引擎--这让添加一个新博客到你网站变得非常容易. 本文将介绍怎样添加一 ...

  9. SQL SERVER 中的提示

    提示是指定的强制选项或策略,由 SQL Server 查询处理器针对 SELECT.INSERT.UPDATE 或 DELETE 语句执行. 提示将覆盖查询优化器可能为查询选择的任何执行计划. 注意: ...

  10. supervisor:How is this different from daemontools ?

    "daemontools has too much focus on security as opposed to being a process manager for my taste. ...