<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. (转)Intent flag 与启动模式的对应关系

    原文地址:http://www.cnblogs.com/ttylinux/p/4069513.html Activity有四种启动模式: 1.standard(标准)    2.singleTop   ...

  2. HikariCP

    HiKariCP是数据库连接池的一个后起之秀,号称性能最好,可以完美地PK掉其他连接池. 为何要使用HiKariCP?这要先从BoneCP说起: 什么?不是有C3P0/DBCP这些成熟的数据库连接池吗 ...

  3. [转]Struts2工作原理

    Struts2请求响应流程: 在struts2的应用中,从用户请求到服务器返回相应响应给用户端的过程中,包含了许多组件如:Controller.ActionProxy.ActionMapping.Co ...

  4. MySQL学习笔记(2/2)

    SQL种类 DDL/DML/DQL/DCL 中括号[]里面的表示可选,大括号{}里面的表示必须从里面选一个,FEILED表示字段. 数据定义语言(DDL):CREATE.DROP.ALTER 用于定义 ...

  5. (2016弱校联盟十一专场10.3) D Parentheses

    题目链接 把左括号看成A右括号看成B,推一下就行了.好久之前写的,推到最后发现是一个有规律的序列. #include <bits/stdc++.h> using namespace std ...

  6. myeclipse如何设置字体?

    1.首先,将你的Myeclipse打开. 找到上面的菜单“windows”打开“Preferences” 2.然后,在弹出的设置窗口中找到“colors and fonts” 3.将右边的basic打 ...

  7. Spring+SpringMvc+Mybatis框架集成搭建教程二(依赖配置及框架整合)

    依赖导入以及框架整合 (1).打开项目的pom.xml文件,声明依赖 <project xmlns="http://maven.apache.org/POM/4.0.0" x ...

  8. OSG透明代码

    //关闭灯光 state->setMode(GL_LIGHTING,osg::StateAttribute::OFF|osg::StateAttribute::PROTECTED); //打开混 ...

  9. JS && JSON

    将Json字符串转为Json对象以下3种方式: eval('(' + str + ')'); JSON.parse(str); jQuery.parseJSON(str): 将Json对象转为字符串: ...

  10. VS2012 自动为类文件添加头注释

    1. 打开文件夹 %VS110COMNTOOLS%..\IDE\ItemTemplates\CSharp\Code\1033\Class 2. 打开 Class.cs 文件,在其中添加 public ...