1 Star 0 Fork 0

yuhjphp/问题总结

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
wenti.html 31.45 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=3,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="keywords" content="keywords">
<meta name="description" content="description">
<script src="__ROOT__/Public/kj/js/jquery.min.js"></script>
<link href="__ROOT__/Public/kj/layer/layui-v1.0.9/css/layui.css" rel="stylesheet">
<script src="__ROOT__/Public/kj/layer/layui-v1.0.9/layui.js"></script>
<title>问题</title>
</head>
<body >
<div class="heads" id="head">
<a href="#t1" class="ah2">layui网址 form没定义</a>
<a href="#t2" class="ah2">渲染 加载</a>
<a href="#t3" class="ah2">js打印日志</a>
<a href="#t4" class="ah2">字符串替换</a>
<a href="#t5" class="ah2">ajax请求</a>
<a href="#t6" class="ah2">刷新图片功能</a>
<a href="#t7" class="ah2">模板加载laytpl</a>
<a href="#t8" class="ah2">获取url中参数</a>
<a href="#t9" class="ah2">提示删除?</a>
<a href="#t10" class="ah2">easyui 查询</a>
<a href="#t11" class="ah2">上传图片</a>
<a href="#t12" class="ah2">分页</a>
<a href="#t13" class="ah2">js加一天 年月选择</a>
<a href="#t14" class="ah2">java include</a>
<a href="#t15" class="ah2">ifram</a>
<a href="#t16" class="ah2">js检测身份证</a>
<a href="#t17" class="ah2">mysql统计周日月</a>
<a href="#t18" class="ah2">localStorage</a>
<a href="#t19" class="ah2">js cookie</a>
<a href="#t20" class="ah2">小程序图片预览</a>
<a href="#t21" class="ah2">js 时间转字</a>
<a href="#t22" class="ah2"></a>
</div>
<div class="lista1" id="lista">
<div id="t1">
<pre class="layui-code" lay-title="form,layer 没定义之类">
原因是没有加载
layui.use(['layer','form'], function(){
var layer = layui.layer;
var form = layui.form(); // 1.0.9版要加(),新版不要加()
});
<a href="./wxsmall.html" target="_blank">本地小程序编缉</a>
<a href="http://html.com/java/kangshang/regtest.html" target="_blank">日期弹层H5 html.com/java/kangshang/regtest.html</a>
<a href="http://www.cnblogs.com/qingcaixiaoge/p/5508197.html" target="_blank">http://www.cnblogs.com/qingcaixiaoge/p/5508197.html日期弹层H5</a>
<a href="http://blog.csdn.net/libin_1/article/details/50400941" target="_blank">日期弹层H5 全面 blog.csdn.net</a>
<a href="http://192.168.1.12/din.php/Vue/list" target="_blank">http://192.168.1.12/din.php/Vue/list</a>
<a href="http://www.baidu.com/" target="_blank">百度一下</a>
<a href="http://fanyi.baidu.com/#en/zh/" target="_blank">百度翻译</a>
<a href="http://www.w3school.com.cn/html/html_entities.asp" target="_blank">html符号 HTML 中有用的字符实体 w3school</a>
<a href="http://192.168.1.12/din.php/Vue/list" target="_blank">http://192.168.1.12/din.php/Vue/list</a>
<a href="http://www.w3school.com.cn/tags/html_ref_symbols.html" target="_blank">完整HTML 中有用的字符实体 w3school</a>
<a href="http://www.iconfont.cn/collections/detail?cid=29" target="_blank">icon图标下载</a>
<a href="http://www.layui.com/doc/" target="_blank">www.layui.com/doc/ 文档</a>
<a href="http://www.layui.com/demo/" target="_blank">www.layui.com/demo/ 示例</a>
<a href="http://layer.layui.com/" target="_blank">layer.layui.com/ 弹层之美</a>
<a href="http://layer.layui.com/mobile/" target="_blank">layer.layui.com/mobile/ 移动版弹层</a>
<a href="https://mp.weixin.qq.com/debug/wxadoc/dev/component/navigator.html" target="_blank">微信小程序文档</a>
<a href="https://mp.weixin.qq.com/" target="_blank">微信公众号登录</a>
<a href="http://lbs.qq.com/tool/getpoint/" target="_blank">腾讯地图坐标拾取</a>
<a href="http://api.map.baidu.com/lbsapi/getpoint/index.html" target="_blank">百度地图坐标拾取</a>
<a href="http://www.google.cn/maps/@22.7061321,113.9179452,847m/data=!3m1!1e3" target="_blank">google.cn地图坐标拾取</a>
<a href="http://blog.sina.com.cn/s/blog_4586764e0100h5ct.html" target="_blank">MySql函数大全 http://blog.sina.com.cn/s/blog_4586764e0100h5ct.html</a>
</pre>
</div>
<pre class="layui-code" lay-title="登录列表" >
<a href="https://mp.weixin.qq.com/" target="_blank">微信公众号登录https://mp.weixin.qq.com/</a>
<a href="http://mooking.com/index.php/Admin/Index/index" target="_blank">本地后台商城登录http://mooking.com/index.php/Admin/Index/index</a>
<a href="http://www.zclear.cn/eshop/index.php/Admin/Index/index" target="_blank">http://www.zclear.cn/eshop/index.php/Admin/Index/index</a>
<a href="http://mooking.com/index.php/Admin/" target="_blank">本地后台小程序登录http://mooking.com/small.php</a>
<a href="http://www.zclear.cn/eshop/small.php/" target="_blank">后台小程序登录http://www.zclear.cn/eshop/small.php/</a>
<a href="http://192.168.1.12/din.php/Vue/list" target="_blank">http://192.168.1.12/din.php/Vue/list</a>
<a href="http://cy.vaubansz.com/CMemberTakeAway/index/554073" target="_blank">外卖模板http://cy.vaubansz.com/CMemberTakeAway/index/554073</a>
<div id="hreflist"></div>
</pre>
<div id="t2">
<pre class="layui-code" lay-title="渲染">
// 调方法更新比较好。
function formrender(){
layui.use(['form', 'layedit', 'laydate'], function(){
var form = layui.form(); //1.0.9版用法
// var form = layui.form; // 2.0.1以上用
form.render();
})
}
form.render('select'); //刷新select选择框渲染
var ss="input[name='sex'][value='男']";
$("input[name='sex'][value='男']").prop("checked",true); // 设置男值选中 radio
.prop('checked',false);//不选中
.attr('dataid','123'); // 设置属性
.removeAttr('readyOnly'); // 移除属性
//eg1
var index = layer.load();
//eg2
var index = layer.load(1); //换了种风格
//eg3
var index = layer.load(2, {time: 10*1000}); //又换了种风格,并且设定最长等待10秒
//关闭
layer.close(index);
// 加载方法
var layindex=0;
function layload(i){
if (i==undefined) i=0;
layui.use('layer', function(){
layindex=layer.load(i);
})
}
function layclose(i){
layui.use('layer', function(){
if (i==undefined) i=layindex
layer.close(i);
})
}
// 刷新父页面
parent.location.reload();
function openhtm(v) {
window.location.href=v
}
</pre>
</div>
<div id="t3">
<pre class="layui-code" lay-title="js打印日志">
cosole.log(string)
如果是数组就转为字符串
cosole.log(JSON.stringify(arr));
var str = JSON.stringify(jsObj);
var obj = JSON.parse(str);
</pre>
</div>
<div id="t4">
<pre class="layui-code" lay-title="字符串替换">
var str='aabc';
var ret=str.replace('b','kkk')
// ret=aakkkc
str="jpg|bmp|gif|ico|png";
arr=str.split('|');
// 时间去掉 T .0
function fortime(t){
var str = t.replace('T',' ')
str = str.replace('.0','')
return str;
}
var resultStr=testStr.replace(/\ +/g,""); //去掉空格
resultStr=testStr.replace(/[ ]/g,""); //去掉空格
resultStr=testStr.replace(/[\r\n]/g,"")); //去掉回车换行
var myList=new Array("jpg","bmp","gif","ico","png");
var portableList=myList.join("|");
//结果是jpg|bmp|gif|ico|png
var z=myString.indexOf("key");
var mycars = new Array()
mycars[0] = "Saab"
mycars[1] = "Volvo"
mycars[2] = "BMW"
// 从小到大排序
function sortNumber(a, b)
{
return a - b
}
var arr = new Array(6)
arr[0] = "10"
arr[1] = "5"
arr[2] = "40"
arr[3] = "25"
arr[4] = "1000"
arr[5] = "1"
document.write(arr + "<br />")
document.write(arr.sort(sortNumber))
</pre>
</div>
<div id="t5">
<pre class="layui-code" lay-title="ajax请求">
$.ajax({
type: "POST",
url: "mobile",
dataType: 'json',
data: {
uri: uri,
content: content
},
success: function(result) {
if (result) {
$("#log").text(result);
} else {
$("#log").text("请求数据失败");
}
},
error: function() {
tipmsg("服务器开小差!");
}
});
//获取form表单input的值返回data,直接ajax请求的参数
function getFormJson(form) {
var o = {};
var a = $(form).serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
}
</pre>
</div>
<div id="t6">
<pre class="layui-code" lay-title="刷新图片功能">
/* 刷新图片功能
< img src="__ROOT__/Public/cf/img/8.png" id="dimg" >
调用 freshimg('#dimg')
*/
function freshimg(imgid) {
var s= $(imgid).attr('src');
var i=s.indexOf('?');
var cc=Math.floor(Math.random()*1000);
if (i>0) {
var strs= new Array();
strs = s.split("?")
s=strs[0]
}
s += '?a='+cc;
$(imgid).attr('src',s);
}
function randomString(len) {
  len = len || 32;
  var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
  var maxPos = $chars.length;
  var pwd = '';
  for (i = 0; i < len; i++) {
    pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
  }
  return pwd;
}
//更新后---
function freshimg(imgid) {
var s= $(imgid).attr('src');
console.log(s)
var i=s.indexOf('?');
var cc=Math.floor(Math.random()*1000);
if (i>0) {
var strs= new Array();
strs = s.split("?")
s=strs[0]
}
s += '?'+randomString(6)+'='+cc;
$(imgid).attr('src',s);
}
function randomString(len) {
  len = len || 32;
  var $chars = 'abcdefghijklmnoprstuvwxyzabcdefghijklmnoprstuvwxyz'; /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
  var maxPos = $chars.length;
  var pwd = '';
  for (i = 0; i < len; i++) {
    pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
  }
  return pwd;
}
</pre>
</div>
<div id="t7">
<pre class="layui-code layui-box layui-code-view" lay-title="模板加载">
var data=[{'src':'cc','id':1},{}]
// 调用 funlaytpl(data, '#demo3', '#toid')
// 要更新的数据[{},{}],源模板#demo3,放到位置#toid
function funlaytpl(data, fromid, toid) {
layui.use('laytpl', function(){
var laytpl = layui.laytpl;
var tplhtm = $(fromid).html()
//使用方式跟独立组件完全一样
laytpl(tplhtm).render(data, function(html){
$(toid).html(html);
});
});
}
// 刷新
function formrender(){
layui.use(['form', 'layedit', 'laydate'], function(){
var form = layui.form()
form.render();
})
}
// 源模板
&lt;script id="demo3" type="text/html">
{{# layui.each(d, function(index, item){ }}
&lt;div class="addimg" imgid="{{ item.id }}">
&lt;img src="{{ item.src }}" height="100px">
&lt;span class="layui-btn layui-btn-danger layui-btn-small">删除&lt;/span>
&lt;/div>
{{# if(d.length === 0){ }}
无数据
{{# } }}
{{# }); }}
&lt;/script>
</pre>
</div>
<div id="t8">
<pre class="layui-code" lay-title="">
// 获取当前页面的?参数 http://www.jb51.net/article/82519.htm
// 调用 var n=GetQueryString('name')
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg); //获取url中"?"符后的字符串并正则匹配
var context = "";
if (r != null)
context = r[2];
reg = null;
r = null;
return context == null || context == "" || context == "undefined" ? "" : context;
}
// 转码
decodeURI()
</pre>
</div>
<div id="t9">
<pre class="layui-code" lay-title="您确定要删除吗?">
layer.confirm('您确定要删除吗?', function(index){
$.ajax({
type: "POST",
url: "su_delSupplier.action",
data: {id:id},
dataType: 'json',
success: function(result) {
if (result.errcode==1) {
tip("成功");
}else{
tip("失败");
}
//$('#bookbody').datagrid('reload');// 重新加载
},
error: function() {
tip("未连到服务器!");
}
});
layer.close(index)
});
function tip(v) {
layui.use('layer', function(){
var layer = layui.layer;
layer.msg(v);
});
}
</pre>
</div>
<div id="t10">
<pre class="layui-code" lay-title="easyui 查询">
$("#bookbody").datagrid({
width : "auto",
height : "auto",
// iconCls : 'icon-help', // 表格左上角的图标样式
url : "ord_listDishOrderInfo.action",
rownumbers : true, // 在最前面显示行号
fitColumns : true, // 自动适应列宽
pagination : true, // 在底部显示分页工具栏
striped : true, // 隔行变色
//singleSelect : true, // 每次只选中一行
singleSelect : false, // 选中多行
selectOnCheck: true, //
checkOnSelect: true, //
loadMsg : '加载……',
pageSize : 10, // 指定每页的大小,服务器要加上page属性和total属性
remoteSort : true, // 从服务器端排序,默认true
pageList : [ 10,20,50,100], // 可以设置每页记录条数的列表,服务器要加上rows属性
idField : 'id', // 主键属性
// 编码,用户名,邮箱,地址电话
toolbar : '#tb',
queryParams: form2Json(), //初始条件
columns : [ [ {
field : 'order_number',
title : '订单编码',
width : 120
}, {
field : 'order_create_date_time',
title : '订单时间',
width : 110 ,
formatter : function(value) {
return value ;
}
}, {
field : 'order_amount',
title : '金额',
width : 50 ,
}, {
field : 'login_name',
title : '订单用户',
width : 110,
}, {
field : 'order_state',
title : '订单状态',
width : 50,
formatter : function(value) {
var str = '完成'
return str;
}
}, {
field : 'id',
title : '操作',
// width : 110,
formatter : function(value,row) {
var str = '&lt;span class="layui-btn layui-btn-mini" onclick="orderdetail('+value+')">详情&lt;/span> '
return str ;
}
} ] ] ,
onLoadSuccess:function(data){
if(data){
$.each(data.rows, function(index, item){
// 设置为选中
if(item.id <100){
$('#einfo').datagrid('checkRow', index);
}
});
}
}
});
$('#bookbody').datagrid('reload');
// 查询
function doSearch(){
// datetime="+v+"&orderstate="+b
$('#bookbody').datagrid('load',{
datetime:$("#param1").val(),
orderstate:$("#param2").val()
});
}
// 初始条件
function form2Json(){
return {
datetime:$("#param1").val(),
orderstate:$("#param2").val()
}
}
下拉框
$("#city2").combobox("getValues")
$('#city').combobox('setValue', 'bj')
日期
$("#param1").datebox('getValue')
$("#param1").datebox('setValue','2017-5-19 14:30:26')
一般输入
$('#param3').val()
$('#param3').val('123')
easyui边框样式 下拉框输入框
.easybbp{
border: solid 1px #95B8E7;
border-radius: 5px;
padding: 2px;
}
</pre>
</div>
<div id="t11">
<pre class="layui-code" lay-title="上传图片">
&lt;img src="../images/upload.png" id="testimg1" height="150px" width="200px">
&lt;input type="file" name="image" id="testfile1" class="layui-upload-file">
&lt;input type="hidden" name="testhide1" id="testhide1" >
layui.use('upload', function(){
fileup();
});
function fileup(){
layui.upload({
url: 'alterImage_upload'
,elem: '#testfile1'
,method: 'post'
,success: function(res){
var imgpath = "../" + res.src;
$('#testimg1').attr('src', imgpath);
$('#testhide1').val(imgpath);
}
});
}
function fileupi(i){
var fileid = '#testfile'+i; //渲染的上传图片控件id
layui.upload({
url: 'alterImage_upload'
,elem: fileid
,method: 'post'
,success: function(res){
var showsrc = '#testimg'+i;
var imgpath = "../" + res.src;
$(showsrc).attr('src', imgpath);
var hideid = '#testhide'+i;
$(hideid).val(imgpath);
}
});
}
</pre>
</div>
<div id="t12">
<pre class="layui-code" lay-title="分页">
/*
initpage(8)
showlist(8,1)
*/
function showlist(rows,page)
{
var devname = $("#inputdevname").val();
layload(2)
}
var pagetotal=0
// showpage(result.total,rows)
// 总数,每页显示的数目rows
function showpage(total,rows){
if ( total==pagetotal) return; // 禁止第二次初始化
pagetotal=total;
var page=Math.ceil(total / rows); //总页数
layui.use(['laypage', 'layer'], function(){
var laypage = layui.laypage
laypage({
cont: 'demopage'
,pages: page
,skip: true
,jump: function(obj, first){
if(!first){
// layer.msg('第 '+ obj.curr +' 页');
showlist(rows,obj.curr)
}
}
});
})
}
// 加载方法
var layindex=0;
function layload(i){
layui.use('layer', function(){
layindex=layer.load(i);
})
}
function layclose(i){
layui.use('layer', function(){
if (i==undefined) i=layindex
layer.close(i);
})
}
</pre>
</div>
<div id="t13">
<pre class="layui-code" lay-title="+1天">
http://www.cnblogs.com/gmq-sh/p/5194706.html
// 日期,在原有日期基础上,增加days天数,默认增加1天
function addDate(date, days) {
if (days == undefined || days == '') {
days = 1;
}
var date = new Date(date);
date.setDate(date.getDate() + days);
var month = date.getMonth() + 1;
var day = date.getDate();
return date.getFullYear() + '-' + getFormatDate(month) + '-' + getFormatDate(day);
}
// 日期月份/天的显示,如果是1位数,则在前面加上'0'
function getFormatDate(arg) {
if (arg == undefined || arg == '') {
return '';
}
var re = arg + '';
if (re.length < 2) {
re = '0' + re;
}
return re;
}
// 年月显示
&lt;span class="t1" style="width:150px">
&lt;select name="year1" lay-filter="aihao" id="year1">
&lt;option value="">请选择年&lt;/option>
&lt;option value="1">1月&lt;/option>
&lt;/select>
&lt;/span>
&lt;span class="t1" style="width:150px">
&lt;select name="month1" lay-filter="aihao" id="month1" >
&lt;option value="">请选择月份&lt;/option>
&lt;option value="01">1月&lt;/option>
&lt;option value="02">2月&lt;/option>
&lt;option value="03">3月&lt;/option>
&lt;option value="04">4月&lt;/option>
&lt;option value="05">5月&lt;/option>
&lt;option value="06">6月&lt;/option>
&lt;option value="07">7月&lt;/option>
&lt;option value="08">8月&lt;/option>
&lt;option value="09">9月&lt;/option>
&lt;option value="10">10月&lt;/option>
&lt;option value="11">11月&lt;/option>
&lt;option value="12">12月&lt;/option>
&lt;/select>
&lt;/span>
// setyear(2000,2030)
function setyear(min,max){
var date = new Date();
var s=date.getFullYear()
// console.log(s)
var str = '&lt;option value="">请选择年&lt;/option>'
for (var i = min; i &lt; max; i++) {
if (i==s) {
str += '&lt;option value="'+i+'" selected>'+i+'年&lt;/option>'
}else
str += '&lt;option value="'+i+'">'+i+'年&lt;/option>'
}
$("#year1").html(str);
formrender();
}
</pre>
</div>
<div id="t14">
<pre class="layui-code" lay-title="">
静态页包含
&lt;%@ include file="head.html" %>
&lt;jsp:include page="menuleft.jsp" flush="true" >
</pre>
</div>
<div id="t15">
<pre class="layui-code" lay-title="大通上传图片">
&lt;iframe id="certUploadFrame" name="certUploadFrame" src="__MODULE__/Jpg/minitPage1?sid={$sid}&ticket={$ticket}&certType=0&ptype=1" frameborder="0" scrolling="no" style="width:100%;" height="295px">&lt;/iframe>
http://localhost/webhand/tp322/index.php/Home/Dtmobile/stjhm
/webhand/tp322/index.php/Home/Jpg/minitPage1?sid=stimg20170805142318440&ticket=1501914198&certType=0&ptype=1
$this->sid = 'repair'.date("YmdHis").rand(100,999);
$this->ticket = time();
//提示
.layui-layer-content{
background:#e88329;
color: #fff;
}
$imgurl = __ROOT__ . "/Uploads/Repair/";
</pre>
</div>
<div id="t16">
<pre class="layui-code" lay-title="检测身份证">
// 身份证
var regPhone=/1[3-8]+\d{9}/
// 请输入正确的身份证号 判断位数
isCardNo = function(obj)
{
var reg = /(^\d{15}$)|(^\d{17}(\d|X)$)/;
if(reg.test(obj) === false)
{
return false;
}
return true;
};
// 判断身份证号最后一位
checkParity = function(obj)
{
obj = changeFivteenToEighteen(obj);
var len = obj.length;
if(len == '18')
{
var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
var cardTemp = 0, i, valnum;
for(i = 0; i < 17; i ++)
{
cardTemp += obj.substr(i, 1) * arrInt[i];
}
valnum = arrCh[cardTemp % 11];
if (valnum == obj.substr(17, 1))
{
return true;
}
return false;
}
return false;
};
changeFivteenToEighteen = function(obj)
{
if(obj.length == '15')
{
var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
var cardTemp = 0, i;
obj = obj.substr(0, 6) + '19' + obj.substr(6, obj.length - 6);
for(i = 0; i < 17; i ++)
{
cardTemp += obj.substr(i, 1) * arrInt[i];
}
obj += arrCh[cardTemp % 11];
return obj;
}
return obj;
};
</pre>
</div>
<div id="t17">
<pre class="layui-code" lay-title="统计周日月">
统计周日月
select DATE_FORMAT(create_time,'%Y%u') weeks,count(caseid) count from tc_case group by weeks;
select DATE_FORMAT(create_time,'%Y%m%d') days,count(caseid) count from tc_case group by days;
select DATE_FORMAT(create_time,'%Y%m') months,count(caseid) count from tc_case group by months;
http://blog.sina.com.cn/s/blog_4586764e0100h5ct.html
</pre>
</div>
<div id="t18">
<pre class="layui-code" lay-title="localStorage">
localStorage.setItem('input_name', '4455');
var input_name = localStorage.getItem('input_name');
if(window.localStorage){
alert('你的浏览器支持localStorage!');
}else{
alert('浏览器不支持localStorage!');
}
localStorage.myName='walkingp';
localStorage['mySite']='http://www.cnblogs.com/walkingp';
alert('name:' + localStorage.myName + '\rsite:' + localStorage['mySite']);
localStorage['mySite']=null;
</pre>
</div>
<div id="t19">
<pre class="layui-code" lay-title="cookie">
function setCookie(c_name,value,expiredays)
{
var exdate=new Date()
exdate.setDate(exdate.getDate()+expiredays)
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}
//取回cookie
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=")
if (c_start!=-1)
{
c_start=c_start + c_name.length+1
c_end=document.cookie.indexOf(";",c_start)
if (c_end==-1) c_end=document.cookie.length
return unescape(document.cookie.substring(c_start,c_end))
}
}
return ""
}
示例:
//设置cookie,有效期为365天
setCookie('username','123',365);
//取回,若cookie失效,将返回空
getCookie('username');
</pre>
</div>
<div id="t20">
<pre class="layui-code" lay-title="">
mode="widthFix"
&lt;span style="font-family:Comic Sans MS;font-size:18px;color:#333333;">&lt;view class="container">
&lt;view wx:for="{{imgalist}}" wx:for-item="image" class="previewimg">
&lt;image src="{{image}}" data-src="{{image}}" bindtap="previewImage">&lt;/image>
&lt;/view>
&lt;/view>&lt;/span>
data: {
imgalist:[
"/a.jpg",
"/a.jpg",
"/a.jpg",
"/a.jpg",
]},
/**
* 预览图片
*/
previewImage: function (e) {
var current=e.target.dataset.src;
wx.previewImage({
current: current, // 当前显示图片的http链接
urls: this.data.imgalist // 需要预览的图片http链接列表
})
}
</pre>
</div>
<div id="t21">
<pre class="layui-code" lay-title="">
// js 时间戳转yyyy-mm-dd
function settime(timestamp) {
if (!timestamp) return '';
var date = new Date();
date.setTime(timestamp * 1000);
// var date = new Date(inputTime);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? ('0' + m) : m;
var d = date.getDate();
d = d < 10 ? ('0' + d) : d;
var h = date.getHours();
h = h < 10 ? ('0' + h) : h;
var minute = date.getMinutes();
var second = date.getSeconds();
minute = minute < 10 ? ('0' + minute) : minute;
second = second < 10 ? ('0' + second) : second;
return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
};
</pre>
</div>
<div id="t22">
<pre class="layui-code" lay-title="">
</pre>
</div>
<div id="t23">
<pre class="layui-code" lay-title="">
</pre>
</div>
<div id="t24">
<pre class="layui-code" lay-title="">
</pre>
</div>
<div id="t25">
<pre class="layui-code" lay-title="">
</pre>
</div>
<div id="t26">
<pre class="layui-code" lay-title="">
</pre>
</div>
<div id="t27">
<pre class="layui-code" lay-title="">
</pre>
</div>
<div id="t28">
<pre class="layui-code" lay-title="">
</pre>
</div>
<div id="t29">
<pre class="layui-code" lay-title="">
</pre>
</div>
<div id="t110">
<pre class="layui-code" lay-title="其它">
< a href="" target="_blank">其它</a>
</pre>
</div>
<script>
layui.use('layer', function(){
var layer = layui.layer;
});
function webtip(v) {
// body...
layui.use('layer', function(){
var layer = layui.layer;
layer.msg(v);
});
}
var layindex=0;
function layload(i){
layui.use('layer', function(){
layindex=layer.load(i);
})
}
function layclose(i){
layui.use('layer', function(){
if (i==undefined) i=layindex
layer.close(i);
})
}
/*
cancel: 点关闭,end: 销毁
cancel: function(index, layero){
if(confirm('确定要关闭么')){ //只有当点击confirm框的确定时,该层才会关闭
layer.close(index)
}
return false;
}
*/
function openweb(url){
layer.open({
type: 2,
title: false,
closeBtn: 0, //不显示关闭按钮
shade: 0.4,
shadeClose: true,
area: ['100%', '70%'],
offset: 'b', //右下角弹出
anim: 2,
content: [url, 'yes']
});
}
layui.use('layer', function(){
var layer = layui.layer;
var i1= layer.open({
type: 1,
title: '目录',
offset: ['20px','20px'],
shade: false,
closeBtn: false,
resize: false, //可拉伸
scrollbar: true,
area: ['300px', 'auto'],
content: $('#head'),
end : function(index, layero){
if(confirm('确定要关闭么')){ //只有当点击confirm框的确定时,该层才会关闭 层
layer.close(index)
}
return false;
}
});
// setTimeout(function() {layer.close(i1)}, 3000);
//
layer.open({
type: 1,
title: '代码区',
offset: ['20px','380px'],
shade: false,
closeBtn: false,
scrollbar: true,
resize: true, //可拉伸
maxmin: true,
area: ['700px', 'auto'],
content: $('#lista'),
success: function(layero, index){
console.log(layero, index);
}
});
/*layer.open({
type: 2,
title: false,
closeBtn: 0, //不显示关闭按钮
shade: 0.4,
shadeClose: true,
area: ['100%', '70%'],
offset: 'b', //右下角弹出
anim: 2,
content: ['http://layer.layui.com/', 'yes']
});*/
// openweb('http://layer.layui.com/')
});
layui.use('code', function(){
layui.code({
about: false,
// height: '150px', //请注意必须加px。如果该key不设定,则会自适应高度,且不会出现滚动条。
});
});
/*
&lt; <
&#39; '
&#34; "
http://www.w3school.com.cn/html/html_entities.asp
无心法师第7集
http://113.113.89.145/sohu/v1/TmwG0EIsWDvHyVoObTdNeSxDfSAODpNIvI2otyCfewHqM14wmfcymcAr.mp4?k=sD2tvY&p=j9lvzSwC0S1m0SkmoLx3qLwAopsWsU1IyLNS0MWAyJ2dypES0mEAZD6sfY6XfGA4Wh6S0pviNF2Cf5&r=TmI20LscWOoUgt8IS33SwjHXClyqakB4wFF9alfqHFWJiFPkUFQOHwgq9G9oAODOfoIWG1svmXAyBj&q=OpCUhW7IWhodRD6XfYWSotE7ZD6XfOXORhXsWByHfhb4vmbcWJesWY6OfD1SqD2sWOvSqF2sY&cip=183.39.177.145
nmORHinvjT8nxqfbLYw0NJLS98EGDpkTs9AjI5e1CWk9
kohNmesyGhLT-VxzHjjoBNbGvO2QqOnm87OfFekPSHvO8F1wNzu-l2FghGvu9iE7exOzWy3jg6bWaXYHo1rD_IZ6OEzuzG-AmEC4blF3ktnoxsc3tPBj12-0iLYC-goy
XlViS6Sl1ZzXQyugB5XLiOhN0Kl51E28PYE5U5oEl-5hvOTNHr7YrvkbMBF2YLBf4GP-clFMfszl9Co42fj1uh1FFW-VJ48L4lqLEa7A9y42-41U7o97QuyiQvF_zAIoFIXdADANQF
*/
var yy = {
ii : 0,
changei:function(i){
ii = i;
},
showi: function(){
alert(ii)
},
test1: function(a, b, str){
return str.replace(a, b)
}
}
function funlaytpl(data, fromid, toid) {
layui.use('laytpl', function(){
var laytpl = layui.laytpl;
var tplhtm = $(fromid).html()
//使用方式跟独立组件完全一样
laytpl(tplhtm).render(data, function(html){
$(toid).html(html);
});
});
}
// <a href="http://cy.vaubansz.com/CMemberTakeAway/index/554073" target="_blank">外卖模板http://cy.vaubansz.com/CMemberTakeAway/index/554073</a>
</script>
<style type="text/css">
a:hover{
background: #FF5722;
color:#fff;
border-radius: 3px;
}
.heads a{
display: block;
font-size: 20px;
padding: 2px 3px;
border-bottom: solid 1px #ccc;
}
.lista1{
padding: 1px;
/*padding-top: 0px;*/
}
/*弹出层高度自动时,可以控制高度*/
.layui-layer-content{
height: 600px;
}
.layui-code-view{
/*margin-top: 0px;*/
}
</style>
<script type="text/javascript">
$(function(){
var hrefarr = [
{
"name":"外卖模板",
"href":"http://cy.vaubansz.com/CMemberTakeAway/index/554073"
},{
"name":"本地数据库",
"href":"http://localhost/phpmyadmin/"
},{
"name":"判断是否微信打开",
"href":"http://blog.csdn.net/blacksource/article/details/23671667"
},{
"name":"微信支付文档",
"href":"https://pay.weixin.qq.com/wiki/doc/api/H5.php?chapter=9_7&index=7"
}
]
funlaytpl(hrefarr, '#demohref', '#hreflist');
})
</script>
<script id="demohref" type="text/html">
{{# layui.each(d, function(index, item){ }}
<br><a href="{{item.href}}" target="_blank">{{item.name}} {{item.href}}</a>
{{# }); }}
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/yuhjphp/wenti.git
git@gitee.com:yuhjphp/wenti.git
yuhjphp
wenti
问题总结
master

搜索帮助