var Common = {
//获得url参数(例:"http://localhost:1239?a=1")
GetQueryString: function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
//if (r != null) return unescape(r[2]); return null;
if (r != null) return decodeURI(r[2]); return null;
},
//回到头部(参数为距顶部的距离,默认没有距离)
GoTop: function (marginTop) {
$('body,html').animate({ scrollTop: marginTop || 0 }, 500);
},
//回到尾部(参数为距尾部的距离,默认没有距离)
GoBottom: function (marginBottom) {
var sc = $(document).height() - (marginBottom || 0);
$('body,html').animate({ scrollTop: sc }, 500);
},
//获得选择器
ReturnObj: function (obj) {
try {
var object = typeof obj == "string" ? $("#" + obj).length ? $("#" + obj.replace("#", "")) : $("." + obj).length ? $("." + obj.replace(".", "")) : $(obj) : $(obj);
return object;
}
catch (e) {
return $(obj);
}
},
//切换验证码
ToggleCode: function (obj, codeurl) {
$(obj).children("img").eq(0).attr("src", codeurl + "?time=" + Math.random());
return false;
},
//四舍五入的函数
ForDight: function (Dight, How) {
//例:Common.ForDight(1.413, 1); 保留一位小数 结果为1.4
Dight = Math.round(Dight * Math.pow(10, How)) / Math.pow(10, How);
return Dight;
},
//toFixed() 方法可把 Number 四舍五入为指定小数位数的数字
//eg:var num = new Number(1);alert(num.toFixed(2)); 结果为1.00
ForFixed: function (num, obj) {
var num = new Number(num);
return num.toFixed(obj);
},
ForNumber: function (number) {
return number / 100;
},
//显示信息
MyMsg: {
//成功提示
SuccessMsg: function (msg, showTime, successFunction) {
Common.MyMsg.ShowMsg(msg, 1, showTime, successFunction);
},
//错误提示
ErrorMsg: function (msg, showTime) {
Common.MyMsg.ShowMsg(msg, 2, showTime);
},
//显示信息(icon 1为成功,2为失败,3为询问,4为锁,5为哭脸,6为笑脸,7为警告)
//至关于一个重载的方法 参数icon不传入的话,就是没有任何符号的提示
//如:Common.MyMsg.ShowMsg("真的",3,2000, a); a为方法名 参数必需要齐全,少一个调用方法都会失败
ShowMsg: function (msg, icon, time, successFunction) {
try {
layer.msg(msg, {
icon: icon,
time: time || 2000 //2秒关闭
}, successFunction);//提示后能够执行特定的function
} catch (e) {
alert(msg || e.message);
}
},
},
//加载层
MyLoad: {
//load下标
LoadIndexs: null,
//显示加载
ShowLoad: function () {
Common.LoadIndexs = Common.LoadIndexs || new Array();
try {
Common.LoadIndexs[Common.LoadIndexs.length] = layer.load(2);
//Common.LoadIndexs[Common.LoadIndexs.length] = layer.open({
// type: 3,
// shade: [0.4, '#000']
//});
}
catch (e)
{ }
},
//关闭全部层
CloseLoad: function () {
if (Common.LoadIndexs) {
$.each(Common.LoadIndexs, function (index, ele) {
layer.close(ele);
});
}
}
},
//能够是输入后验证的错误提示
//msg提示信息 obj是选中的对象 如:按钮、文本框等
MyTips: function (obj, msg) {
layer.tips(msg, obj, {
tips: [1, '#3595CC'],
time: 2000
});
},
//询问框
MyConForm: function (msg, successFunction) {
try {
layer.confirm(msg, { icon: 3, title: "提示" }, function (index) {
successFunction();
layer.close(index);
});
}
catch (e) {
if (confirm(msg)) {
successFunction();
}
}
},
MyAjax: {
//发起ajax请求
Ajax: function (type, url, data, async, dataType, successFunction, isShowLoad) {
//弹出遮罩
//$(document).ajaxStart(function () {
// Common.MyLoad.ShowLoad();
//});
//关闭遮罩
$(document).ajaxStop(function () {
Common.MyLoad.CloseLoad();
});
//发起请求
$.ajax({
type: type,
url: url,
data: data, //$.extend(data, { M: Math.random() }),
global: isShowLoad,
async: async,//true 异步 默认值,false 同步
contentType: dataType,//dataType
success: successFunction,
error: Common.MyAjax.AjaxError
});
},
//发起ajaxPost请求,返回json
GetJsonByPost: function (url, data, async, successFunction, isShowLoad) {
Common.MyAjax.Ajax("POST", url, data, async, "application/json", successFunction, isShowLoad);
},
//发起ajaxGet请求,返回json
GetJsonByGet: function (url, data, async, successFunction, isShowLoad) {
Common.MyAjax.Ajax("GET", url, data, async, "application/json", successFunction, isShowLoad);
},
//发起ajaxPost请求,返回html
GetHtmlByPost: function (url, data, async, successFunction, isShowLoad) {
Common.MyAjax.Ajax("POST", url, data, async, "html", successFunction, isShowLoad);
},
//发起ajaxGet请求,返回html
GetHtmlByGet: function (url, data, async, successFunction, isShowLoad) {
Common.MyAjax.Ajax("GET", url, data, async, "html", successFunction, isShowLoad);
},
//ajax错误时调用
AjaxError: function (XMLHttpRequest, textStatus, errorThrown) {
//dialog({ title: '提示', content: "状态:" + textStatus + ";出错提示:" + errorThrown, okValue: '肯定', ok: function () { } }).showModal();
}
},
//操做cookies
MyCookie: {
//写cookies(过时时间默认为7天)
SetCookie: function (name, value, expiresDays) {
var exp = new Date();
expiresDays = expiresDays || 7;
exp.setTime(exp.getTime() + expiresDays * 24 * 60 * 60 * 1000);//";//
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";path=/;";//domain=" + Common.DomainName.MaxName();//domain=testcubejoy.com
},
//读取cookies
GetCookie: function (name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg)) {
return decodeURI(unescape(arr[2]));
//return unescape(arr[2]);
}
else
return null;
},
//删除cookies
DelCookie: function (name) {
var exp = new Date();
exp.setTime(exp.getTime() - 8 * 24 * 60 * 60 * 1000);
var cval = Common.MyCookie.GetCookie(name);//";//
if (cval != null)
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString() + "; path=/;";//domain=" + Common.DomainName.MaxName();//domain=testcubejoy.com
//$.cookie("idphonemail", null);
},
DelDomainCookies: function (domain) {
var cookies = document.cookie.split(/; */);
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
if (cookie.indexOf(domain) != -1) {
var eqPos = cookie.indexOf("=");
var name = cookie.substr(0, eqPos);
document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; domain=" + domain;
}
}
}
},
MyVerification: {
//验证数字
VerificationInt: function (value) {
var patrn = /^[0-9]{1,20}$/;
if (typeof value == "number") {
return true;
}
else if (typeof value == "string" && !patrn.test(value)) {
Common.MyMsg.ErrorMsg("请输入正确的数字");
return false;
}
},
//验证手机(参数1为值,参数2为是否显示默认提示)
VerificationMobile: function (value, isShowMsg) {
var patrn = /^(13[0-9]|15[0|3|6|7|8|9]|18[0-9])\d{8}$/;
if (patrn.test(value)) {
return true;
}
else {
if (isShowMsg) {
Common.MyMsg.ErrorMsg("请输入有效的手机号");
}
return false;
}
},
},
}
第一步
页面须要引用此js
第二步
var loginJs = {
//登陆
goLogin: function () {
var _userinfo = { name: "夏小沫", pwd: "123" };
var _addinfo = { Country: "北京", Street: "上地三街" };
Common.MyAjax.GetJsonByPost("/myinfo/GetInfo", JSON.stringify({ userinfo: _userinfo, addinfo: _addinfo }), false, function (data) {
try {
alert(data);
} catch (e) {
alert(e.message);
}
});
},
}
这是调用common.js的方法,方法很简单,common.js就至关于一个类,直接调取就能够。
备注:
loginJs是一个新的Js,写法可能和你的写法不太同样,不过没有关系,换个写法也是能够的
function aa(){
Common.MyAjax.GetJsonByPost("/myinfo/GetInfo",JSON.stringify({userinfo: _userinfo, addinfo: _addinfo}),false,function(data){
alert(data);
})
}
<input type="text" id="filterName">
<div class="scope fr">
<div class="option">
<div>所有积分范围</div>
<div>0-100积分</div>
<div>100-500积分</div>
<div>1000-5000积分</div>
<div>5000-10000积分</div>
<div>10000积分以上</div>
</div>
</div>
$(function(){
$("#filterName").keyup(function(){
$(".option div").hide().filter(":contains('"+($(this).val())+"')").show();
}).keyup();
$(".option div").click(function(){
var _txt=$(this).text();
$("#filterName").val(_txt);
})
})
一.Join 语法概念
Join 按照功能可分为三大类:
left join (左链接) 即:取左边表的所有数据,即便右边表没有对应的数据,也是会把左边表的数据取出来,并返回
right join(右链接) 即:和left join 相反,取右边表的所有数据。
inner join(内链接,也叫等值链接) 即:取两个表中共同的数据,相似于数学中的交集。
二.Left Join
语句:select * from TableA left join TableB on TableA.orderid=TableB.orderid
结果说明:取TableA表中全部的记录与匹配TableB表中的记录,若是TableB中没有匹配的数据,则返回null,返回的数据集个数是TableA表中的个数
返回的结果集如图:


三.Inner Join
语句:select * from A inner join B on A.orderid=B.orderid
结果说明:inner join产生同时符合A和B的一组数据
返回结果集如图:

四.Right Join
语句:select * from A right join B on A.orderid=B.orderid
结果说明:取TableB表中全部的记录与匹配TableA表中的记录,若是TableA中没有匹配的数据,则返回null,返回的数据集个数是TableB表中的个数
返回结果如图:嘻嘻,没有现成的图,就不整图片啦,相信你会了解返回的数据集的