NGToolsCSharp/NGTools/obj/Release/Package/PackageTmp/Pages/Z_System/buy.aspx

417 lines
17 KiB
Plaintext
Raw Normal View History

2024-09-13 08:44:13 +00:00
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="buy.aspx.cs" Inherits="NGTools.Pages.Z_System.buy" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>功能管理</title>
<link rel="stylesheet" type="text/css" href="../../Scripts/EASYUI/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="../../Scripts/EASYUI/themes/icon.css" />
<!--2个js文件 ,要先引入jquery,然后再引入easyui-->
<script src="../../Scripts/EASYUI/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../Scripts/EASYUI/jquery.easyui.min.js"></script>
<script src="../../Scripts/EASYUI/locale/easyui-lang-zh_CN.js"></script>
<script src="../../MYJS/constant.js"></script>
<script src="../../MYJS/MyTools.js"></script>
</head>
<body class="easyui-layout">
<div id="AllMenu"data-options="region:'west'" class="easyui-panel" title="请选择要购买的功能模块" style="width: 600px; text-align: right">
<input id="MDALL" type="checkbox" onclick="buyAll(this.checked)" /><a>全站买断</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true" onclick="getBuy()">确定购买勾选功能</a>
<form id="systemMenu" class="easyui-panel" title="">
</form>
</div>
<div id="selectMenu"data-options="region:'center', split:true" title="订单信息">
<div>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="saveGN()">提交订单</a>
</div>
<div>
<a class="easyui-lable">购买人:</a> <a id="buyer" class="easyui-lable"><%=Session["userName"] %></a>
<a class="easyui-lable">联系电话:</a>
<input type="text" id="phoneNo" class="easyui-textbox" required="required" />
<a class="easyui-lable">订单号:</a> <a id="orderNo" class="easyui-lable"></a>
</div>
<div id="menuSelected" class="easyui-panel" title="">
</div>
<div id="Result" class="easyui-panel" title="已购买订单" style="width: 900px; height: 150px; padding: 5px;" data-options="collapsible:true">
<table id="dg" style="width: 900px; height: auto" data-options="
singleSelect:true">
<thead>
<tr>
</tr>
</thead>
</table>
</div>
</div>
<div id="tb" style="height: auto; display: none">
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true" onclick="pay()">付款</a>
<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true" onclick="confirm()">确认订单</a>
</div>
</body>
<script>
var AllMenu;
var arrayMenuID = new Array();
var arrayMenuName = new Array();
var arraySelectMenuName = new Array();
var arraySelectMenuID = new Array();
var buyType = new Array();
var buyNum = new Array();
var buyDJ = new Array();
var buyhjJG = new Array();
var buyMDDj = new Array();
var buyCSDj = new Array();
var buyBNDj = new Array();
var blbuyAll = false;
var endDate = new Array();
var totalJG = 0;
$(function () {
//alert(11);
var hh = sessionStorage.getItem("AllMenu");//获取键为allJson的字符串
//alert(hh);
//alert(11);
AllMenu = JSON.parse(hh);//将字符串抓换成对象
getAllMenu();
$('#phoneNo').textbox('setValue', '<%= Session["phoneNo"]%>');
//从数据库中调取已购买的功能
});
function buyAll(blchecked) {
if (blchecked) {
blbuyAll = true;
}
else {
blbuyAll = false;
}
}
//点击功能时触发
function btnbuy(value, name) {
var QNo = 0;
for (var i = 0; i < arrayMenuID.length; i++) {
if (arrayMenuID[i] == name) {
QNo = i;
break;
}
}
var numBox = ("num" + name);
switch (value) {
case "MD":
buyDJ[QNo] = buyMDDj[QNo];
buyType[QNo] = "无限制";
buyNum[QNo] = 1;
buyhjJG[QNo] = parseInt(buyDJ[QNo]) * parseInt(buyNum[QNo]);
break;
case "CS":
buyDJ[QNo] = buyCSDj[QNo];
buyType[QNo] = "买次数";
document.getElementById("numNameID" + name).innerText = "次";
buyNum[QNo] = $('#' + numBox).val();
buyhjJG[QNo] = parseInt(buyDJ[QNo]) * parseInt(buyNum[QNo]);
break;
case "BN":
//var date = new Date().format({ });
//var date = new Date().format({ value: 'date' });
buyDJ[QNo] = buyBNDj[QNo];
buyType[QNo] = "包月";
document.getElementById("numNameID" + name).innerHTML = "月";
buyNum[QNo] = $('#' + numBox).val();
buyhjJG[QNo] = parseInt(buyDJ[QNo]) * parseInt(buyNum[QNo]);
var date = dateToString(new Date(), DateFormart.DATETIME_HORIZONTAL_24);
//alert(date);
//alert(addMonths(date, buyNum[QNo]));
endDate[QNo] = addMonth(date, buyNum[QNo]);
//alert(endDate[QNo]);
break;
default:
}
//alert(buyDJ.join(','));
//alert(buyType.join(','));
}
function btnSelect(value, name, blchecked) {
var QNo = 0;
for (var i = 0; i < arrayMenuID.length; i++) {
if (arrayMenuID[i] == value) {
QNo = i;
break;
}
}
if (buyType[QNo] == "") {
$.messager.alert("提示", "没有选择购买类型!");
return;
}
//alert($('#'+numBox).val());
if (blchecked) {
var numBox = ("num" + value);
arraySelectMenuName[QNo] = name;
arraySelectMenuID[QNo] = value;
}
else {
arraySelectMenuName[QNo] = "";
arraySelectMenuID[QNo] = "";
}
}
function saveGN() {
var strGN = "";
var strGNName = "";
var strEndDate = "";
var strBuyType = "";
var strBuyNum = "";
if (blbuyAll) {
strGN = arrayMenuID.join('_');
strGNName = arrayMenuName.join('_');
strBuyType = buyType.join('_');
strEndDate = "2199-12-31";
}
else {
for (var i = 0; i < arraySelectMenuID.length; i++) {
if (arraySelectMenuID[i] != "") {
strGN += arraySelectMenuID[i] + "_";
strGNName += arraySelectMenuName[i] + "_";
strEndDate += endDate[i] + "_";
strBuyType += buyType[i] + "_";
//if (buyType[i] == "买次数") {
strBuyNum += buyNum[i] + "_";
//}
//else {
// strBuyNum += "_";
//}
}
}
strGN = strGN.substring(0, strGN.length - 1);
strGNName = strGNName.substring(0, strGNName.length - 1);
strEndDate = strEndDate.substring(0, strEndDate.length - 1);
strBuyType = strBuyType.substring(0, strBuyType.length - 1);
strBuyNum = strBuyNum.substring(0, strBuyNum.length - 1);
}
var orderNo = document.getElementById("orderNo").innerHTML;
$.ajax({
type: "post",
url: '../../ASHX/getTreeCombox.ashx?action=saveBuy' + "&t=" + Date.parse(new Date()),
dataType: "json",
//async: true,//异步请求默认为true。如果需要发送同步请求发送false
data: { orderNo: orderNo, userID: '<%=Session["userAccount"]%>', orgID: '<%=Session["userOrgID"]%>', strGN: strGN, strTotalJG: totalJG, strGNName: strGNName, strBuyType: strBuyType, strBuyNum: strBuyNum, strEndDate: strEndDate },
success: function (data) {
alert(JSON.stringify(data));
$('#dg').datagrid({
loadMsg: '正在加载数据请稍后...',
pageSize: 20,
pageList: [20, 30, 40, 50, 100],
fitColumns: true,
pagination: true,
striped: true, //奇偶行是否区分
singleSelect: true,//单选模式
rownumbers: true,//行号
fitColumns: true,
//height: window.innerHeight - 45 - 58,
toolbar: toolbar,
fit: true,
columns: [data.title] //动态取标题
});
$('#dg').datagrid({ loadFilter: pagerFilter }).datagrid('loadData', data.rows); //动态取数据
}
});
}
function getBuy() {
var html = '<br/><table border="1" style=" font-color:black ;font-size:14px;text-align:center">';
html += '<tr>';
html += '<td style="margin: 5px;font-weight:600;"><a style="text-align: center; display: inline-block;width:120px">' + "功能模块" + '</a></td>';
html += '<td style="margin: 5px;font-weight:600;"><a style="text-align: center; display: inline-block;width:90px">' + "购买类型" + '</a></td>';
html += '<td style="margin: 5px;font-weight:600;"><a style="text-align: center; display: inline-block;width:60px">' + "单价" + '</a></td>';
html += '<td style="margin: 5px;font-weight:600;"><a style="text-align: center; display: inline-block;width:60px">' + "数量" + '</a></td>';
html += '<td style="margin: 5px;font-weight:600;"><a style="text-align: center; display: inline-block;width:90px">' + "小计" + '</a></td>';
html += '</tr>';
var buyNumber = 0;
var blMd = true;
for (var i = 0; i < arraySelectMenuName.length; i++) {
if (blbuyAll) {
html += '<tr>';
html += '<td style="margin:10px;height:20px"><a style="text-align: center; display: inline-block;width:120px">' + arrayMenuName[i] + '</a></td>'
html += '<td style="margin:10px;height:20px"><a style="text-align: center; display: inline-block;width:90px">' + buyType[i] + '</a></td>'
html += '<td style="margin:10px;height:20px"><a style="text-align: center; display: inline-block;width:60px">' + buyMDDj[i] + '</a></td>'
html += '<td style="margin:10px;height:20px"><a style="text-align: center; display: inline-block;width:60px">1</a></td>'
html += '<td style="margin:10px;height:20px"><a style="text-align: center; display: inline-block;width:90px">' + buyMDDj[i] + '</a></td>'
totalJG += parseInt(buyMDDj[i]);
buyNumber += 1;
html += '</tr>';
}
else {
if (arraySelectMenuName[i] == "") {
continue;
}
else {
if (buyType[i] != "无限制") {
blMd = false;
}
html += '<tr>';
html += '<td style="margin:10px;height:20px"><a style="text-align: center; display: inline-block;width:120px">' + arraySelectMenuName[i] + '</a></td>'
html += '<td style="margin:10px;height:20px"><a style="text-align: center; display: inline-block;width:90px">' + buyType[i] + '</a></td>'
html += '<td style="margin:10px;height:20px"><a style="text-align: center; display: inline-block;width:60px">' + buyDJ[i] + '</a></td>'
html += '<td style="margin:10px;height:20px"><a style="text-align: center; display: inline-block;width:60px">' + buyNum[i] + '</a></td>'
html += '<td style="margin:10px;height:20px"><a style="text-align: center; display: inline-block;width:90px">' + buyhjJG[i] + '</a></td>'
totalJG += parseInt(buyhjJG[i]);
buyNumber += 1;
html += '</tr>';
}
}
}
html += '</table><br/><br/>';
html += '<a style="text-align: center; display: inline-block">所选功能总价:' + totalJG + '元,</a>';
if (buyNumber == arraySelectMenuName.length) {
if (blMd || blbuyAll) {
html += '<a style="text-align: center; display: inline-block">全站买断价格优惠总价5000元</a>';
}
else {
html += '<a style="text-align: center; display: inline-block">全站功能购买打八折:' + totalJG * 0.8 + '元</a>';
}
}
else {
html += '<a style="text-align: center; display: inline-block">全站功能购买打九折:' + totalJG * 0.9 + '元</a>';
}
var systemMenu = document.getElementById("menuSelected");
systemMenu.innerHTML = html;
var dingdanNo = document.getElementById("orderNo");
dingdanNo.innerHTML = '<%=Session["userAccount"]%>' + getRandom(10); //调用随机数函数生成10位数的随机数
}
//获取指定位数的随机数
function getRandom(num) {
var random = Math.floor((Math.random() + Math.floor(Math.random() * 9 + 1)) * Math.pow(10, num - 1));
return random;
}
function getAllMenu() {
//alert(AllMenu);
arrayMenuName = new Array();
arrayMenuID = new Array();
arraySelectMenuName = new Array();
buyType = new Array();
buyNum = new Array();
buyMDDj = new Array();
buyCSDj = new Array();
buyBNDj = new Array();
buyhjJG = new Array();
buyDJ = new Array();
var html = '<table border="1" style=" font-color:black ;font-size:14px">';
for (var i = 0; i < AllMenu.length; i++) {
if (AllMenu[i]["text"] == "系统设置") {
continue;
}
else {
html += '<tr><td style="margin: 5px;font-weight:600">' + AllMenu[i]["text"] + ':</td></tr>';
var childMenu = AllMenu[i]["children"];
for (var j = 0; j < childMenu.length; j++) {
html += '<tr>';
html += '<td style="height:20px">';
html += '<input required="required" name="' + childMenu[j]["text"] + '" value="' + childMenu[j]["id"] + '" type="checkbox" onclick="btnSelect(this.value,this.name,this.checked)" />' + '<a style="text-align: right; display: inline-block">' + childMenu[j]["text"] + '</a>';
html += '</td>'
html += '<td style="height:20px;width:250px">';
html += ' <input required="required" name="' + childMenu[j]["id"] + '" type="radio" value="MD" checked="checked" onclick="btnbuy(this.value,this.name)"/> <a style="text-align: right; display: inline-block">无限制</a>';
html += '<input required="required" name="' + childMenu[j]["id"] + '" type="radio" value="CS" onclick="btnbuy(this.value,this.name)"/> <a style="text-align: right; display: inline-block">限次数</a>';
html += ' <input required="required" name="' + childMenu[j]["id"] + '" type="radio" value="BN" onclick="btnbuy(this.value,this.name)"/> <a style="text-align: right; display: inline-block">包月</a>';
html += '</td>';
html += '<td style="height:20px;width:150px">';
html += " <input id=\"num" + childMenu[j]["id"] + "\" value=\"12\" type=\"text\" style =\"width :60px\" /> ";
html += '<lable name="numName" id="numNameID' + childMenu[j]["id"] + '"style ="width :30px" />';
html += '</td>'
arrayMenuName.push(childMenu[j]["text"]);
arrayMenuID.push(childMenu[j]["id"]);
arraySelectMenuName.push("");
arraySelectMenuID.push("");
endDate.push("");
buyType.push("无限制");
buyNum.push("1");
buyhjJG.push(childMenu[j]["MDJG"]);
buyDJ.push(childMenu[j]["MDJG"]);
buyMDDj.push(childMenu[j]["MDJG"]);
buyCSDj.push(childMenu[j]["CSJG"]);
buyBNDj.push(childMenu[j]["BNJG"]);
html += '</tr>';
}
}
}
html += '</table>';
//alert(html);
//alert(buyMDDj.join(','));
var systemMenu = document.getElementById("systemMenu");
systemMenu.innerHTML = html;
}
</script>
</html>