<%@ page title="" language="C#" masterpagefile="~/Member/MyShopMasterPage.master" autoeventwireup="true" inherits="Member_test2, WebApp_deploy" %>

<asp:Content ID="Content1" ContentPlaceHolderID="CPHead" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:TextBox ID="txtId" runat="server"></asp:TextBox>
    <table>
    <tr>
    <td colspan='3'></td>
    </tr>
    </table>
    <div id="selectDeliver">
    </div>
    <asp:HiddenField ID="hfProductID" runat="server" />
    <input type="button" id="btnSelectProduct" onclick="SelectProduct()" value="选择商品" />&nbsp;&nbsp;
    <script type="text/javascript">

        //选择商品
        function SelectProduct() {
            var ctlName = document.getElementById("<%=hfProductID.ClientID %>");
            var arr = showModalDialog('/Member/ProductManage.aspx?ProductType=0&DefaultValue=' + ctlName.value, '', 'dialogWidth:800px; dialogHeight:650px; help: no; scroll: yes; status: no');
            if (arr != null) {
                ctlName.value = arr; //商品ID
                window.location.href = "test2.aspx?ProductIDS=" + arr;
                // GetProductByProductids(arr);<a href="../test2.aspx">../test2.aspx</a>
            }
        }     
    </script>
    <script type="text/javascript">

        var delivercharge = "deliverTypeID#111$deliverName#平邮$arriveArea#$defaultPrice#0.5$deincrementPrice#0.05" +
"$|deliverTypeID#111$deliverName#平邮$arriveArea#福建,广东,广西,海南$defaultPrice#0.3" +
"$deincrementPrice#0.03$|deliverTypeID#111$deliverName#其它快递$arriveArea#$defaultPrice#0.2" +
"$deincrementPrice#0.02$|deliverTypeID#111$deliverName#邮政快递$arriveArea#$defaultPrice#0.1" +
"$deincrementPrice#0.01$";

        if (delivercharge.length > 0) {
            var obj = "<select name='sel'>";
            var de_position = delivercharge.indexOf('|');
            //判断是否存在"|"符号
            if (de_position > 0) {
                var temparray = delivercharge.split('|');
                for (var de_index1 = 0; de_index1 < temparray.length; de_index1++) {
                    var optionValue = temparray[de_index1]; //Value值
                    var optionText = ""; //Text值
                    var deliverName = "";
                    var arriveArea = "";
                    var defaultPrice = 0;
                    var deincrementPrice = 0;

                    var tempArrayOption = optionValue.split('$');
                    for (var de_index2 = 0; de_index2 < tempArrayOption.length; de_index2++) {
                        var tempArrayValue = tempArrayOption[de_index2];
                        var optionText = "";
                        var de_position2 = tempArrayValue.indexOf('#');
                        var de_lenght = tempArrayValue.length;
                        if (de_index2 > 0) {
                            var firstText = tempArrayValue.substring(0, de_position2);
                            var begin = parseInt(de_position2) + 1;
                            var end = parseInt(de_lenght);
                            var secondText = tempArrayValue.substring(begin, end);
                            // alert("firstText:" + firstText); alert("secondText:" + secondText);
                            if (firstText == "deliverName") {
                                deliverName = secondText;
                            }
                            if (firstText == "arriveArea") {
                                arriveArea = secondText;
                            }
                            if (firstText == "defaultPrice") {
                                defaultPrice = secondText;
                            }
                            if (firstText == "deincrementPrice") {
                                deincrementPrice = secondText;
                            }
                        }
                    }
                    optionText = deliverName + " " + defaultPrice + " 元每加一件加" + deincrementPrice + "元 至" + arriveArea;
                    obj += "<option value='" + optionValue + "'>" + optionText + "</option>";
                }
            } else {
                var optionValue = delivercharge; //Value值
                var optionText = ""; //Text值
                var deliverName = "";
                var arriveArea = "";
                var defaultPrice = 0;
                var deincrementPrice = 0;

                var tempArrayOption = optionValue.split('$');
                for (var de_index2 = 0; de_index2 < tempArrayOption.length; de_index2++) {
                    var tempArrayValue = tempArrayOption[de_index2];
                    var optionText = "";
                    var de_position2 = tempArrayValue.indexOf('#');
                    var de_lenght = tempArrayValue.length;
                    if (de_index2 > 0) {
                        var firstText = tempArrayValue.substring(0, de_position2);
                        var begin = parseInt(de_position2) + 1;
                        var end = parseInt(de_lenght);
                        var secondText = tempArrayValue.substring(begin, end);
                        // alert("firstText:" + firstText); alert("secondText:" + secondText);
                        if (firstText == "deliverName") {
                            deliverName = secondText;
                        }
                        if (firstText == "arriveArea") {
                            arriveArea = secondText;
                        }
                        if (firstText == "defaultPrice") {
                            defaultPrice = secondText;
                        }
                        if (firstText == "deincrementPrice") {
                            deincrementPrice = secondText;
                        }
                    }
                }
                optionText = deliverName + " " + defaultPrice + " 元每加一件加" + deincrementPrice + "元 至" + arriveArea;
                obj += "<option value='" + optionValue + "'>" + optionText + "</option>";
            }
            obj += "</select>";
            document.getElementById("selectDeliver").innerHTML = obj;
        }       
    </script>
</asp:Content>
