buy
<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的更多相关文章
- [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 ...
- [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 ...
- [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 ...
- [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 ...
- [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 ...
- Best Time to Buy and Sell Stock1,2,3,4
找到最低值和最高值 int maxProfit(vector<int>& prices) { ); ; ]; ;i<prices.size();i++) { profit=m ...
- [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 ...
- 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 ...
- [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 ...
- [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 ...
随机推荐
- SharePreferences的DB实现
存储一些简单数据的时候,最快的实现是用SharePreferences,但SharePreferences的可靠性不高,在某些非官方ROM上,总是存取失败.后来想到用数据库来存取.产品中,存取的数据项 ...
- angularjs里对JS的lowercase和uppercase的完善
读angularjs的源码开头. var lowercase = function (string) { return isString(string) ? string.toLowerCase() ...
- ACM/ICPC 之 最小割转网络流(POJ3469)
重点:构图 //最小割转网络流 //邻接表+Dinic //Time:5797Ms Memory:6192K #include<iostream> #include<cstring& ...
- float 比较, 这是一个坑
为了方便随机关键产品数据,做了一个随机值列的方案,列字段类型设置为float. 在测试的两个随机值的时候, 故意设置了几个随机值相同保存到数据库表中, 这样问题就出来了. 详细如下: 当进行小于比较的 ...
- iOS开发UI篇—CALayer简介
iOS开发UI篇—CALayer简介 一.简单介绍 在iOS中,你能看得见摸得着的东西基本上都是UIView,比如一个按钮.一个文本标签.一个文本输入框.一个图标等等,这些都是UIView. 其实 ...
- ORACLE用户创建&删除
●sqlplus登陆sqlplus sys/isc@testgmmc as sysdba●创建用户create user testpoi3 IDENTIFIED by iscaccount unloc ...
- 解决rand()伪随机数
利用time改变种子 例: #include <stdlib.h> #include <stdio.h> #include <time.h>//使用当前时钟做种子 ...
- Node.js学习之简介
1.简单的说Node.js就是运行在服务端的javaScript: 2.Node.js是一个基于Chrome javaScript运行时建立的一个平台: 3.Node.js是一个事件驱动I/O服务端J ...
- win10 系统怎么获取最高管理员权限删除文件
http://www.xitongcity.com/jiaocheng/win8_content_3473.html 很多win8.1系统用户在对磁盘文件进行清理时,经常会遇到“文件夹访问被拒绝,您需 ...
- win10打开组策略提示命名空间已经被定义
http://www.xitongcity.com/jiaocheng/win10jc_content_3629.html 最近有win10系统用户升级到10532版本时,无法打开组策略,弹出提示“命 ...