LaJiFenLei/Waste.Web.Entry/wwwroot/js/main.js

97 lines
2.5 KiB
JavaScript

layui.use(['jquery', 'laydate','layer'], function () {
var laydate = layui.laydate;
var layer = layui.layer;
$("input[class*=ydatetime]").each(function () {
laydate.render({
elem: this,
format: 'yyyy/MM/dd'
});
});
$("input[class*=ysdatetime]").each(function () {
laydate.render({
elem: this,
type: 'datetime',
format:'yyyy/MM/dd HH:mm:ss'
});
});
$("input[data-time='ydatetime']").each(function () {
laydate.render({
elem: this,
range: '~',
calendar: false,
format: 'yyyy/MM/dd'
});
});
$("input[data-time='ysdatetime']").each(function () {
laydate.render({
elem: this,
range: '~',
calendar: false,
type:'datetime',
format: 'yyyy/MM/dd HH:mm:ss'
});
});
$("body").on("click", "img[data-src='preview']", function () {
preview(this);
});
//ͼƬԤÀÀ
function preview(obj) {
layer.photos({
photos: {
"title": "ͼƬԤÀÀ",
"id": 1,
"start": 0,
"data": [
{
"alt": "",
"pid": 1,
"src": obj.src,
"thumb": ""
}
]
}
})
}
function previewimg(src) {
layer.photos({
photos: {
"title": "ͼƬԤÀÀ",
"id": 1,
"start": 0,
"data": [
{
"alt": "",
"pid": 1,
"src": src,
"thumb": ""
}
]
}
});
}
$("body").on("click", "video[data-src='preview']", function () {
layer.open({
type: 1,
title:"ÊÓÆµ²¥·Å",
offset:'15px',
content: '<video src="' + this.src +'" controls="controls">ÄúµÄä¯ÀÀÆ÷²»Ö§³Ö</video>'
});
});
function getImageWidth(url, callback) {
var img = new Image();
img.src = url;
//Èç¹ûͼƬ±»»º´æ£¬ÔòÖ±½Ó·µ»Ø»º´æÊý¾Ý
if (img.complete) {
callback(img.width, img.height);
} else {
img.onload = function () {
callback(img.width, img.height);
}
}
}
})