| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- if ($('.content').height() > 750) {
- $('#iframe-main', parent.document).css('height', $('.content').height() + 20)
- } else {
- $('#iframe-main', parent.document).css('height', '750px')
- }
- function submit_info() {
- var header = $("#header").val();
- var footer = $("#footer").val();
- var group = $("#group").val();
- // if (footer == '') {
- // layer.alert("footer不能为空!");
- // return false;
- // }
- console.log(footer)
- console.log(group)
- $.ajax({
- type: "post",
- url: "home_set",
- data: {
- 'req':'footer',
- header: header,
- footer: footer,
- group:group
- },
- dataType: "json",
- success: function (data) {
- if (data == 0) {
- layer.msg("修改成功!");
- window.location.href = '/systemmanage_role'
- } else if (data == 1) {
- layer.msg("修改失败!");
- }
- }
- });
- return false;
- }
- // file 文件
- // divId div id
- // imgId 图片id
- // fileId 文件id
- // width 图片宽
- // height 图片高
- function previewImage(file, divId, imgId, fileId, width, height) {
- var div = document.getElementById(divId);
- if (file.files && file.files[0]) {
- if (file.files[0].size / 1024 / 1024 < 4) {
- div.innerHTML = '<img id=' + imgId + ' onclick=$("#' + fileId + '").click()>';
- var img = document.getElementById(imgId);
- img.onload = function () {
- // var rect = clacImgZoomParam(width, height, img.offsetWidth, img.offsetHeight);
- img.width = width;
- img.height = height;
- // img.style.marginTop = rect.top+'px';
- }
- var reader = new FileReader();
- reader.onload = function (evt) {
- img.src = evt.target.result;
- // $(window.parent.document).find('.nav-user-photo').attr('src',evt.target.result);
- }
- reader.readAsDataURL(file.files[0]);
- // $('#userPhoto').submit();
- send_logo();
- } else {
- $(file).val('');
- layer.alert("图片过大!");
- }
- } else {//兼容IE
- var sFilter = 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
- file.select();
- if (document.selection != undefined) {
- var src = document.selection.createRange().text;
- div.innerHTML = '<img id=' + imgId + '>';
- var img = document.getElementById(imgId);
- img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
- var rect = clacImgZoomParam(width, height, img.offsetWidth, img.offsetHeight);
- status = ('rect:' + rect.top + ',' + rect.left + ',' + rect.width + ',' + rect.height);
- div.innerHTML = "<div id=divhead style='width:" + rect.width + "px;height:" + rect.height + "px;" + sFilter + src + "\"'></div>";
- }
- }
- }
- function clacImgZoomParam(maxWidth, maxHeight, width, height) {
- var param = { top: 0, left: 0, width: width, height: height };
- if (width > maxWidth || height > maxHeight) {
- var rateWidth = width / maxWidth;
- var rateHeight = height / maxHeight;
- if (rateWidth > rateHeight) {
- param.width = maxWidth;
- param.height = Math.round(height / rateWidth);
- } else {
- param.width = Math.round(width / rateHeight);
- param.height = maxHeight;
- }
- }
- param.left = Math.round((maxWidth - param.width) / 2);
- param.top = Math.round((maxHeight - param.height) / 2);
- return param;
- }
- // 上传图片
- function send_logo() {
- var formData = new FormData($("#userPhoto")[0]);
- $.ajax({
- type: 'post',
- url: 'home_set',
- data: formData,
- contentType: false,
- processData: false,
- success: function (data) {
- if (data == 0) {
- $(window.parent.document).find('.fa fa-leaf').attr('src', $('#viewPhoto').prop('src'));
- }
- else { layer.msg("上传失败!"); }
- }
- });
- }
|