<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:set var="ctx" value="${pageContext.request.contextPath}" /> <jsp:include page="/jsp/common/header1.jsp"></jsp:include> <script type="text/javascript" src="${ctx }/js/common/area_linkage.js"></script> <script type="text/javascript" src="${ctx}/js/order/create_order_main.js?20140930"></script> <% String memberId1 = request.getParameter("memberId"); %> <c:set var="memberId1" value="<%=memberId1%>"/> <input type="hidden" id="memberId1" name="memberId1" value="${memberId1 }"/> <span style="font-weight: bold;font-size: 9pt">請選擇訂單來源:</span> <table class="queryTable" > <tbody> <tr> <td class="queryTitle" style="width:80px" >訂單來源</td> <td class="queryContent" style="width:150px"> <input class="inputText" type="text" id="multiChannelId" style="width: 150px"/> </td> </tr> </tbody> </table> <!-- 會員查詢區 --> <br/> <span style="font-weight: bold;font-size: 9pt">請選擇會員: <a href="javascript:void(0)" onclick="addMemberPage();">註冊新會員</a></span> <table class="queryTable" width="804" > <tr> <td class="queryTitle" width="80">聯繫電話</td> <td class="queryContent"> <input class="inputText" type="text" id="tel" style="width: 100px"/> </td> <td class="queryTitle" width="80">手機號碼</td> <td class="queryContent"> <input class="inputText" type="text" id="mobile" style="width: 100px"/> </td> <td class="queryTitle" width="80">會員登陸名</td> <td class="queryContent"> <input class="inputText" type="text" id="loginName" style="width: 100px"/> </td> <td align="right" colspan="2"> <a class="easyui-linkbutton" href="javascript:void(0)" iconCls="icon-search" onclick="queryMember()">查詢</a> </td> </tr> </table> <!-- 會員grid --> <table id="memberGrid"></table> <br> <a class="easyui-linkbutton" href="javascript:void(0)" iconCls="icon-exportExcel" onclick="showImportDialog()">訂單批量導入</a> <br> <!-- 商品或贈品grid --> <br/> <span style="font-weight: bold;font-size: 9pt">請選擇商品和贈品: </span> <br/> <table id="orderItemEditGrid"></table> <br/> <!-- 收貨地址grid --> <span style="font-weight: bold;font-size: 9pt">請選擇收貨地址: <a href="javascript:void(0)" onclick="addMemmberAddress();">使用新地址</a></span> <br/> <table id="addressGrid"></table> <!-- 發票信息 --> <br/> <span style="font-weight: bold;font-size: 9pt">請填寫發票信息: </span> <form id="editInvoiceForm"> <table class="queryTable" id="invoiceTable"> <tbody> <tr id="headTr"> <td class="queryTitle" style="width:80px" >發票類型</td> <td class="queryContent" style="width:300px"> <input type="radio" id="general" name="invoiceType" value="general" onclick="changeType('general')"/>普通發票 <input type="radio" id="vat" name="invoiceType" checked="checked" value="none" onclick="changeType('none')"/>無發票 </td> </tr> </tbody> </table> </form> <table style="display: none"> <tbody id="general_table"> <tr rel="dny" id="cHeadTr"> <td class="queryTitle">發票內容類型</td> <td class="queryContent"> <input type="radio" id="private" name="invoiceContentType" value="private" onclick="changeContentType('private')"/>我的 <input type="radio" id="company" name="invoiceContentType" value="company" onclick="changeContentType('company')"/>單位 </td> </tr> </tbody> </table> <table style="display: none"> <tbody id="general_personal_table"> <tr rel="dny_gen"> <td class="queryTitle">發票內容</td> <td class="queryContent"> <input class="inputText text_plus" type="text" id="invoiceContent" name="invoiceContent" value="${orderInfo.invoiceContent }"/> </td> </tr> </tbody> </table> <table style="display: none"> <tbody id="general_company_table"> <tr rel="dny_gen"> <td class="queryTitle">單位名稱</td> <td class="queryContent"> <input class="inputText text_plus" type="text" id="invoiceTitle" name="invoiceTitle" value="${orderInfo.invoiceTitle }"/> </td> </tr> <tr rel="dny_gen"> <td class="queryTitle">發票內容</td> <td class="queryContent"> <input class="inputText text_plus" type="text" id="invoiceContent" name="invoiceContent" value="${orderInfo.invoiceContent }"/> </td> </tr> </tbody> </table> <!-- 配送、支付信息 --> <span style="font-weight: bold;font-size: 9pt">請填寫配送、支付信息: </span> <table class="queryTable" > <tbody> <!-- <tr> <td class="queryTitle" style="width:80px" >配送日期</td> <td class="queryContent" style="width:300px"> <select id="receiveDateType" name="receiveDateType"> <option value="">請選擇</option> <option value="workday">工做日</option> <option value="holiday">節假日</option> <option value="allday" selected="selected">工做日、節假日都可</option> </select> </td> <td class="queryTitle" style="width:80px" >配送時間</td> <td class="queryContent" style="width:300px"> <select name="receiveTimeType" id="receiveTimeType" > <option value="">請選擇</option> <option value="morning">上午</option> <option value="afternoon">下午</option> <option value="allday" selected="selected">全天都可</option> </select> </td> </tr> --> <tr> <td class="queryTitle" style="width:80px" >支付類型</td> <td class="queryContent" style="width:300px"> <select name="paymentMode" id="paymentMode" onchange="calcFee()"> <option value="" >請選擇</option> <option value="KDFH" id="op_KDFH" selected="selected">款到發貨</option> <option value="HDFK" id="op_HDFK">貨到付款</option> </select> </td> <!-- <td class="queryTitle" style="width:80px">支付方式</td> <td class="queryContent"> <select id="paymentTypeId" name="paymentTypeId"> </select> </td> --> </tr> </tbody> </table> <span style="font-weight: bold;font-size: 9pt">優惠券信息: </span> <table class="queryTable" width="400"> <tbody> <tr> <td class="queryTitle" align="left"><input type="radio" id="couponNoID1" name="couponNoChoose" value="SRK" />請輸入優惠券號 </td> <td class="queryContent"><input class="inputText easyui-validatebox" maxlength="20" type="text" id="couponNo" /></td> </tr> <tr> <td class="queryTitle" align="left"><input type="radio" id="couponNoID2" name="couponNoChoose" value="XL" checked="checked" />請使用帳號中優惠券 </td> <td class="queryContent"> <select name="couponNoXLName" id="couponNoXL"> </select> </td> </tr> <tr> <td class="queryContent" align="center" colspan="2"> <label id="checkCouponNoA"><a class="easyui-linkbutton" href="javascript:void(0)" onclick="checkCouponNo()">肯定</a></label> <label id="checkCouponNoQK"><a class="easyui-linkbutton" href="javascript:void(0)" onclick="checkCouponNoQK()">清空</a></label> </td> </tr> </tbody> </table> <!-- 結算信息 --> <br/> <span style="font-weight: bold;font-size: 9pt">結算信息以下: </span> <input type="hidden" id="deliveryFeeHid" name="deliveryFeeHid"/><!-- 運費 --> <input type="hidden" id="skuWeightsHid" name="skuWeightsHid"/><!-- 貨品總重 --> <input type="hidden" id="skuFeeHid" name="skuFeeHid"/><!-- 貨款金額 --> <input type="hidden" id="discountFeeHid" name="discountFeeHid"/><!-- 優惠後金額 --> <input type="hidden" id="orderFeeHid" name="orderFeeHid"/><!-- 訂單金額 --> <table class="queryTable" > <tbody> <tr> <td class="queryTitle" style="width:60px" >使用積分</td> <td class="queryContent" style="width:700px" colspan="3"> <input class="inputText" type="text" id="orderPoints" style="width: 150px" onchange="calcFee();"/> 積分與現金兌換比例爲<span style="color:red;font-size: 9pt" id="pointVsMoneySpan"></span>, 可用積分數爲:<span style="color:red;font-size: 9pt" id="currentPoints"></span>, 兌換後可用現金爲:<span style="color:red;font-size: 9pt" id="currentMoney"></span> </td> <td class="queryTitle" style="width:80px" >優惠券優惠金額</td> <td class="queryContent"> <input type="text" id="couponNoFee" value="" style="border:0px" readonly="readonly"/> </td> </tr> <tr> <td class="queryTitle" style="width:60px" >運費</td> <td id="deliveryFeeTd" class="queryContent" style="width:200px"> </td> <td class="queryTitle" style="width:60px" >訂單金額</td> <td id="orderFeeTd" class="queryContent" style="width:200px"> </td> <td class="queryTitle" style="width:60px" >來源媒體</td> <td id="orderFeeTd" class="queryContent" style="width:200px"> <select id="addUrlFromNo" name="addUrlFromNo"> <option value="健一網" selected="selected">健一網</option> <option value="網盟">網盟</option> <option value="搜索引擎">搜索引擎</option> </select> </td> </tr> </tbody> </table> <!-- 提交按鈕 --> <div style="width:700px;margin-top: 5px;text-align: center"> <!-- <a class="easyui-linkbutton" href="javascript:void(0)" iconCls="icon-ok" onclick="calcFee()">計算訂單金額</a> --> <a class="easyui-linkbutton" href="javascript:void(0)" iconCls="icon-ok" onclick="doCreateOrder()">提交訂單</a> <a class="easyui-linkbutton" href="javascript:void(0)" iconCls="icon-cancel" onclick="closeTab()">取消下單</a> </div> <!-- 註冊新會員 --> <div id="addMemberDlg" class="easyui-window" closed="true" title="" iconCls="icon-add" style="width:400px; height:280px;text-align:center; background: #fafafa;"> <div class="easyui-layout" fit="true"> <div region="center" border="false" style="background:#fff;border:1px solid #ccc;padding-left: 30px;"> <form id="addForm" method="POST"> <table border="0" class="queryTable" > <tr> <td class="queryTitle" width="100">登陸賬號</td> <td class="queryContent" align="left" colspan = "2"> <input class="inputText easyui-validatebox" maxlength = "40" type="text" id="addLoginName" /> <a class="easyui-linkbutton" href="javascript:void(0)" onclick="checkLoginName()">校驗</a> </td> </tr> <tr> <td class="queryTitle" width="100">登陸密碼</td> <td class="queryContent" align="left" colspan = "3"> <input class="txt01 easyui-validatebox" maxlength = "20" type="Password" id="addLoginPassword" /> </td> </tr> <tr> <td class="queryTitle" width="100">確認密碼</td> <td class="queryContent" align="left" colspan = "3"> <input class="txt01 easyui-validatebox" maxlength = "20" type="Password" id="addConfirmPassword" /> </td> </tr> <tr> <td class="queryTitle" width="100">會員姓名</td> <td class="queryContent" align="left" colspan = "3"> <input class="inputText easyui-validatebox" maxlength = "40" type="text" id="addRealName" /> </td> </tr> <tr> <td class="queryTitle" width="100">手機號</td> <td class="queryContent" align="left" colspan = "3"> <input class="inputText easyui-validatebox" maxlength = "20" type="text" id="addMobile" /> </td> </tr> </table> </form> </div> <div region="south" border="false" style="text-align:center;height:30px;line-height:30px;"> <a class="easyui-linkbutton" href="javascript:void(0)" iconCls="icon-ok" onclick="addMember()">肯定</a> <a class="easyui-linkbutton" href="javascript:void(0)" iconCls="icon-cancel" onclick="closeAddMemberDlg()">取消</a> </div> </div> </div> <!-- 新增收貨地址 --> <div id="addMemberAddressWindow" class="easyui-window" title="" closed="true" iconCls="icon-add" style="width:650px; height:320px;text-align:center; background: #fafafa;"> <div class="easyui-layout" fit="true"> <div region="center" border="false" style="background:#fff;border:1px solid #ccc;padding-left: 30px;"> <form id="addMemberAddressForm" method="POST" style="width: 380px;height:230px; text-align: center;"> <input type="hidden" id="hdProId" /> <input type="hidden" id="hdCityId" /> <input type="hidden" id="hdAreaId" /> <table border="0" class="queryTable" width="580px" height="190px" style="margin-bottom: 0px" > <tr> <td class="queryTitle" style="width:80px" >收貨地址</td> <td class="queryContent" style="width:670px" colspan="3"> <input id="provinceId" required="true" /> 省 <input class="inputText" type="text" id="cityId" required="true" /> 市 <input class="inputText" type="text" id="areaId" required="true" /> 區 <br><br> <input type="text" class="inputText easyui-validatebox" style="margin-bottom: 4px;width: 400px" validType="maxLength[40]" id="fullAddress" name="fullAddress" required="true"/> </td> </tr> <tr> <td class="queryTitle">收貨人</td> <td class="queryContent"> <input class="inputText easyui-validatebox" type="text" id="receiveUser" name="receiveUser" required="true"/> </td> <td class="queryTitle">手機</td> <td class="queryContent"> <input class="inputText easyui-validatebox" type="text" id="receiveMobile" name="receiveMobile" required="true" validType="maxLength[11]"/> </td> </tr> <tr> <td class="queryTitle">電話</td> <td class="queryContent"> <input class="inputText" type="text" id="receiveTel" name="receiveTel" validType="maxLength[12]"/> </td> <td class="queryTitle">郵編</td> <td class="queryContent"> <input class="inputText" type="text" id="receivePost" name="receivePost" /> </td> </tr> </table> </form> </div> <div region="south" border="false" style="text-align:center;height:30px;line-height:30px;"> <a id="okBtn" class="easyui-linkbutton" iconCls="icon-ok" href="javascript:void(0)" onclick="saveAdd()">肯定</a> <a id="cancelBtn" class="easyui-linkbutton" iconCls="icon-cancel" href="javascript:void(0)" onclick="closeMemberAddressWindow()">取消</a> </div> </div> </div> <!-- 查看會員詳情 --> <div id="memberManagerView" class="easyui-window" title="" iconCls="icon-search" closed="true"></div>
create_order_main.jsjavascript
var appPath = getAppPath(); var _memberId = "";//會員id var _memberCurrentPoints = 0;//會員當前可用積分 var _pointVsMoney = 0;//現金與積分兌換比例參數 $(function(){ $("#checkCouponNoA").show(); $("#checkCouponNoQK").hide(); genMemberGrid(); if($("#memberId1").val()!="" && $("#memberId1").val()!=null){ queryMember2(); } genSkuGrid(); genAddressGrid(); generateAdrr(); genMulChannelComb(); getEcMultiChannelByNo(); //genPaymentTypeComb(); genNumberBox(); $("#vat").click(); $("#deliveryFeeTd").text("0.00");//運費顯示爲0 $("#orderFeeTd").text("0.00");//訂單顯示爲0 $("#orderPoints").val("0"); $("#currentPoints").text("0"); $("#currentMoney").text("0"); //查找現金與積分兌換比例參數 _pointVsMoney = findPointVsMoneyParam(); $("#pointVsMoneySpan").text(_pointVsMoney+":1"); $.extend($.fn.validatebox.defaults.rules, { maxLength: { validator: function(value, param){ return value.length <= param[0]; }, message: '最大{0}字,請確認 ' } }); }); /** * 生成會員Grid */ function genMemberGrid(){ $("#memberGrid").datagrid({ // url:appPath+'/page/createOrder/member/list', height:'160', nowrap: true, striped: true, remoteSort:false, singleSelect:true, idField:'memberId', checkbox:false, frozenColumns:[[ {field:'memberId',title:'操做',width:50,align:'center', formatter:function(value,rowData,rowIndex){ return "<img onclick='toQueryMemberPage("+value+")' width='12px' height='12px' style='border:0px' src='"+appPath+"/js/lib/jquery-easyui/themes/icons/search.png' title='查看會員詳情' />"; } } ]], columns:[[ {field:'realName',title:'會員姓名',width:80,align:'left',sortable:false}, {field:'loginName',title:'會員帳號',width:80,align:'left',sortable:false}, {field:'mobile',title:'手機號碼',width:80,align:'left',sortable:false}, {field:'tel',title:'電話號碼',width:80,align:'left',sortable:false}, {field:'memberRankName',title:'會員等級',width:80,align:'left',sortable:false}, {field:'provinceName',title:'省',width:65,align:'left',sortable:false}, {field:'cityName',title:'市',width:65,align:'left',sortable:false}, {field:'areaName',title:'區/縣',width:65,align:'left',sortable:false}, {field:'paymentLimit',title:'支付方式限制',width:65,align:'left',sortable:false, formatter:function(val){ if(val=="only_KDFH"){ return "只能使用款到發貨進行支付"; }else{ return ""; } }}, {field:'memberState',title:'黑名單',width:65,align:'left',sortable:false, formatter:function(val){ if(val=="black"){ return "已加入黑名單沒法下單"; }else{ return ""; } }} ]], pagination:true, rownumbers:true, pageSize:4, pageList:[4], onLoadSuccess:function(){ $("#memberGrid").datagrid('selectRow','0');//默認選中第1行 }, onSelect:function(rowIndex, rowData){ _memberId = rowData.memberId; _memberCurrentPoints = rowData.currentPoints; $("#op_HDFK").attr("disabled",false); if(rowData.paymentLimit=="only_KDFH"){ $("#op_HDFK").attr("disabled",true); } loadAddressGrid(_memberId); $("#currentPoints").html(_memberCurrentPoints); var currentMoney = Math.round((_memberCurrentPoints/_pointVsMoney)*Math.pow(10,2))/Math.pow(10,2); $("#currentMoney").text(parseInt(currentMoney)); //我的優惠券加載 couponNoXLComb(rowData.memberId); } }); } /** * 生成商品grid */ function genSkuGrid(){ $("#orderItemEditGrid").datagrid({ url:appPath+'/page/order/0/items', height:160, striped: true, remoteSort:false, singleSelect:false, rownumbers:true, idField:'orderItemId', checkbox:true, frozenColumns:[[ {field:'ck',checkbox:true}, {field:'opt',title:'操做',width:32,align:'center', formatter:function(value,rowData,rowIndex){ return "<img class='op-enable' src='"+appPath+"/js/lib/jquery-easyui/themes/icons/pencil.png' onClick='beginEditorData(\""+rowIndex+"\",\""+rowData.goodsType+"\")' title='編輯'/>"; } } ]], columns:[[ {field:'goodsNo',title:'商品編碼',width:100,align:'left',sortable:true}, {field:'goodsName',title:'商品名稱',width:150,align:'left',sortable:true}, {field:'goodsType',title:'商品類型',width:80,align:'left',sortable:true,formatter:function(value){ switch(value){ case "gift": return "贈品"; break; case "group": return "組合商品"; break; default: return "普通商品"; break; } } }, {field:'goodsBiaoshi',title:'商品標識',width:80,align:'left',sortable:true, formatter:function(value){ if(value=="OTC") { return "非處方藥甲類"; }else if(value=="TC") { return "處方藥"; }else if(value=="OTHER") { return "普通商品"; }else if(value=="SG") { return "隱形眼鏡"; }else if(value=="OTCy") { return "非處方藥乙類"; }else if(value=="DF") { return "代發商品"; } } }, {field:'goodsOldPrice',title:'原價',width:80,align:'right',sortable:true,formatter:function(value){if(!isNaN(Number(value))){return Number(value).toFixed(2);}}}, {field:'goodsPrice',title:'成交價',width:60,align:'right',editor:{type:'numberbox',options:{required:true,min:0,precision:2}},sortable:true,formatter:function(value){if(!isNaN(Number(value))){return Number(value).toFixed(2);}}}, {field:'goodsAmount',title:'數量',width:60,align:'right',editor:{type:'numberbox',options:{required:true,min:1,precision:0}},sortable:true, formatter:function(value){ if(!isNaN(Number(value))){ return Number(value).toFixed(2); } } }, {field:'goodStock',title:'庫存',width:60,align:'right',sortable:true,formatter:function(value){if(!isNaN(Number(value))){return Number(value).toFixed(2);}}}, {field:'goodsSumFee',title:'小計金額',width:60,align:'right',editor:{type:'numberbox',options:{required:true,min:0,precision:2,disabled:true}},sortable:true,formatter:function(value){if(!isNaN(Number(value))){return Number(value).toFixed(2);}}}, {field:'weight',title:'重量',hidden:true}, {field:'volume',title:'體積',hidden:true} ]], toolbar:[{ id:'btnadd', text:'添加商品', iconCls:'icon-add', handler:function(){ var exceptGoodsIdString = ""; var rows = $("#orderItemEditGrid").datagrid("getRows"); for(var i=0;i<rows.length;i++){ if(rows[i].goodsType != "gift"){ exceptGoodsIdString = exceptGoodsIdString + rows[i].goodsId +","; } } exceptGoodsIdString = exceptGoodsIdString.substring(0,exceptGoodsIdString.lastIndexOf(",")); var argObj = new Object(); if(exceptGoodsIdString){ argObj.exceptGoodsIdString = exceptGoodsIdString; } showGoodsQueryDialog("","","addGoods",argObj); } }, // 屏蔽添加贈品功能-wangjun // '-',{ // id:'btnaddGift', // text:'添加贈品', // iconCls:'icon-add', // handler:function(){ // var exceptGiftIdString = ""; // var rows = $("#orderItemEditGrid").datagrid("getRows"); // for(var i=0;i<rows.length;i++){ // if(rows[i].goodsType == "gift"){ // exceptGiftIdString = exceptGiftIdString + rows[i].goodsId +","; // } // } // exceptGiftIdString = exceptGiftIdString.substring(0,exceptGiftIdString.lastIndexOf(",")); // var argObj = new Object(); // if(exceptGiftIdString){ // argObj.exceptGiftIdString = exceptGiftIdString; // } // showGiftQueryDialog("","","addGift",argObj); // } // }, '-',{ id:'btndelMu', text:'刪除', iconCls:'icon-cancel', handler:function(){ var selections = $("#orderItemEditGrid").datagrid('getSelections'); if(selections == null || selections == ''){ $.messager.alert('提示信息','請選擇要刪除的數據','info'); return ; } for(var i=0;i<selections.length;i++){ var row = selections[i]; var rowIndex = $("#orderItemEditGrid").datagrid('getRowIndex',row); $("#orderItemEditGrid").datagrid('deleteRow',rowIndex); calcFee(); } } }] }); } /** * 生成收貨地址grid */ function genAddressGrid(){ $("#addressGrid").datagrid({ url:appPath+'/page/createOrder/memberAddress/list', queryParams:{memberId:'0'},//"ec_refrigeration_info"表示新聞類別爲製冷資訊 height:'160', nowrap: true, striped: true, remoteSort:false, singleSelect:true, idField:'memberAddressId', checkbox:false, frozenColumns:[[{field:'ck',checkbox:true}]], columns:[[ {field:'isDefault',title:'默認',width:80,align:'left',sortable:false,formatter:function data(value){ if(value!=""){ if(value=="Y"){ return "是"; }else{ return "否"; } } }}, {field:'consignee',title:'收貨人',width:80,align:'left',sortable:false}, {field:'fullAddress',title:'收貨地址',width:300,align:'left',sortable:false}, {field:'tel',title:'固定電話',width:100,align:'left',sortable:false}, {field:'mobile',title:'手機號碼',width:100,align:'left',sortable:false} ]], pagination:true, rownumbers:true, pageSize:4, pageList:[4], onClickRow:function(){calcFee()}, onLoadSuccess:function(){ $("#addressGrid").datagrid('selectRow','0');//默認選中第1行 } }); } /** * 選擇發票類型radio * @param type */ function changeType(type){ $("#invoiceTable tr[rel^=dny]").remove(); var defContentType = $("#defContentType").val(); switch(type){ case "general": $("#headTr").after($("#general_table").html()); if($("input[type=radio][name=invoiceContentType][value="+defContentType+"]").length > 0){ $("input[type=radio][name=invoiceContentType][value="+defContentType+"]").click(); }else{ $("input[type=radio][name=invoiceContentType]:eq(0)").click(); } break; case "vat": $("#headTr").after($("#vat_table").html()); break; default: break; } } /** * 選擇發票內容類型radio * @param type */ function changeContentType(type){ $("#invoiceTable tr[rel=dny_gen]").remove(); switch(type){ case "private": $("#cHeadTr").after($("#general_personal_table").html()); break; case "company": $("#cHeadTr").after($("#general_company_table").html()); break; default: $("#cHeadTr").siblings().remove(); break; } } /** * 打開註冊新會員窗口 */ function addMemberPage(){ $('#addForm').form('clear'); $('#addMemberDlg').window({ title:'註冊新會員', width:500, height:280, left:100, modal: true, shadow: true, collapsible:false, minimizable:false, maximizable:false }); $('#addMemberDlg').window('move',{top:20}); $('#addMemberDlg').window('open'); } /** * 檢驗會員帳號是否存在 * @returns */ function checkLoginName(){ var data = new Object(); data = {"loginName":$.trim($('#addLoginName').val())}; if(data.loginName==""||data.loginName==null){ $.messager.alert('提示信息','請輸入登陸賬號。','info'); return; } var url = appPath+"/page/createOrder/member/checkLoginName"; var result; doAjax({ url:url, type:'post', async:false, data:data, success:function(data){ if (data == "exist") { $.messager.alert('提示信息','輸入的登陸賬號已存在。','info'); result = false; } else { $.messager.alert('提示信息','恭喜,該登陸賬號能夠註冊。','info'); result = true; } } }); return result; } /** * 保存新會員 */ function addMember(){ if (checkLoginName()==true){ var loginName = $.trim($("#addLoginName").val()); var loginPassword = $.trim($("#addLoginPassword").val()); var confirmPassword = $.trim($("#addConfirmPassword").val()); var realName = $.trim($("#addRealName").val()); var mobile = $.trim($("#addMobile").val()); if(loginName == '') { $.messager.alert('提示信息','請錄入登陸賬號!','info'); return; } if(loginPassword == '') { $.messager.alert('提示信息','請錄入登陸密碼!','info'); return; } if(confirmPassword == '') { $.messager.alert('提示信息','請錄入確認密碼!','info'); return; } if(confirmPassword != loginPassword) { $.messager.alert('提示信息','確認密碼與登陸密碼不一致!','info'); return; } doAjax({ url:appPath+'/page/createOrder/member/add', type:'post', data:{"loginName":loginName, "loginPassword":loginPassword, "realName":realName, "mobile":mobile}, success:function(data){ if(data='ok'){ $.messager.alert('提示信息','註冊成功!','info'); } if(data!='ok'){ $.messager.alert('提示信息','抱歉,新增未能完成,'+data,'error'); } closeAddMemberDlg(); //1、根據手機號碼,查詢出剛添加的記錄,並選中 $("#telphone").val(""); $("#mobile").val(mobile); $("#loginName").val(""); queryMember(); }, error:function(XMLHttpRequest, textStatus, errorThrown){ $.messager.alert('提示信息','抱歉,新增未能完成,'+textStatus,'error'); } }); } } /** * 關閉註冊會員窗口 */ function closeAddMemberDlg(){ $('#addMemberDlg').window('close'); } /** * 查詢會員 */ function queryMember(){ $('#memberGrid').datagrid('options').url = appPath+'/page/createOrder/member/list'; var param = $('#memberGrid').datagrid('options').queryParams; param.mobile = $.trim($('#mobile').val()); param.loginName = $.trim($("#loginName").val()); param.tel = $.trim($("#tel").val()); param.memberId=""; $("#memberGrid").datagrid('unselectAll'); $("#memberGrid").datagrid('load',param); } /** * 查詢會員 */ function queryMember2(){ $('#memberGrid').datagrid('options').url = appPath+'/page/createOrder/member/list'; var param = $('#memberGrid').datagrid('options').queryParams; if($("#memberId1").val()!="" && $("#memberId1").val()!=null){ param.memberId = $.trim($("#memberId1").val()); }else{ param.memberId="0"; } $("#memberGrid").datagrid('unselectAll'); $("#memberGrid").datagrid('load',param); } /** * 從新加載會員Grid */ function reloadMemberGrid(){ //$("#memberGrid").datagrid('unselectAll'); $("#memberGrid").datagrid('reload'); } /** * 根據會員id,查詢收貨地址列表 * @param memberId */ function loadAddressGrid(memberId){ var param = $("#addressGrid").datagrid('options').queryParams; param.memberId = memberId; $("#addressGrid").datagrid('unselectAll'); $("#addressGrid").datagrid('load',param); } /** * 打開收貨地址窗口 */ function addMemmberAddress(){ $('#addMemberAddressForm').form('clear'); $('#addMemberAddressWindow').window({ title:"添加收貨地址", iconCls:'icon-add', modal: true, shadow: true, collapsible:false, minimizable:false, maximizable:false }); $('#addMemberAddressWindow').window('move',{top:300}); $('#addMemberAddressWindow').window('open'); } /** * 生成地址下拉框 */ function generateAdrr(){ var proFn = function(){ if($("#provinceId").combobox("getData").length > 1 && $("#hdProId").val()){ $("#provinceId").combobox("select",$("#hdProId").val()); } }; var cityFn = function(){ if($("#cityId").combobox("getData").length > 1 && $("#hdCityId").val()){ $("#cityId").combobox("select",$("#hdCityId").val()); $("#hdCityId").val(""); } }; var areaFn = function(){ if($("#areaId").combobox("getData").length > 1 && $("#hdAreaId").val()){ $("#areaId").combobox("select",$("#hdAreaId").val()); $("#hdAreaId").val(""); } }; createAreaLinkage("provinceId","cityId","areaId",proFn,cityFn,areaFn); } /** * 保存收貨地址 */ function saveAdd(){ if(!$('#addMemberAddressForm').form('validate')){ return; } var memberId = _memberId; var provinceId = $("#provinceId").combobox("getValue"); var cityId = $("#cityId").combobox("getValue"); var areaId = $("#areaId").combobox("getValue"); var address = $("#fullAddress").val(); var mobile = $("#receiveMobile").val(); var tel = $("#receiveTel").val(); var post = $("#receivePost").val(); var consignee = $("#receiveUser").val(); if(provinceId==null||provinceId==""){ $.messager.alert('提示信息','請選擇省份!','info'); return; } if(cityId==null||cityId==""){ $.messager.alert('提示信息','請選擇市!','info'); return; } if(areaId==null||areaId==""){ $.messager.alert('提示信息','請選擇區縣!','info'); return; } var memberAddress = {memberId:memberId,provinceId:provinceId,cityId:cityId,areaId:areaId,address:address,mobile:mobile,tel:tel,post:post,consignee:consignee}; if(memberId==""||memberId==null){ $.messager.alert('提示信息','請先選擇會員,再添加收貨地址!','info'); return; } doAjax({ url:appPath+'/page/createOrder/memberAddr/add', type:'post', data:memberAddress, success:function(data){ if(data='ok'){ $.messager.alert('提示信息','新增成功!','info'); } if(data!='ok'){ $.messager.alert('提示信息','抱歉,新增未能完成,'+data,'error'); } closeMemberAddressWindow(); loadAddressGrid(memberId); }, error:function(XMLHttpRequest, textStatus, errorThrown){ $.messager.alert('提示信息','抱歉,新增未能完成,'+textStatus,'error'); } }); } /** * 關閉新增收貨地址窗口 */ function closeMemberAddressWindow(){ $('#addMemberAddressWindow').window('close'); } /** * 生成多渠道combox */ function genMulChannelComb(){ $("#multiChannelId").combobox({ url:appPath+"/page/createOrder/mulChannel/combox", valueField:"id", textField:"text", panelHeight:"auto", editable:false }); } /** * 生成支付方式combox */ function genPaymentTypeComb(){ doAjax({ url:appPath+'/page/createOrder/paymentType/combox', type:'post', data:"", async:false, success:function(data){ var options=""; for(var i=0;i<data.length;i++){ options = options + "<option value='"+data[i].paymentTypeId+"'>"+data[i].paymentTypeName+"</option>"; } $("#paymentTypeId").html(options); }, error:function(XMLHttpRequest, textStatus, errorThrown){ $.messager.alert('提示信息','系統錯誤,請與管理員聯繫!','error'); } }); } /** * 訂單來源默認選中呼叫中心 */ function getEcMultiChannelByNo(){ doAjax({ url:appPath+'/page/createOrder/mulChannel/getByNo', type:'post', data:"", async:false, success:function(data){ var multiChannelId = data;//呼叫中心對應的multiChannelId $("#multiChannelId").combobox("setValue",multiChannelId); }, error:function(XMLHttpRequest, textStatus, errorThrown){ $.messager.alert('提示信息','系統錯誤,請與管理員聯繫!','error'); } }); } /** * 添加貨品(關閉貨品查詢公共窗口後回調方法) * @param {} goodsDatas */ function addGoods(goodsDatas){ if(!goodsDatas){ return ; } for(var i=0;i<goodsDatas.length;i++){ var goods = goodsDatas[i]; var goodsObj = new Object(); // goodsObj.orderItemId =""; goodsObj.goodsId = goods.goodsId; goodsObj.goodsType = "general"; goodsObj.goodsNo = goods.goodsNo; goodsObj.goodsName = goods.goodsName; goodsObj.goodsBiaoshi = goods.goodsBiaoshi; goodsObj.goodsOldPrice = Number(goods.ecPrice).toFixed(2); goodsObj.goodsPrice = Number(goods.ecPrice).toFixed(2); goodsObj.goodStock = Number(goods.availableStock).toFixed(2); goodsObj.goodsAmount = 1; goodsObj.goodsSumFee = Number(goods.ecPrice).toFixed(2); goodsObj.weight = Number(goods.weight).toFixed(2); goodsObj.volume = Number(goods.volume).toFixed(2); $("#orderItemEditGrid").datagrid("appendRow",goodsObj); } var lastIndex = $('#orderItemEditGrid').datagrid('getRows').length-1; beginEditorData(lastIndex,"general"); $("#orderItemEditGrid").datagrid("getEditor",{index:lastIndex,field:'goodsAmount'}).target.blur(); } /** * 添加贈品(關閉贈品查詢公共窗口後回調方法) * @param {} giftDatas */ function addGift(giftDatas){ if(!giftDatas){ return ; } for(var i=0;i<giftDatas.length;i++){ var gift = giftDatas[i]; var giftObj = new Object(); // giftObj.orderItemId = "newOrderItem_"+(new Date()).getTime(); giftObj.goodsId = gift.giftId; giftObj.goodsType = "gift"; giftObj.goodsNo = gift.giftNo; giftObj.goodsName = gift.giftName; giftObj.goodsOldPrice = Number(gift.giftPrice).toFixed(2); giftObj.goodsPrice = 0; giftObj.goodStock = Number(gift.giftStock).toFixed(2); giftObj.goodsAmount = 1; giftObj.goodsSumFee = 0; giftObj.weight = 0; giftObj.volume = 0; $("#orderItemEditGrid").datagrid("appendRow",giftObj); var lastIndex = $('#orderItemEditGrid').datagrid('getRows').length-1; beginEditorData(lastIndex,"gift"); $("#orderItemEditGrid").datagrid("getEditor",{index:lastIndex,field:'goodsAmount'}).target.blur(); } } /** * 貨品grid,開始編輯,而且綁定事件 * @param {} rowIndex */ function beginEditorData(rowIndex,goodsType){ $("#orderItemEditGrid").datagrid('beginEdit',rowIndex); var priceEditor = $("#orderItemEditGrid").datagrid("getEditor",{index:rowIndex,field:'goodsPrice'}); var amountEditor = $("#orderItemEditGrid").datagrid("getEditor",{index:rowIndex,field:'goodsAmount'}); // #11198 有改價權限時,能夠修改爲交價 if (!checkUserButtonRight2('edit_cost_price_create',false) || goodsType == "gift"){ priceEditor.target.attr("disabled","disabled"); } else{ priceEditor.target.removeAttr("disabled"); } priceEditor.target.attr("editIndex",rowIndex); priceEditor.target.blur(function(){sumFee(this);}); amountEditor.target.attr("editIndex",rowIndex); amountEditor.target.blur(function(){sumFee(this);}); } /** * 貨品grid,計算金額,退出編輯 */ function sumFee(dom){ var editIndex = $(dom).attr("editIndex"); var priceEditor = $("#orderItemEditGrid").datagrid("getEditor",{index:editIndex,field:"goodsPrice"}); var amountEditor = $("#orderItemEditGrid").datagrid("getEditor",{index:editIndex,field:"goodsAmount"}); var feeEditor = $("#orderItemEditGrid").datagrid("getEditor",{index:editIndex,field:"goodsSumFee"}); var price = priceEditor.actions.getValue(priceEditor.target); var amount = amountEditor.actions.getValue(amountEditor.target); amount = Number(amount); if(isNaN(amount)){ return ; } price = Number(price); if(isNaN(price)){ return ; } var allRows = $("#orderItemEditGrid").datagrid("getRows"); //計算Grid中當前編輯記錄中「小計金額」 var sumFee = Math.round((price*amount)*Math.pow(10,2))/Math.pow(10,2); feeEditor.actions.setValue(feeEditor.target,sumFee); $("#orderItemEditGrid").datagrid("endEdit",editIndex); calcFee(); } /*檢查用戶是否爲黑名單*/ function checkIsBlack(memberId){ var flag = true; doAjax({ url:appPath + "/page/member/checkIsBlack", type:"post", async : false, data:{ "memberId":memberId }, success:function(data){ if(data.memberState=="black"){ flag = false; } } }); return flag; } /** * 保存訂單, */ function doCreateOrder(){ var submitObj = new Object(); var calcParam = new Object(); //訂單來源提交數據 submitObj.multiChannelId = $("#multiChannelId").combobox("getValue"); if(submitObj.multiChannelId==null){ $('body,html').scrollTop(0); $.messager.alert('提示',"請選擇訂單來源!",'info'); return; } //會員提交數據 var memberRecord = $("#memberGrid").datagrid("getSelected"); //#13492 bug 修復 if (!checkUserButtonRight2('commit_order_hfl',false) && !(/^((?!hfl).)*$/.test(memberRecord.loginName)) ) { $.messager.alert('提示',"會員名包含hfl的用戶暫時不支持後臺下單!",'info'); return ; } if(memberRecord==null){ $('body,html').scrollTop(0); $.messager.alert('提示',"請選擇會員!",'info'); return; } /*判斷是不是黑名單*/ if(!checkIsBlack(memberRecord.memberId)){ $.messager.alert('提示',"對不起,您的帳號暫時沒法下單,謝謝!"); return; } submitObj.memberId = memberRecord.memberId; submitObj.loginName = memberRecord.loginName; //貨品和贈品提交數據 var changedArray = []; var insertRows = $("#orderItemEditGrid").datagrid("getChanges","inserted"); var insertLength = insertRows.length; if(insertLength > 0){ for(var i=0;i<insertLength;i++){ insertRows[i].orderItemId = null; } $.merge(changedArray,insertRows); } if(changedArray.length > 0){ submitObj.items = JSON.stringify(changedArray); }else{ $('body,html').scrollTop(0); $.messager.alert('提示',"請選擇商品!",'info'); return; } //收貨地址提交數據 var addressRecord = $("#addressGrid").datagrid("getSelected"); if(addressRecord==null){ $('body,html').scrollTop(0); $.messager.alert('提示',"請選擇收貨地址!",'info'); return; } submitObj.memberAddressId = addressRecord.memberAddressId; //地址ID submitObj.receiveUser = addressRecord.consignee; submitObj.provinceId = addressRecord.provinceId; submitObj.cityId = addressRecord.cityId; submitObj.areaId = addressRecord.areaId; submitObj.receiveAddress = addressRecord.address; submitObj.receiveFullAddress = addressRecord.fullAddress2; if(addressRecord.post==null){ submitObj.receivePost = ""; }else{ submitObj.receivePost = addressRecord.post; } submitObj.receiveTel = addressRecord.tel2; submitObj.receiveMobile = addressRecord.mobile2; submitObj.receiveEmail = addressRecord.email; //發票信息提交數據 var invioceObj = $("#editInvoiceForm").serializeObject(); $.extend(submitObj,invioceObj); //配送和支付提交數據 //submitObj.receiveDateType = $("#receiveDateType").val(); //submitObj.receiveTimeType = $("#receiveTimeType").val(); submitObj.paymentMode = $("#paymentMode").val(); //submitObj.paymentTypeId = $("#paymentTypeId").val(); submitObj.orderPoints =$("#orderPoints").val(); // if(submitObj.receiveDateType==null||submitObj.receiveDateType==""){ // $('body,html').scrollTop(0); // $.messager.alert('提示',"請選擇配送日期!",'info'); // return; // } // if(submitObj.receiveTimeType==null||submitObj.receiveTimeType==""){ // $('body,html').scrollTop(0); // $.messager.alert('提示',"請選擇配送時間!",'info'); // return; // } if(submitObj.paymentMode==null||submitObj.paymentMode==""){ $.messager.alert('提示',"請選擇支付類型!",'info'); return; } submitObj.orderPoints =$("#orderPoints").val(); if(submitObj.orderPoints==null||submitObj.orderPoints==""){ submitObj.orderPoints =0; } if(submitObj.orderPoints>_memberCurrentPoints){ $('body,html').scrollTop(0); $.messager.alert('提示',"所輸入的積分數不能大於該會員的可用積分數!",'info'); return; } //結算信息提交數據,計算運費、貨品總重、貨款金額、優惠後金額、訂單金額 $.extend(submitObj,calcFee()); if(submitObj.orderFee<=0){ $.messager.alert('提示',"訂單金額不能小於0",'info'); return; } if(submitObj.orderFee<submitObj.deliveryFee){ $.messager.alert('提示',"訂單金額不能小於運費",'info'); return; } submitObj.urlFromNo=$("#addUrlFromNo").val(); if($("#couponNoFee").val()>0){ var str=$('input:radio[name="couponNoChoose"]:checked').val(); //判斷是選擇輸入框仍是下拉框 if(str=="SRK"){ submitObj.couponNo=$("#couponNo").val(); //優惠券號碼 }else if(str=="XL"){ submitObj.couponNo=$("#couponNoXL").val(); //優惠券號碼 } } //銷售下單帳號積分使用判斷 if(submitObj.orderPoints>0 && "jy"==submitObj.loginName){ $('body,html').scrollTop(0); $.messager.alert('提示',"jy帳號不能使用積分!",'info'); return; } $('body,html').scrollTop(0); $.messager.confirm('提示信息','您肯定提交訂單嗎?',function(r){ if(r){ doAjax({ url:appPath + "/page/createOrderConnector/orderInfo/save", type:"post", data:submitObj, success:function(data){ var code = data.code; switch(code){ case 0: $.messager.alert('提示',data.msg,'info'); break; case 1: $.messager.alert("下單成功!","訂單號爲:"+data.msg,'info'); break; case 2: $.messager.alert('提示',data.msg,'info'); break; case 3: $.messager.alert('提示',data.msg,'info'); break; default: $.messager.alert('提示',data,'info'); break; } }, error:function(XMLHttpRequest, textStatus, errorThrown){ $.messager.alert('提示信息','訂單提交失敗!,'+textStatus,'error'); } }); } }); } /** * 關閉貨品Grid的編輯功能 */ function endEdit(){ var allRows = $("#orderItemEditGrid").datagrid("getRows"); for (var i=0;i<allRows.length;i++){ $("#orderItemEditGrid").datagrid("endEdit",i); } } /** * 計算運費、貨品總重、貨款金額、優惠後金額、訂單金額 */ function calcFee(){ //積分必須是_pointVsMoney的倍數 if(parseInt($("#orderPoints").val())%_pointVsMoney>0){ $.messager.alert('提示',"積分必須是"+_pointVsMoney+"的倍數",'info'); return; } var calcParam = new Object(); //關閉貨品Grid的編輯功能 //endEdit(); //收貨地址提交數據 var addressRecord = $("#addressGrid").datagrid("getSelected"); if(addressRecord!=null){ calcParam.provinceId = addressRecord.provinceId; calcParam.cityId = addressRecord.cityId; calcParam.areaId = addressRecord.areaId; } var feeObject = new Object(); var orderSkuWeights = 0;//貨品總重 var orderSkuVolume = 0;//貨品整體積 var orderDeliveryFee = 0;//運費 var orderSkuFee = 0;//貨款金額 var orderDiscountFee = 0;//優惠後金額 var orderFee = 0;//訂單金額 var orderPointsMoney=0;//積分兌換後的現金值 var orderPoints = $("#orderPoints").val(); var otherDiscounts = 0;//其餘優惠 var orderVouchers = 0;//使用代金劵 var discountFee = 0;//手工優惠 var couponNoFee=$("#couponNoFee").val(); //優惠券優惠金額 //檢查現金與積分兌換比例參數是否設置 if(_pointVsMoney==""||_pointVsMoney==null){ $('body,html').scrollTop(0); $.messager.alert('提示',"現金與積分兌換比例參數未設置!",'info'); return; } //計算現金與積分兌換後的值 if(_memberCurrentPoints>0&&orderPoints>0&&_pointVsMoney!=0){ orderPointsMoney = Math.round((orderPoints/_pointVsMoney)*Math.pow(10,2))/Math.pow(10,2); } var allRows = $("#orderItemEditGrid").datagrid("getRows"); for (var i=0;i<allRows.length;i++){ var goodsOldPrice = Number(allRows[i].goodsOldPrice); var goodsPrice = Number(allRows[i].goodsPrice); var goodsAmount = Number(allRows[i].goodsAmount); var weight = Number(allRows[i].weight); var volume = Number(allRows[i].volume); var sumPrice = Number(allRows[i].goodsSumFee); var sumOldPrice = Math.round((goodsOldPrice*goodsAmount)*Math.pow(10,2))/Math.pow(10,2); orderSkuWeights += weight; orderSkuVolume += volume; orderSkuFee += sumOldPrice; orderDiscountFee += sumPrice; } calcParam.skuFee = orderDiscountFee; calcParam.skuWeights = orderSkuWeights; calcParam.skuVolume = orderSkuVolume; var temp=""; // if(addressRecord!=null&&(orderSkuWeights!=0||orderSkuVolume!=0)){ // //計算運費 // temp = calcDeliveryFee(calcParam); // } // if(temp=="-1"){ // $.messager.alert('提示',"運費規則未設置!",'info'); // return; // }else if(temp!=""&&temp!="-1"){ // orderDeliveryFee = temp; // } // orderFee =(orderDiscountFee + orderDeliveryFee) - orderPointsMoney - otherDiscounts - orderVouchers - discountFee; //積分的錢丟棄小數,取整 orderFee =((orderDiscountFee + orderDeliveryFee) - parseInt(orderPointsMoney) - otherDiscounts - orderVouchers - discountFee)-couponNoFee; feeObject.skuWeights = orderSkuWeights; feeObject.skuVolume = orderSkuVolume; feeObject.deliveryFee = orderDeliveryFee; feeObject.skuFee = orderDiscountFee;//新需求,貨款金額取修改後金額orderDiscountFee feeObject.orderFee = orderFee; // feeObject.orderPoints = orderPointsMoney;//積分兌換後的金額 feeObject.otherDiscounts = otherDiscounts; feeObject.orderVouchers = orderVouchers; feeObject.discountFee = discountFee; feeObject.orderPayFee = orderFee; $("#deliveryFeeTd").text(orderDeliveryFee.toFixed(2)); if(orderDiscountFee-(parseInt(couponNoFee)+parseInt(orderPointsMoney))<=0){ orderFee=orderDeliveryFee; //優惠券不能抵消運費 } $("#orderFeeTd").text(orderFee.toFixed(2)); return feeObject; } /** * 生成積分數字框 */ function genNumberBox(){ $("#orderPoints").numberbox({ min:0, precision:0, max:9999999 }); } /** * 取消下單 */ function closeTab(){ parent.closeNewOrderTab(); } /** * 提交訂單成功,打開新頁籤 */ function submitOrderOk(orderId,loginName,orderFee){ document.domain = 'j1.com'; parent.addTab("訂單提交成功",appPath+"/page/createOrder/orderInfo/submitOk?orderId="+orderId+"&loginName="+encodeURI(encodeURI(loginName))+"&orderFee="+orderFee,"icon icon-auditPass",true,"submitOrderOk_iframe"); document.domain = null; } /** * 查找現金與積分兌換比例 */ function findPointVsMoneyParam(){ var pointVsMoney=""; doAjax({ url:appPath+'/page/createOrder/ecParam/findPointVsMoneyParam', type:'post', data:"", async:false, success:function(ecParams){ if(ecParams!=null&&ecParams!=""){ pointVsMoney = ecParams.pointVsMoney; } }, error:function(XMLHttpRequest, textStatus, errorThrown){ $.messager.alert('提示信息','系統錯誤,請與管理員聯繫!','error'); } }); return pointVsMoney; } /** * 查看會員詳情 * @param memberId */ function toQueryMemberPage(memberId) { var data = new Object(); data = {"memberId":memberId}; var id = "memberManagerView"; var url = appPath+"/page/member/detail"; doAjax({ url:url, type:'post', data:data, success:function(data){ $("#"+id).empty().html(data); $("#"+id).window({ title:'查看會員詳細信息', width:700, height:450, left:100, modal: true, shadow: true, collapsible:false, minimizable:false, maximizable:false }); $("#"+id).window('move',{top:0}); $("#"+id).window('open'); } }); } /** * 計算運費 * @param submitObj * @returns {String} */ function calcDeliveryFee(calcParam){ var orderInfo = new Object(); orderInfo.provinceId = calcParam.provinceId; orderInfo.cityId = calcParam.cityId; orderInfo.areaId = calcParam.areaId; orderInfo.skuFee = calcParam.skuFee; orderInfo.skuWeights = calcParam.skuWeights; orderInfo.skuVolume = calcParam.skuVolume; orderInfo.paymentMode = $("#paymentMode").val(); var orderDeliveryFee=""; doAjax({ url:appPath+'/page/getDeliveryFee', type:'post', data:orderInfo, async:false, success:function(data){ if(data!=null&&data!=""){ orderDeliveryFee = data; } }, error:function(XMLHttpRequest, textStatus, errorThrown){ $.messager.alert('提示信息','系統錯誤,請與管理員聯繫!','error'); } }); return orderDeliveryFee; } function showImportDialog(){ if(!$("#memberGrid").datagrid("getSelected")){ $.messager.alert('提示信息','請先選擇會員!','info'); return ; } var isOpen = false; //訪問一次服務器,檢測是否登陸失效,若是失效,就不打開子窗口,防止在子窗口中打開登陸頁面 doAjax({ async:false, url:appPath+'/page/system/checkOpenCommonPage', success:function(data,textStatus,jqXHR){ if(data && data == "ok"){ isOpen = true; } }, error:function(XMLHttpRequest, textStatus, errorThrown){ } }); if(!isOpen){ return ; } var isChrome = navigator.userAgent.toLowerCase().match(/chrome/) != null; if (isChrome) { var args1 = "height=510," + "width=850," + "toolbar =no," + "top =150," + "left =250," + "menubar=no," + "scrollbars=no," + "resizable=no," + "location=no," + "status=no"; window.open(appPath+"/jsp/order/order_import.jsp","",args1); }else{ var args = "dialogHeight:510px;"+ "dialogWidth:850px;"+ "center:true;"+ "help:no;"+ "status:no;"+ "location:no;"+ "dialogLeft:200px;"+ "dialogTop:170px;"+ "resizable:yes;"; var obj = new Object(); var member = $("#memberGrid").datagrid("getSelected"); obj.memberId = member.memberId; obj.realName = member.realName; obj.loginName = member.loginName; window.showModalDialog(appPath+"/jsp/order/order_import.jsp",obj,args); } } /** * 我的查詢可用優惠劵 */ function couponNoXLComb(memberId){ doAjax({ url:appPath+"/page/createOrderConnector/memberCouponNoList?memberId="+memberId, type:'post', async:false, success:function(data){ if(data.length>0){ $("#couponNoXL").empty(); for(var i=0;i<data.length;i++){ $("#couponNoXL").append( "<option value='"+data[i].id+"'>"+data[i].text+"</option>" ); } } }, }); } /** * 驗證優惠券(肯定按鈕,減金額) */ function checkCouponNo(){ var orderInfo=new Object(); //貨品和贈品提交數據 var changedArray = []; var insertRows = $("#orderItemEditGrid").datagrid("getChanges","inserted"); var insertLength = insertRows.length; if(insertLength > 0){ for(var i=0;i<insertLength;i++){ insertRows[i].orderItemId = null; } $.merge(changedArray,insertRows); } if(changedArray.length > 0){ orderInfo.items = JSON.stringify(changedArray); }else{ $('body,html').scrollTop(0); $.messager.alert('提示',"請選擇商品!",'info'); return; } //會員提交數據 var memberRecord = $("#memberGrid").datagrid("getSelected"); if(memberRecord==null){ $('body,html').scrollTop(0); $.messager.alert('提示',"請選擇會員!",'info'); return; } var str=$('input:radio[name="couponNoChoose"]:checked').val(); //判斷是選擇輸入框仍是下拉框 //優惠券號 if(str=="SRK"){ if($("#couponNo").val()==null||$("#couponNo").val()==""){ $.messager.alert('提示',"請輸入優惠券號",'info'); return; } if(checkNumberOrStr($("#couponNo").val())==false){ $.messager.alert('提示',"優惠券號只能爲字母、數字",'info'); return; } orderInfo.couponNo=$("#couponNo").val(); }else if(str=="XL"){ if($("#couponNoXL").val()=="請選擇"||$("#couponNoXL").val()==null||$("#couponNoXL").val()==""){ $.messager.alert('提示',"請使用帳號中優惠券",'info'); return; } orderInfo.couponNo=$("#couponNoXL").val(); } orderInfo.memberId = memberRecord.memberId; doAjax({ url:appPath+'/page/createOrderConnector/order/checkVoucher', type:'post', data:orderInfo, async:false, success:function(data){ if(data.status=="NORMAL"){ //扣金額,灰按鈕 if(data.result.result!="ok"){ $("#couponNoFee").val(""); //優惠券金額清空 if(str=="SRK"){ $("#couponNo").val(""); //優惠券號碼清空 }else if(str=="XL"){ //我的優惠券加載 couponNoXLComb(_memberId); } $.messager.alert('提示信息',data.result.resultStr,'info'); return; }else{ //賦值優惠券金額 $("#couponNoFee").val(data.result.ecCoupons.discountFee); //從新計算訂單金額(金額進行加) calcFee(); $("#checkCouponNoA").hide(); $("#checkCouponNoQK").show(); $("#couponNo").attr("readonly",true); } } $.messager.alert('提示信息',data.message,'info'); }, }); } /** * 優惠券清空(加金額) */ function checkCouponNoQK(){ var str=$('input:radio[name="couponNoChoose"]:checked').val(); //判斷是選擇輸入框仍是下拉框 $("#checkCouponNoA").show(); $("#checkCouponNoQK").hide(); $("#couponNoFee").val(""); //清空優惠券優惠金額,訂單金額進行從新計算 $("#couponNo").attr("readonly",false); if(str=="SRK"){ $("#couponNo").val(""); //優惠券號碼清空 }else if(str=="XL"){ //我的優惠券加載 couponNoXLComb(_memberId); //下拉框重置 } //從新計算訂單金額(金額進行減) calcFee(); }