针对这几月的技术,做一次小总结
上传控件uploadify
function inexel() {
$("#btnExcel").uploadify({
'method': 'post',
'swf': 'js/uploadify/uploadify.swf',
'successTimeout': , //设置时间
'debug': false,
'auto': true,
'multi': false,
'uploader': 'AjaxSource/FileUpLoad.ashx', //加载成后的ashx页面
'buttonText': '导入', //文本值
'fileSizeLimit': '4MB', //文件大小
'width': ,
'height': ,
'fileTypeDesc': '支持的格式:',
'fileTypeExts': '*.xls;', //文本格式
'formData': { 'OPT': 'Inexenl' }, //参数值
'onFallback': function () {/*检测FLASH失败调用*/
alert("您未安装FLASH控件,无法选择文件!请安装FLASH控件后再试。");
},
'onUploadStart': function (file) { },
'onUploadSuccess': function (file, data, response) {
var f = $.parseJSON(data);
if (response) {
if (f.length > ) {
readExcel(f); //把加载后的值,读取后,返回页面table
}
} else {
alert("导入失败,请重新选择!");
}
}
});
}
uploadify
前台获取返回的json值
//阅读execl文件
function readExcel(f) {
var trtd = "";
var tacout = ($("#tdui").find("tr").length) - ;
for (var i = ; i < f.length; i++) {
var na = f[i].names == undefined ? "" : f[i].names; //名字
var se = f[i].sexs == undefined ? "" : f[i].sexs; //性别
var phn = f[i].phones == undefined ? "" : f[i].phones; //电话
}
}
radio选中
if (tyw == '小孩') {
$('#typ_1').attr('checked', true); //年龄阶段
} else if (tyw == '成人') {
$('#typ_2').attr('checked', true);
} else if (tyw == '老人') {
$('#typ_3').attr('checked', true);
} else {
$('#typ_4').attr('checked', true);
}
<label><input name="txtkend" type="radio" id="typ_4" value="婴儿" />婴儿</label><label>
<input name="txtkend" id="typ_1" type="radio" value="小孩" checked="checked" />小孩</label><label><input
name="txtkend" type="radio" id="typ_2" value="成人" />成人</label>
其他数据后台返回json
//确认的字符串是数据库读取的,自己定义
JObject qb = new JObject();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument(); //客人名单信息
JArray jakr = new JArray();
JObject joker = new JObject();
int krert = ;
//团队信息
JArray jatd = new JArray();
JObject jotd = new JObject();
int tds = ;
if (string.IsNullOrEmpty(xmld) && string.IsNullOrEmpty(xmltd))
{
joker.Add("orderid", "kr");
jakr.Add(joker);
jotd.Add("orderid", "td");
jatd.Add(jotd);
}
else
{
if (!string.IsNullOrEmpty(xmlsor.ToString())) //客人名单
{
for (int i = ; i < xmlsor.Length; i++)
{
string kren = "<xmlkr>" + xmlsor[i] + "</xmlkr>";
doc.LoadXml(kren);//Name节点名称
XmlNode xn = doc.SelectSingleNode("xmlkr");
// 得到根节点的所有子节点
XmlNodeList node = xn.ChildNodes;
foreach (XmlNode xnd in node)
{
XmlElement xe = (XmlElement)xnd;
if (xe != null)
{
XmlNodeList nods = xe.ChildNodes;
krert += nods.Count;
if (krert > )
{
foreach (XmlNode ite in nods)
{
XmlElement xeh = (XmlElement)ite;
joker = new JObject();
joker.Add("orderid", xeh.GetAttribute("order").ToString());
joker.Add("kguestname", ite.SelectSingleNode("guestname").InnerText);
joker.Add("ksex", ite.SelectSingleNode("sex").InnerText);
joker.Add("kmobile", ite.SelectSingleNode("mobile").InnerText);
joker.Add("kpassport", ite.SelectSingleNode("passport").InnerText);
joker.Add("kvisa", ite.SelectSingleNode("visa").InnerText);
joker.Add("ktypepass", ite.SelectSingleNode("typepass").InnerText);
joker.Add("kcountry", ite.SelectSingleNode("country").InnerText);
joker.Add("ken", ite.SelectSingleNode("en").InnerText);
joker.Add("khit", ite.SelectSingleNode("hit").InnerText);
joker.Add("kguestuu", ite.SelectSingleNode("guestuu").InnerText);
jakr.Add(joker);
}
}
}
//if (!string.IsNullOrEmpty(xmlsor[0]))
//{
// list = xmlsor.ToList();
// list.RemoveAt(0);
// xmlsor = list.ToArray();
//}
}
}
}
if (!string.IsNullOrEmpty(xmltd)) //客人信息
{
doc.LoadXml(xmltd);//Name节点名称
XmlNode xn = doc.SelectSingleNode("GuestInfo");
// 得到根节点的所有子节点
XmlNodeList node = xn.ChildNodes;
tds = node.Count;
if (tds > )
{
foreach (XmlNode xnd in node)
{
jotd = new JObject();
XmlElement xe = (XmlElement)xnd;
if (xe != null)
{
XmlNodeList nodelist = xe.ChildNodes;
jotd.Add("orderid", xe.GetAttribute("order").ToString());
jotd.Add("guestname", xnd.SelectSingleNode("guestname").InnerText);
jotd.Add("sex", xnd.SelectSingleNode("sex").InnerText);
jotd.Add("mobile", xnd.SelectSingleNode("mobile").InnerText);
jotd.Add("passport", xnd.SelectSingleNode("passport").InnerText);
jotd.Add("visa", xnd.SelectSingleNode("visa").InnerText);
jotd.Add("typepass", xnd.SelectSingleNode("typepass").InnerText);
jotd.Add("country", xnd.SelectSingleNode("country").InnerText);
XmlNodeList elet = xe.GetElementsByTagName("en");
if (elet != null && elet.Count > )
{
string en = "";
en = xnd.SelectSingleNode("en").InnerText;
if (en != null && en.Length > )
{
jotd.Add("en", en);
}
else
{
jotd.Add("en", en);
}
}
else
{
jotd.Add("en", "");
}
jotd.Add("hit", xnd.SelectSingleNode("hit").InnerText);
jotd.Add("guestuu", xnd.SelectSingleNode("guestuu").InnerText);
jatd.Add(jotd);
}
}
} } }
int cout = ;
if (krert != || tds != )
{
//判断客人数组和团队数组的大小。如果客人数组长度大,则添加团队名单,否则,反之
if (krert > tds)
{
cout = krert - tds;
for (int i = ; i < cout; i++)
{
jotd = new JObject();
jotd.Add("orderid", "");
jotd.Add("guestname", "");
jotd.Add("sex", "");
jotd.Add("mobile", "");
jotd.Add("passport", "");
jotd.Add("visa", "");
jotd.Add("typepass", "");
jotd.Add("country", "");
jotd.Add("en", "");
jotd.Add("hit", "");
jotd.Add("guestuu", "");
jatd.Add(jotd);
}
}
}
qb.Add("kers", jakr);
qb.Add("tds", jatd);
////先读出客人订单,和团队订单,组成两个数组,最后组成obj ,返回前台对象,
////前台对象获取<订单号。身份证和名字。进行显示>
//Newtonsoft.Json.Linq.JObject oxml = Newtonsoft.Json.Linq.JObject.FromObject(doc);
//xm = oxml.ToString();ClassUU.ClassStrBase.DeleteHTMLCode(xm.ToString());
return qb.ToString();
其他数据前台json
//数据加载
function loads() {
$.ajax({
url: "AjaxSource/TeamList.ashx?OPT=lkr&TeamID=" + $("#ted").val(),
type: "POST",
success: function (r) {
var td = $.parseJSON(r);
var kres = td.kers;
var tdy = td.tds;
// console.log(kres);
// console.log(tdy);
// .orderid != "kr" && d.tds
var ge = document.getElementById('tpl-ShopCart').innerHTML;
laytpl(ge).render(td, function (html) {
document.getElementById('divselect').innerHTML = html;
});
},
error: function (XMLHttpRequest, textStatus, errorThrown) { layer.msg('网络出现错误了!,请刷新重试或者联系管理员'); },
complete: function (XMLHttpRequest, textStatus) {
}
});
}
前台js模板是参照 layer模板
http://layer.layui.com/
大家可以去看看这个网址