补充文件
2091
public/static/mobile/edit/css/Common.css
Normal file
62
public/static/mobile/edit/css/font.css
Normal file
@@ -0,0 +1,62 @@
|
||||
@font-face {
|
||||
font-family: 'iconfont';
|
||||
src: url('//at.alicdn.com/t/font_1458365148_6313732.eot'); /* IE9*/
|
||||
src: url('//at.alicdn.com/t/font_1458365148_6313732.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
|
||||
url('//at.alicdn.com/t/font_1458365148_6313732.woff') format('woff'), /* chrome、firefox */
|
||||
url('//at.alicdn.com/t/font_1458365148_6313732.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
|
||||
url('//at.alicdn.com/t/font_1458365148_6313732.svg#iconfont') format('svg'); /* iOS 4.1- */
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.ui-icon,[class^=ui-icon-] {
|
||||
font-family:iconfont!important;
|
||||
|
||||
font-style:normal;
|
||||
-webkit-font-smoothing:antialiased;
|
||||
-webkit-text-stroke-width:.2px;
|
||||
display:block;
|
||||
color:rgba(0,0,0,.5)
|
||||
}
|
||||
.ui-icon-phone:before {
|
||||
content:"\e601"
|
||||
}
|
||||
.ui-icon-pwd:before {
|
||||
content:"\e603"
|
||||
}
|
||||
.ui-icon-yzm:before {
|
||||
content:"\e600"
|
||||
}
|
||||
.ui-icon-gs:before {
|
||||
content:"\e605"
|
||||
}
|
||||
|
||||
|
||||
.ui-icon-add:before {
|
||||
content:"\e60b"
|
||||
}
|
||||
.ui-icon-true:before {
|
||||
content:"\e60d";
|
||||
font-size: 22px !important;
|
||||
color:#4cd964
|
||||
}
|
||||
.ui-icon-false:before {
|
||||
content:"\e60e";
|
||||
font-size: 22px !important;
|
||||
color: #f6383a
|
||||
}
|
||||
.icon2 {
|
||||
font-family: iconfont!important;
|
||||
font-style: normal;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-size: 100% auto;
|
||||
background-position: center;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-webkit-text-stroke-width: .2px;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
.icon-video:before {
|
||||
content: "\e60c";
|
||||
}
|
||||
6
public/static/mobile/edit/css/sm-extend.min.css
vendored
Normal file
6
public/static/mobile/edit/css/sm.min.css
vendored
Normal file
BIN
public/static/mobile/edit/img/addimg.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
public/static/mobile/edit/img/cosle.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
public/static/mobile/edit/img/icon_bgcolor.png
Normal file
|
After Width: | Height: | Size: 343 B |
BIN
public/static/mobile/edit/img/icon_bold.png
Normal file
|
After Width: | Height: | Size: 473 B |
BIN
public/static/mobile/edit/img/icon_center.png
Normal file
|
After Width: | Height: | Size: 341 B |
BIN
public/static/mobile/edit/img/icon_color.png
Normal file
|
After Width: | Height: | Size: 400 B |
BIN
public/static/mobile/edit/img/icon_font.png
Normal file
|
After Width: | Height: | Size: 561 B |
BIN
public/static/mobile/edit/img/icon_left.png
Normal file
|
After Width: | Height: | Size: 340 B |
BIN
public/static/mobile/edit/img/icon_right.png
Normal file
|
After Width: | Height: | Size: 337 B |
BIN
public/static/mobile/edit/img/link.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
public/static/mobile/edit/img/t_add.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
public/static/mobile/edit/img/t_cancel.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/static/mobile/edit/img/t_del0.png
Normal file
|
After Width: | Height: | Size: 612 B |
BIN
public/static/mobile/edit/img/t_image.png
Normal file
|
After Width: | Height: | Size: 755 B |
BIN
public/static/mobile/edit/img/t_text.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
public/static/mobile/edit/img/t_video.png
Normal file
|
After Width: | Height: | Size: 664 B |
BIN
public/static/mobile/edit/img/t_word.png
Normal file
|
After Width: | Height: | Size: 556 B |
787
public/static/mobile/edit/js/common.js
Normal file
@@ -0,0 +1,787 @@
|
||||
|
||||
$(function(){
|
||||
|
||||
//
|
||||
//
|
||||
$(document).on("pageInit", "#page-upimages", function(e, pageId, $page) {
|
||||
|
||||
var Options = {
|
||||
width : 300,
|
||||
height : 300,
|
||||
cutWidth : 300,
|
||||
cutHeight : 300,
|
||||
cutMinSize : 50,//裁剪框最小尺寸,即最小可以缩放到这个size,width及height任意一个都无法小于这个值。
|
||||
|
||||
//--系统自带,运行时自动运算,请不要修改。
|
||||
cropViewWidth : 0,//在画布里面显示的最大宽度
|
||||
cropViewHeight : 0,//在画布里面显示的最大高度
|
||||
cropLeft : 0,
|
||||
cropTop : 0,
|
||||
//--裁剪框
|
||||
cutViewWidth : 0, //当前宽度,
|
||||
cutViewHeight : 0,//当前高度
|
||||
cutMaxWidth : 0, //裁剪框最大宽度。
|
||||
cutMaxHeight : 0,//裁剪框最大高度。
|
||||
//--四象限。用于判断距离。
|
||||
cutBoxLimitX1 : 0,
|
||||
cutBoxLimitX2 : 0,
|
||||
cutBoxLimitY1 : 0,
|
||||
cutBoxLimitY2 : 0,
|
||||
cutLeft : 0,//裁剪框绝对定位,左侧距离。
|
||||
cutTop : 0,//裁剪框绝对定位,离顶部距离。
|
||||
initStatus : false
|
||||
//当前组件是否已经初始化了。
|
||||
};
|
||||
var Options_image = {
|
||||
width : 0,
|
||||
height : 0,
|
||||
imgData : ""
|
||||
}
|
||||
|
||||
var input_browseFile = document.getElementById("browseFile");
|
||||
var img_preview = document.getElementById("imgPreview");
|
||||
var cutBox = document.getElementById("cutBox");
|
||||
var tipBox = document.getElementById("tipBox");
|
||||
var _cropper = document.getElementById("cropper");
|
||||
var mainCutter = document.getElementById("mainCutter");
|
||||
var tips2 = $("#tips2");
|
||||
var wrapper = document.getElementById("wrapper");
|
||||
var component_box = document.getElementById("component_box");
|
||||
|
||||
var ctx = _cropper.getContext('2d');//ctx.drawImage(myImage, 50, 50);
|
||||
|
||||
function previewInImage(file) {
|
||||
//通过file.size可以取得图片大小
|
||||
var reader = new FileReader();
|
||||
LoadingImage();
|
||||
|
||||
reader.onload = function(evt) {
|
||||
img_preview.src = evt.target.result;
|
||||
}
|
||||
Options_image.imgData = reader.readAsDataURL(file);
|
||||
}
|
||||
img_preview.onload = function() {
|
||||
Options_image.width = img_preview.width;
|
||||
Options_image.height = img_preview.height;
|
||||
_initCropAndCut();
|
||||
}
|
||||
function LoadingImage() {
|
||||
$(img_preview).css({
|
||||
"width" : "",
|
||||
"height" : ""
|
||||
});
|
||||
}
|
||||
function _initCropAndCut() {
|
||||
//--计算比例,将其放到canvas里面。
|
||||
|
||||
var scale = Math.max(Options_image.width / Options.width,
|
||||
Options_image.height / Options.height);
|
||||
if (scale > 1) {
|
||||
Options.cropViewWidth = parseInt(Math.floor(Options_image.width
|
||||
/ scale));
|
||||
Options.cropViewHeight = parseInt(Math.floor(Options_image.height
|
||||
/ scale));
|
||||
} else {
|
||||
Options.cropViewWidth = Options_image.width;
|
||||
Options.cropViewHeight = Options_image.height;
|
||||
}
|
||||
//--计算画布里面的图像的位置。
|
||||
Options.cropLeft = parseInt((Options.width - Options.cropViewWidth) / 2);
|
||||
Options.cropTop = parseInt((Options.height - Options.cropViewHeight) / 2);
|
||||
//--计算裁剪框实际大小及实际位置。
|
||||
//计算裁剪框的位置。
|
||||
|
||||
var scale_2 = Math.max(Options.cutWidth / Options.cropViewWidth,
|
||||
Options.cutHeight / Options.cropViewHeight);
|
||||
if (scale_2 > 1) {
|
||||
Options.cutViewWidth = parseInt(Math.floor(Options.cutWidth
|
||||
/ scale_2));
|
||||
Options.cutViewHeight = parseInt(Math.floor(Options.cutHeight
|
||||
/ scale_2));
|
||||
} else {
|
||||
Options.cutViewHeight = Options.cutHeight;
|
||||
Options.cutViewWidth = Options.cutWidth;
|
||||
}
|
||||
Options.cutMaxWidth = Options.cutViewWidth;
|
||||
Options.cutMaxHeight = Options.cutViewHeight;
|
||||
|
||||
Options.cutLeft = parseInt(Math
|
||||
.floor((Options.cropViewWidth - Options.cutViewWidth)) / 2);
|
||||
Options.cutTop = parseInt(Math
|
||||
.floor((Options.cropViewHeight - Options.cutViewHeight)) / 2);
|
||||
//-四象限。
|
||||
Options.cutBoxLimitX1 = 0;
|
||||
Options.cutBoxLimitX2 = Options.cropViewWidth;
|
||||
Options.cutBoxLimitY1 = 0;
|
||||
Options.cutBoxLimitY2 = Options.cropViewHeight;
|
||||
|
||||
//获取x、y坐标!!!
|
||||
$("#x").val(Options.cutLeft);
|
||||
$("#y").val(Options.cutTop);
|
||||
//获取图片长宽!!!
|
||||
$("#h").val(Options.cropViewHeight);
|
||||
$("#w").val(Options.cropViewWidth);
|
||||
//获取剪切框长宽!!!
|
||||
$("#hh").val(Options.cutViewHeight);
|
||||
$("#ww").val(Options.cutViewWidth);
|
||||
//获取图片实际长宽!!!
|
||||
$("#imgh").val(Options.cutViewHeight);
|
||||
$("#imgw").val(Options.cutViewWidth);
|
||||
$("#scale").val(scale);
|
||||
|
||||
$(cutBox).css({
|
||||
"display" : "block",
|
||||
"width" : Options.cutViewWidth + "px",
|
||||
"height" : Options.cutViewHeight + "px",
|
||||
"left" : Options.cutLeft + "px",
|
||||
"top" : Options.cutTop + "px"
|
||||
});
|
||||
//$(cutBox).css({"display":"block","left":Options.cutLeft+"px","top":Options.cutTop+"px"});
|
||||
$(img_preview).css({
|
||||
"width" : Options.cropViewWidth + "px",
|
||||
"height" : Options.cropViewHeight + "px"
|
||||
});
|
||||
$(mainCutter).css({
|
||||
"display" : "block",
|
||||
"width" : Options.cropViewWidth + "px",
|
||||
"height" : Options.cropViewHeight + "px",
|
||||
"left" : Options.cropLeft + "px",
|
||||
"top" : Options.cropTop + "px"
|
||||
});
|
||||
//ctx.drawImage(img_preview,Options.cropLeft,Options.cropTop,Options.cropViewWidth,Options.cropViewHeight);
|
||||
//ctx.drawImage(img_preview, 0, 0, Options_image.width,Options_image.height, Options.cropLeft, Options.cropTop, Options.cropViewWidth, Options.cropViewHeight );
|
||||
|
||||
Options.initStatus = true;
|
||||
Options_process.initStatus = true;
|
||||
Options_process.percent = 100;
|
||||
Options_process.pointX = Options_process.barWidth;
|
||||
_resizeProcessBar();
|
||||
}
|
||||
|
||||
input_browseFile.addEventListener("change", function() {
|
||||
//通过 this.files 取到 FileList ,这里只有一个
|
||||
previewInImage(this.files[0]);
|
||||
|
||||
$.popup('.popup-caiface');
|
||||
|
||||
}, false);
|
||||
//--添加缩放功能。
|
||||
Options_zoom = {
|
||||
beginX1 : 0,
|
||||
beginY1 : 0,
|
||||
beginX2 : 0,
|
||||
beginY2 : 0,
|
||||
endX1 : 0,
|
||||
endY1 : 0,
|
||||
endX2 : 0,
|
||||
endY2 : 0
|
||||
};
|
||||
//--添加裁剪框移动功能
|
||||
Options_move = {
|
||||
beginX1 : 0,
|
||||
beginY1 : 0,
|
||||
endX1 : 0,
|
||||
endY1 : 0
|
||||
};
|
||||
|
||||
/**
|
||||
* 拖动裁剪框的逻辑处理。
|
||||
* */
|
||||
cutBox.addEventListener("touchstart", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
Options_move = {
|
||||
beginX1 : 0,
|
||||
beginY1 : 0,
|
||||
endX1 : 0,
|
||||
endY1 : 0
|
||||
};
|
||||
var beginX = event.changedTouches[0].pageX;
|
||||
var beginY = event.changedTouches[0].pageY;
|
||||
Options_move.beginX1 = beginX;
|
||||
Options_move.beginY1 = beginY;
|
||||
|
||||
}, false);
|
||||
cutBox.addEventListener("touchmove", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
//--
|
||||
var beginX = event.changedTouches[0].pageX;
|
||||
var beginY = event.changedTouches[0].pageY;
|
||||
Options_move.endX1 = beginX;
|
||||
Options_move.endY1 = beginY;
|
||||
//--计算是否发生位移,根据位移来定位裁剪框位置。
|
||||
//位移量。
|
||||
var _d_x = Options_move.endX1 - Options_move.beginX1;
|
||||
var _d_y = Options_move.endY1 - Options_move.beginY1;
|
||||
//--当前裁剪框原始位置。
|
||||
var _new_x = Options.cutLeft;
|
||||
var _new_y = Options.cutTop;
|
||||
_new_x += _d_x;
|
||||
_new_y += _d_y;
|
||||
//--判断是否在矩形边框,假如超出去,那么就取最终点。
|
||||
//--注意,判断相关点的范围。
|
||||
|
||||
if (_new_x < Options.cutBoxLimitX1) {
|
||||
_new_x = Options.cutBoxLimitX1;
|
||||
} else if (_new_x > Options.cutBoxLimitX2) {
|
||||
_new_x = Options.cutBoxLimitX2;
|
||||
}
|
||||
//--顺便判断,加上宽度后,是否超过了范围。
|
||||
if ((_new_x + Options.cutViewWidth) > Options.cutBoxLimitX2) {
|
||||
_new_x = Options.cutBoxLimitX2 - Options.cutViewWidth;
|
||||
}
|
||||
if (_new_y < Options.cutBoxLimitY1) {
|
||||
_new_y = Options.cutBoxLimitY1;
|
||||
} else if (_new_y > Options.cutBoxLimitY2) {
|
||||
_new_y = Options.cutBoxLimitY2;
|
||||
}
|
||||
//--顺便判断,加上裁剪框高度后,是否超过下限。
|
||||
if ((_new_y + Options.cutViewHeight) > Options.cutBoxLimitY2) {
|
||||
_new_y = Options.cutBoxLimitY2 - Options.cutViewHeight;
|
||||
}
|
||||
|
||||
//获取x、y坐标!!!
|
||||
$("#x").val(_new_x);
|
||||
$("#y").val(_new_y);
|
||||
|
||||
Options.cutLeft = _new_x;
|
||||
Options.cutTop = _new_y;
|
||||
_resizeCutBox();
|
||||
//---将这一点的放回前一点。
|
||||
Options_move.beginX1 = Options_move.endX1;
|
||||
Options_move.beginY1 = Options_move.endY1;
|
||||
|
||||
}, false);
|
||||
cutBox.addEventListener("touchend", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
return;
|
||||
|
||||
}, false);
|
||||
/**
|
||||
* 根据相关参数重新resize裁剪框
|
||||
* */
|
||||
function _resizeCutBox() {
|
||||
|
||||
//$(cutBox).css({"left":Options.cutLeft+"px","top":Options.cutTop+"px"});
|
||||
$(cutBox).css({
|
||||
"width" : Options.cutViewWidth + "px",
|
||||
"height" : Options.cutViewHeight + "px",
|
||||
"left" : Options.cutLeft + "px",
|
||||
"top" : Options.cutTop + "px"
|
||||
});
|
||||
}
|
||||
function _getCutImageData() {
|
||||
var output = document.createElement("canvas");
|
||||
//--坐标换算。
|
||||
var scale_x = Options_image.width / Options.cropViewWidth;
|
||||
var scale_y = Options_image.height / Options.cropViewHeight;
|
||||
var _o_x = parseInt((scale_x) * Options.cutLeft);
|
||||
var _o_y = parseInt((scale_y) * Options.cutTop);
|
||||
//--长度换算
|
||||
var _o_width = parseInt(scale_x * Options.cutViewWidth);
|
||||
var _o_height = parseInt(scale_y * Options.cutViewHeight);
|
||||
|
||||
output.width = Options.cutWidth;
|
||||
output.height = Options.cutHeight;
|
||||
output.getContext("2d").drawImage(img_preview, _o_x, _o_y, _o_width,
|
||||
_o_height, 0, 0, output.width, output.height);
|
||||
return output.toDataURL("image/jpeg");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 图片剪切提交方法
|
||||
*/
|
||||
function saveImage() {
|
||||
var imgData = _getCutImageData();
|
||||
var img=imgData.substr(23, imgData.length);
|
||||
$.post(url+'Img/index',{img:img},function(r){
|
||||
if(r){
|
||||
$.hidePreloader();
|
||||
xface=r;
|
||||
$.closeModal();
|
||||
history.go(-1);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
/**
|
||||
* processBar 进度条相关操作。
|
||||
* */
|
||||
|
||||
Options_process = {
|
||||
beginX : 0,//触摸时候起始点
|
||||
beginY : 0,//触摸时候起始点
|
||||
endX : 0,//触摸时候终点
|
||||
endY : 0,//触摸时候终点
|
||||
barWidth : 280,//进度条长度
|
||||
pointX : 0,//当前指示点位置
|
||||
pointY : 0,
|
||||
percent : 0,//百分比值。
|
||||
initStatus : false
|
||||
};
|
||||
var processBar = document.getElementById("processBar");
|
||||
var processPoint = document.getElementById("processPoint");
|
||||
|
||||
//--添加触屏事件,监控相关动作。
|
||||
//开始触摸
|
||||
processBar.addEventListener("touchstart", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (!Options_process.initStatus) {
|
||||
return;
|
||||
}
|
||||
var beginX = event.changedTouches[0].pageX;
|
||||
var beginY = event.changedTouches[0].pageY;
|
||||
Options_process.beginX = beginX;
|
||||
Options_process.beginY = beginY;
|
||||
}, false);
|
||||
//--移动中
|
||||
processBar.addEventListener("touchmove", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (!Options_process.initStatus) {
|
||||
return;
|
||||
}
|
||||
var beginX = event.changedTouches[0].pageX;
|
||||
var beginY = event.changedTouches[0].pageY;
|
||||
Options_process.endX = beginX;
|
||||
Options_process.endY = beginY;
|
||||
//--计算比分比。
|
||||
var _d_x = Options_process.endX - Options_process.beginX;
|
||||
Options_process.percent += parseInt(_d_x * 100/Options_process.barWidth);
|
||||
if (Options_process.percent < 0) {
|
||||
Options_process.percent = 0;
|
||||
} else if (Options_process.percent > 100) {
|
||||
Options_process.percent = 100;
|
||||
}
|
||||
//--计算那个指示点位置。
|
||||
Options_process.pointX = parseInt(Options_process.barWidth
|
||||
* (Options_process.percent / 100));
|
||||
_resizeProcessBar();
|
||||
//--根据百分比,设置裁剪框大小。
|
||||
var _o_cut_x = Options.cutLeft;
|
||||
var _o_cut_y = Options.cutTop;
|
||||
var _o_cut_width = Options.cutViewWidth;
|
||||
var _new_cut_width = parseInt(Options.cutMaxWidth
|
||||
* (Options_process.percent / 100));
|
||||
var _new_cut_height = parseInt(Options.cutMaxHeight
|
||||
* (Options_process.percent / 100));
|
||||
|
||||
//最小裁剪框尺寸
|
||||
var cutMinSize = Options.cutMinSize;
|
||||
if (_new_cut_width < cutMinSize) {
|
||||
_new_cut_width = _new_cut_height = cutMinSize;
|
||||
}
|
||||
|
||||
if (_new_cut_width > _o_cut_width) {
|
||||
//--扩大了。
|
||||
//--计算当前坐标
|
||||
var _d_x_2 = _new_cut_width - Options.cutViewWidth;
|
||||
var _d_y_2 = _new_cut_height - Options.cutViewHeight;
|
||||
|
||||
Options.cutLeft = Options.cutLeft - parseInt(_d_x_2 / 2);
|
||||
Options.cutTop = Options.cutTop - parseInt(_d_y_2 / 2);
|
||||
Options.cutViewWidth = _new_cut_width;
|
||||
Options.cutViewHeight = _new_cut_height;
|
||||
_resizeCutBox();
|
||||
|
||||
} else if (_new_cut_width < _o_cut_width) {
|
||||
//--缩小了。
|
||||
var _d_x_2 = Options.cutViewWidth - _new_cut_width;
|
||||
var _d_y_2 = Options.cutViewHeight - _new_cut_height;
|
||||
Options.cutLeft = Options.cutLeft + parseInt(_d_x_2 / 2);
|
||||
Options.cutTop = Options.cutTop + parseInt(_d_y_2 / 2);
|
||||
Options.cutViewWidth = _new_cut_width;
|
||||
Options.cutViewHeight = _new_cut_height;
|
||||
_resizeCutBox();
|
||||
|
||||
}
|
||||
|
||||
//获取剪切框长宽!!!
|
||||
$("#hh").val(_new_cut_height);
|
||||
$("#ww").val(_new_cut_width);
|
||||
|
||||
//--后续处理。
|
||||
Options_process.beginX = Options_process.endX;
|
||||
Options_process.endY = Options_process.endY;
|
||||
|
||||
}, false);
|
||||
//--结束
|
||||
processBar.addEventListener("touchend", function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
if (!Options_process.initStatus) {
|
||||
return;
|
||||
}
|
||||
}, false);
|
||||
|
||||
function _resizeProcessBar() {
|
||||
var lefe_x = Options_process.pointX;
|
||||
var left_w = parseInt(lefe_x + 5)
|
||||
$(processPoint).css("left", lefe_x + "px");
|
||||
$("#leftBar").css("width", left_w + "px");
|
||||
}
|
||||
|
||||
$("#saveimg").click(function() {
|
||||
if (Options.initStatus == false) {
|
||||
alert("请先选择图片!");
|
||||
return;
|
||||
}
|
||||
$.showPreloader('上传中...');
|
||||
saveImage();
|
||||
});
|
||||
|
||||
|
||||
//
|
||||
})
|
||||
|
||||
|
||||
|
||||
//设置
|
||||
|
||||
$(document).on("pageInit", "#page-set", function(e, pageId, $page) {
|
||||
if(xface){
|
||||
$('.uface_img').attr('src',imgUrl+'face/'+xface);
|
||||
}
|
||||
//
|
||||
//
|
||||
var liclick;
|
||||
$('.list-block .item-link').click(function(){
|
||||
|
||||
liclick=$(this);
|
||||
var t=liclick.attr('pid');
|
||||
if(t!=''){
|
||||
|
||||
$.popup('.popup-'+t);
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
//
|
||||
$('.pull-right').click(function(){
|
||||
|
||||
var n=$(this).attr('pid');
|
||||
var v=$('input[name='+n+']').val();
|
||||
if(v==''){
|
||||
|
||||
$.toast('该项不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
$.post(url+'UserSet/info',{name:n,val:v},function(r){
|
||||
|
||||
if(r){
|
||||
|
||||
$.toast('修改成功');
|
||||
liclick.children().children('.item-after').html(v);
|
||||
|
||||
if(n=='name'){
|
||||
xname=v;
|
||||
}
|
||||
$('input[name='+n+']').val(v);
|
||||
$.closeModal();
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
$('.ewm').click(function(){
|
||||
document.querySelector('#file').addEventListener('change', function () {
|
||||
lrz(this.files[0])
|
||||
.then(function (rst) {
|
||||
|
||||
$.post(url+'Img/ewm',{img:rst.base64},function(r){
|
||||
|
||||
$('.ewm').html('<img src=\"'+imgUrl+'wxewm/'+r+'\">');
|
||||
})
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
//
|
||||
$("#city-picker").cityPicker({
|
||||
toolbarTemplate: '<header class="bar bar-nav">\
|
||||
<button class="button button-link pull-right close-picker">确定</button>\
|
||||
<h1 class="title">选择城市</h1>\
|
||||
</header>'
|
||||
});
|
||||
//
|
||||
$('#savepwd').click(function(){
|
||||
|
||||
var opwd=$('input[name=opwd]').val();
|
||||
var npwd=$('input[name=npwd]').val();
|
||||
var npwd2=$('input[name=npwd2]').val();
|
||||
if(opwd==''){
|
||||
$.toast('旧密码不能为空');
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
if(npwd==''){
|
||||
|
||||
$.toast('新密码不能为空');
|
||||
return false;
|
||||
|
||||
}
|
||||
if(npwd.length<6){
|
||||
$.toast('新密码不能小于6位');
|
||||
return false;
|
||||
|
||||
}
|
||||
if(npwd2==''){
|
||||
|
||||
$.toast('确认密码不能为空');
|
||||
return false;
|
||||
}
|
||||
if(npwd2!=npwd){
|
||||
$.toast('两次密码输入不一致');
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
$.post(url+'UserSet/pwd',{opwd:opwd,npwd:npwd},function(r){
|
||||
if(r.s){
|
||||
$.toast('密码修改成功,请牢记!');
|
||||
$('input[name=opwd]').val('');
|
||||
$('input[name=npwd]').val('');
|
||||
$('input[name=npwd2]').val('');
|
||||
setTimeout(function() {
|
||||
$.closeModal();
|
||||
}, 2000);
|
||||
}else{
|
||||
|
||||
$.toast(r.info);
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
|
||||
//
|
||||
$('.close').click(function(){
|
||||
|
||||
$.get(url+'/Login/close',function(r){
|
||||
|
||||
location.href= url+'Index/login';
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
// 发布文章
|
||||
$(document).on("pageInit", "#page-wzadd", function(e, pageId, $page) {
|
||||
colseimg();
|
||||
var on=Get('on');
|
||||
item=false;
|
||||
var winwidth=$(document).width();
|
||||
$('.fixedDiv').css({width:winwidth+"px",marginLeft:-winwidth/2+"px"});
|
||||
file();
|
||||
/* 文章设置 */
|
||||
$('#wzadd').click(function(){
|
||||
$.popup('.popup-set');
|
||||
})
|
||||
/* 直接插入文字 */
|
||||
$('#addword').click(function(){
|
||||
|
||||
word(1);
|
||||
})
|
||||
/* 插入文字面板 */
|
||||
$('.tinsert_hl ul li').click(function(){
|
||||
|
||||
var pid=$(this).attr('pid');
|
||||
textsub(parseInt(pid));
|
||||
})
|
||||
/* 插入文字面板清空 */
|
||||
$('.text_reset').click(function(){
|
||||
textsub(0);
|
||||
})
|
||||
// 取消插入或者修改文字
|
||||
$('.boxNo').click(function(){
|
||||
var pid=$(this).attr('pid');
|
||||
hidebox(pid);
|
||||
})
|
||||
//提交插入或者修改文字
|
||||
$('.boxYes').click(function(){
|
||||
instrd(parseInt($(this).attr('pid')))
|
||||
})
|
||||
// 颜色 背景颜色 字体大小
|
||||
$('.bgcolor ul li,.color ul li,.check_size ul li').click(function(){
|
||||
textstyle(parseInt($(this).parent('ul').attr('pid')),$(this));
|
||||
})
|
||||
|
||||
|
||||
//清空
|
||||
$('.text_tit_r').click(function(){
|
||||
|
||||
var i=$(this).attr('pid');
|
||||
|
||||
if(i==1){
|
||||
$('.text_word').css('color','');
|
||||
$('.text_color').hide();
|
||||
}else{
|
||||
|
||||
$('.text_word').css('background','');
|
||||
$('.text_bgcolor').hide();
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
$('#addimg').click(function(){
|
||||
$('.text_img').show();
|
||||
$('.mask').show();
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
$('#wzcon').on("click",'a,span,div,em,p,img,section,fieldset,table,td,tr',function(){
|
||||
if(item){
|
||||
return false;
|
||||
}
|
||||
item=$(this);
|
||||
//调操作面板
|
||||
showpanel();
|
||||
var a1=item.height()+item.position().top+$('.tedit_tool').height()+$('nav').height()+10;
|
||||
var a2=$(window).height()-$('header').height();
|
||||
var a3=$('#wzcon').position().top;
|
||||
if(a1>a2){
|
||||
$('.content').scrollTop(-(a3-(a1-a2)));
|
||||
}
|
||||
|
||||
return false;
|
||||
})//*****点击处理 end!
|
||||
$('#wzcon').on('click','.t_link',function(){
|
||||
var pid=$(this).attr('pid');
|
||||
panelclick(pid);
|
||||
|
||||
})
|
||||
//
|
||||
$('#wxstyle').click(function(){
|
||||
if(($('#wxcon').html()=='')){
|
||||
$.get("/ajax/modelstyle",function(data){
|
||||
var str='';
|
||||
if(data.code==1){
|
||||
$('#wxcon').html(data.msg);
|
||||
}
|
||||
});
|
||||
};
|
||||
$.popup('.popup-style');
|
||||
});
|
||||
//
|
||||
//
|
||||
$('#wxcon').on("click",'.card',function(){
|
||||
var str=$(this).children().children('.card-content-inner').html();
|
||||
$('#wzcon').append(str);
|
||||
$.closeModal();
|
||||
})
|
||||
//
|
||||
|
||||
$('#addvideo').click(function(){
|
||||
$('.text_video').show();
|
||||
$('.mask').show();
|
||||
})
|
||||
//
|
||||
var addbtn=false;
|
||||
$('#fbtext').click(function(){
|
||||
var content=$('#wzcon').html();
|
||||
var title=$('input[name=title]').val();
|
||||
var jianjie=$('.jianjie').val();
|
||||
var imgsrc=$('.lstimg img').attr('pid');
|
||||
var imgthumb=$('.lstimg img').attr('src');
|
||||
if(content.length<255){
|
||||
$.toast('您未填写内容,或者内容不足一篇文章');
|
||||
return false;
|
||||
}
|
||||
// if(title==''||jianjie==''){
|
||||
if(1){
|
||||
addbtn=true;
|
||||
$.toast('请先设置文章信息');
|
||||
setTimeout(function(){
|
||||
$.popup('.popup-set');
|
||||
},1600)
|
||||
}else{
|
||||
addwz(title,jianjie,imgsrc,imgthumb,content);
|
||||
}
|
||||
})
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
//上传略缩图
|
||||
//
|
||||
$('.lstbox').click(function(){
|
||||
$('.text_img').show();
|
||||
$('.mask').show();
|
||||
thumb=true;
|
||||
})
|
||||
//
|
||||
//
|
||||
//
|
||||
$('#addbtn').click(function(){
|
||||
var title=$('input[name=title]').val();
|
||||
var jianjie=$('.jianjie').val();
|
||||
var imgsrc=$('.lstimg img').attr('pid');
|
||||
var imgthumb=$('.lstimg img').attr('src');
|
||||
if(title==''){
|
||||
$.toast('文章标题不能为空');
|
||||
return false;
|
||||
}
|
||||
if(jianjie==''){
|
||||
$.toast('文章简介不能为空');
|
||||
return false;
|
||||
}
|
||||
// if(imgsrc==undefined){
|
||||
// $.toast('文章略缩图不能为空');
|
||||
// return false;
|
||||
// }
|
||||
if(addbtn){
|
||||
addwz(title,jianjie,imgsrc,imgthumb,$('#wzcon').html());
|
||||
$.showPreloader('正在发布,请稍后...')
|
||||
}else{
|
||||
$.closeModal();
|
||||
}
|
||||
|
||||
})
|
||||
//
|
||||
function addwz(a,b,c,d,e){
|
||||
var editid=$("#editid").val();
|
||||
var url='/Article/edit';
|
||||
if(editid=="0"){
|
||||
url='/Article/add';
|
||||
}
|
||||
$.post(url,{title:a,description:b,storage_id:c,thumb:d,content:e,id:editid},function(r){
|
||||
$.hidePreloader();
|
||||
if(r['code']==1){
|
||||
$.closeModal();
|
||||
$.alert('发布成功',function(){
|
||||
location.href=r['url'];
|
||||
})
|
||||
}else{
|
||||
$.toast(r['msg']);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
$.init();
|
||||
})
|
||||
|
||||
|
||||
822
public/static/mobile/edit/js/function.js
Normal file
@@ -0,0 +1,822 @@
|
||||
// 公共函数
|
||||
var url='http://m.zhixiaodaren.cn/index.php/';
|
||||
var web='http://m.zhixiaodaren.cn/';
|
||||
var imgUrl='/uploads/';
|
||||
var fxurl='http://fx.dyunkeji.com/index.php/Index/index/id/';
|
||||
var item=false,xg=false;
|
||||
var page=2;
|
||||
var loading=false;
|
||||
var msgs=true;
|
||||
var upimgurl='';
|
||||
var imgfun='';
|
||||
var xface=false,xname=false,thumb=false,guanzhu=false;
|
||||
|
||||
|
||||
//非vip提示
|
||||
function novip(s){
|
||||
$.confirm('您非VIP会员,'+s+'</br>立即开通VIP,享受更多功能特权!', '功能操作受限', function () {
|
||||
location.href=url+'User/vip.html';
|
||||
});
|
||||
}
|
||||
|
||||
function getTime(i)
|
||||
{
|
||||
var now=new Date(i*1000);
|
||||
var year=now.getFullYear();
|
||||
var month=now.getMonth()+1;
|
||||
var date=now.getDate();
|
||||
var hour=now.getHours();
|
||||
var minute=now.getMinutes();
|
||||
var second=now.getSeconds();
|
||||
return year+"-"+add0(month)+"-"+add0(date);
|
||||
}
|
||||
|
||||
function add0(a){
|
||||
var a=a.toString();
|
||||
if(a.length<2){
|
||||
|
||||
return '0'+a;
|
||||
}else{
|
||||
return a;
|
||||
}
|
||||
|
||||
}
|
||||
function Get(name)
|
||||
{
|
||||
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
if(r!=null)return unescape(r[2]); return null;
|
||||
}
|
||||
|
||||
//分享
|
||||
function wxShare(a){
|
||||
wx.onMenuShareTimeline(a);
|
||||
wx.onMenuShareAppMessage(a);
|
||||
wx.onMenuShareQQ(a);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// 文字编辑面板
|
||||
function word(e){
|
||||
var m=$('.text_insert');
|
||||
var s=$('.text_word');
|
||||
if(e==2){
|
||||
xg=true;
|
||||
s.val(item.text());
|
||||
s.attr('style',item.attr('style'));
|
||||
}else{
|
||||
s.val('');
|
||||
s.removeAttr('style');
|
||||
}
|
||||
m.show();
|
||||
$('.mask').show();
|
||||
|
||||
}
|
||||
//文字编辑面板 子面板
|
||||
function textsub(e){
|
||||
var m=$('.text_word');
|
||||
switch(e){
|
||||
case 1:
|
||||
if(m.css('font-weight')=="bold"){
|
||||
m.css('font-weight','');
|
||||
}else{
|
||||
m.css('font-weight','bold');
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$('.text_color').show();
|
||||
break;
|
||||
case 3:
|
||||
$('.text_bgcolor').show();
|
||||
break;
|
||||
case 4:
|
||||
$('.text_size').show();
|
||||
break;
|
||||
case 5:
|
||||
m.css('textAlign','left');
|
||||
break;
|
||||
case 6:
|
||||
m.css('textAlign','center');
|
||||
break;
|
||||
case 7:
|
||||
m.css('textAlign','right');
|
||||
break;
|
||||
|
||||
default:
|
||||
m.val('');
|
||||
m.removeAttr('style');
|
||||
$('.nowcolor').css("background",'rgb(51, 51, 51)');
|
||||
}
|
||||
}
|
||||
//
|
||||
//
|
||||
//取消 输入框 或者video 输入
|
||||
|
||||
function hidebox(i){
|
||||
switch(parseInt(i)){
|
||||
case 1:
|
||||
$('.text_insert').hide();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$('.text_video').hide();
|
||||
|
||||
case 3:
|
||||
$('.text_url').hide();
|
||||
case 4:
|
||||
$('.text_title').hide();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
xg=false;
|
||||
$('.mask').hide();
|
||||
|
||||
}
|
||||
//
|
||||
// 文字编辑面板 子面板 事件
|
||||
function textstyle(i,t){
|
||||
|
||||
switch(i){
|
||||
case 1:
|
||||
$('.text_word').css('background',t.children('span').css('backgroundColor'));
|
||||
$('.text_bgcolor').hide();
|
||||
break;
|
||||
case 2:
|
||||
var c=t.children('span').css('backgroundColor');
|
||||
$('.text_word').css('color',c);
|
||||
$('.nowcolor').css("background",c);
|
||||
$('.text_color').hide();
|
||||
break;
|
||||
case 3:
|
||||
$('.text_word').css('fontSize',t.html());
|
||||
$('.text_size').hide();
|
||||
break;
|
||||
case 4:
|
||||
$('.text_word').removeAttr('style').val('');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function cler(){
|
||||
item.removeClass('eing');
|
||||
item=false;
|
||||
$('#selp').remove();
|
||||
}
|
||||
//
|
||||
// 提交或者插入视频 插入链接
|
||||
function instrd(i){
|
||||
switch(i)
|
||||
{
|
||||
case 1: //插入文字
|
||||
var text=$('.text_word');
|
||||
var val=text.val();
|
||||
var sty=text.attr('style');
|
||||
if(typeof sty=='object')
|
||||
{
|
||||
var s='<p>'+val+'</p>';
|
||||
}
|
||||
else
|
||||
{
|
||||
var s='<p style="'+sty+'">'+val+'</p>';
|
||||
}
|
||||
if(xg){
|
||||
item.text(val);
|
||||
item.attr('style',sty);
|
||||
item.removeClass('eing');
|
||||
item=false;
|
||||
xg=false;
|
||||
}else{
|
||||
if(item){
|
||||
item.after(s);
|
||||
item.removeClass('eing');
|
||||
item=false;
|
||||
}else{
|
||||
$('#wzcon').append(s);
|
||||
}
|
||||
}
|
||||
$('.text_insert').hide();
|
||||
$('.mask').hide();
|
||||
$('#selp').remove();
|
||||
//
|
||||
//
|
||||
break;
|
||||
case 2: //插入视频
|
||||
//
|
||||
//
|
||||
var video=$('input[name=video]').val();
|
||||
|
||||
if(video==''){
|
||||
$.toast('视频地址不能为空');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(video.search(/v\.qq\.com/)<0){
|
||||
|
||||
$.toast('请输入有效的腾讯视频网址');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(video.search(/vid=/)>0){
|
||||
var v=video.substr(video.search(/vid=/)+4,11);
|
||||
}else{
|
||||
var v=video.substr(video.length-16,11);
|
||||
}
|
||||
var s='<p style="max-width:100%; margin:4px"><iframe frameborder="0" src="http://v.qq.com/iframe/player.html?vid='+v+'&auto=0" style="z-index: 1; width: 100% ! important; height: 231.75px ! important; overflow: hidden;" class="video_iframe" scrolling="no"></iframe></p>';
|
||||
if(item){
|
||||
item.after(s);
|
||||
item.removeClass('eing');
|
||||
item=false;
|
||||
$('#selp').remove();
|
||||
|
||||
}else{
|
||||
$('#wzcon').append(s);
|
||||
}
|
||||
$('input[name=video]').val('');
|
||||
$('.text_video').hide();
|
||||
$('.mask').hide();
|
||||
//
|
||||
//
|
||||
//
|
||||
break;
|
||||
|
||||
case 3: //插入链接
|
||||
//
|
||||
//
|
||||
var url=$('input[name=text_url]').val();
|
||||
if(url==''){
|
||||
$.toast('链接不能为空!');
|
||||
return false;
|
||||
}
|
||||
|
||||
if( url.match(/http:\/\/.+/)==null){
|
||||
$.toast('您输入的网址格式不正确');
|
||||
return false;
|
||||
}
|
||||
$('.text_url').hide();
|
||||
$('.mask').hide();
|
||||
|
||||
item.wrap('<a href=\"'+url+'\"></a>');
|
||||
item.removeClass('eing');
|
||||
|
||||
item=false;
|
||||
$('#selp').remove();
|
||||
$('input[name=text_url]').val('');
|
||||
//
|
||||
//
|
||||
//
|
||||
break;
|
||||
case 4:
|
||||
var str=$('.text_ct').val();
|
||||
if(str==''){
|
||||
$.toast('标题不能为空');
|
||||
return false;
|
||||
}
|
||||
$('#title').html(str);
|
||||
$('.text_title').hide();
|
||||
$('.mask').hide();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function showpanel(){
|
||||
|
||||
var panel=[{c:'t_word',t:'插文字'},{c:'t_text',t:'改文字'},{c:'t_image',t:'插图片'},{c:'t_video',t:'插视频'},{c:'t_add',t:'插链接'},{c:'t_del0',t:'删除前'},{c:'t_del0',t:'删除后'},{c:'t_del0',t:'删除'},{c:'t_cancel',t:'取消'}];
|
||||
var str='<div class="tedit_tool" id="selp"><ul>';
|
||||
for(var i=0;i<panel.length;i++){
|
||||
str+='<span class="t_link" pid=\"'+i+'\"><li class=\"'+panel[i].c+'\">'+panel[i].t+'</li></span>';
|
||||
}
|
||||
str+="</ul></div>";
|
||||
item.after(str).addClass('eing');
|
||||
|
||||
}
|
||||
|
||||
|
||||
function rq(){
|
||||
|
||||
var prev = item.prev();
|
||||
var i=item;
|
||||
|
||||
while (prev.length<0||prev.length==0&& !i.hasClass("content-inner")){
|
||||
i=i.parent();
|
||||
prev=i.prev();
|
||||
};
|
||||
|
||||
prev.remove();
|
||||
item.removeClass('eing');
|
||||
$('#selp').remove();
|
||||
item=false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function rh(){
|
||||
var i=$('#selp');
|
||||
var h=i.next();
|
||||
|
||||
while (h.length<0||h.length==0&& !i.hasClass("content-inner")){
|
||||
i=i.parent();
|
||||
h=i.next();
|
||||
}
|
||||
h.remove();
|
||||
item.removeClass('eing');
|
||||
$('#selp').remove();
|
||||
item=false;
|
||||
}
|
||||
//
|
||||
function colseimg(){
|
||||
|
||||
$('.text_img .tinsert_head .cosle').click(function(){
|
||||
$('.text_img').hide();
|
||||
$('.mask').hide();
|
||||
})
|
||||
}
|
||||
function file(){
|
||||
document.querySelector('#files').addEventListener('change', function () {
|
||||
$.showPreloader('图片上传中请稍候...');
|
||||
lrz(this.files[0])
|
||||
.then(function (rst) {
|
||||
var data = {
|
||||
base64: rst.base64,
|
||||
size: rst.base64.length
|
||||
};
|
||||
$.post('/upload/uploadPicture',{files:data},function(r){
|
||||
|
||||
$.hidePreloader();
|
||||
$('.text_img').hide();
|
||||
$('.mask').hide();
|
||||
if(item){
|
||||
item.after('<img src=\"'+r['data']['filename']+'\" width=\"100%\">');
|
||||
item.removeClass('eing');
|
||||
item=false;
|
||||
$('#selp').remove();
|
||||
}else{
|
||||
if(!thumb){
|
||||
$('#wzcon').append('<img src=\"'+r['data']['filename']+'\" width=\"100%\">');
|
||||
}else{
|
||||
$('#thumb').attr('src',r['data']['filename']);
|
||||
$('#thumb').attr('pid',r['data']['fileid']);
|
||||
thumb=false;
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
function panelclick(pid){
|
||||
|
||||
switch(parseInt(pid))
|
||||
{
|
||||
case 0:
|
||||
word(1);
|
||||
break;
|
||||
case 1:
|
||||
word(2);
|
||||
break;
|
||||
case 2:
|
||||
$('.text_img').show();
|
||||
$('.mask').show();
|
||||
break;
|
||||
case 3:
|
||||
$('.text_video').show();
|
||||
$('.mask').show();
|
||||
|
||||
break;
|
||||
case 4:
|
||||
$('.text_url').show();
|
||||
$('.mask').show();
|
||||
break;
|
||||
case 5:
|
||||
rq();
|
||||
|
||||
break;
|
||||
case 6:
|
||||
rh();
|
||||
break;
|
||||
case 7:
|
||||
item.remove();
|
||||
item=false;
|
||||
$('#selp').remove();
|
||||
break;
|
||||
case 8:
|
||||
item.removeClass('eing');
|
||||
$('#selp').remove();
|
||||
item=false;
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 采集或者发布文章列表
|
||||
function article(p,i,e){
|
||||
$.get(url+'UserGet/UserArticle',{p:p,on:i},function(r){
|
||||
|
||||
if(p==1&&r.length==0){
|
||||
e.html('<div class="null_icon">您还没有发布过哦!点击右上角加号开始添加</div>');
|
||||
return false;
|
||||
}
|
||||
var str='';
|
||||
|
||||
for (var i=0;i<r.length; i++) {
|
||||
str+='<div class="card">'+
|
||||
'<div class="card-content">'+
|
||||
'<div class="list-block media-list">'+
|
||||
'<ul>'+
|
||||
'<li class="item-content">'+
|
||||
'<div class="item-media">'+
|
||||
'<img src=\"'+wximg(r[i].img)+'\" style="width: 4rem;">'+
|
||||
'</div>'+
|
||||
'<div class="item-inner">'+
|
||||
'<div class="item-text">'+r[i].title+'</div>'+
|
||||
'<div class="item-title-row mt">'+
|
||||
'<div class="item-after">'+getTime(r[i].time)+'</div>'+
|
||||
'<div class="item-after">'+r[i].eye+'人浏览</div>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</li>'+
|
||||
'</ul>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="card-footer">'+
|
||||
'<a href=\"'+wze(2,r[i].id)+'\" class="link icon icon-search c1" external> 查看</a>'+
|
||||
'<a href=\"'+wze(1,r[i].id,r[i].on)+'\" class="link icon icon-edit c2"> 编辑</a>'+
|
||||
'<a href="javascript:void(0);" class="link icon icon-remove c3" pid=\"'+r[i].id+'\"> 删除</a>'+
|
||||
'</div>'+
|
||||
'</div>';
|
||||
}
|
||||
|
||||
if(p==1){
|
||||
e.html(str);
|
||||
|
||||
}else{
|
||||
if(r.length<10){
|
||||
$.detachInfiniteScroll($('.infinite-scroll'));
|
||||
|
||||
}else{
|
||||
page++;
|
||||
loading = false;
|
||||
}
|
||||
e.append(str);
|
||||
$.refreshScroller();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function wximg(src){
|
||||
|
||||
if(src==''){
|
||||
return web+'Public/icon/noimg.png';
|
||||
}else{
|
||||
return imgUrl+'wzimg/'+src;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function wze(i,id,on){
|
||||
|
||||
if(i==1){
|
||||
if(on==1){
|
||||
|
||||
return url+'User/caibian.html?&id='+id;
|
||||
}
|
||||
return url+'User/wzadd.html?on=0&id='+id;
|
||||
|
||||
}
|
||||
if(i==2){
|
||||
return url+'User/uact?id='+id;
|
||||
}
|
||||
|
||||
if(i==3){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//头像
|
||||
function uface(f){
|
||||
if(f==''){
|
||||
return '/Uploads/face/noface.png';
|
||||
}
|
||||
return '/Uploads/face/'+f;
|
||||
}
|
||||
// 获取经验
|
||||
function getjy(p,on,e){
|
||||
|
||||
$.get(url+'Jingyan/fen',{p:p,on:on},function(r){
|
||||
|
||||
if(p==1&&r.length==0){
|
||||
e.html('<div class="null_icon">空空地撒!</div>');
|
||||
$('.infinite-scroll-preloader').remove();
|
||||
return ;
|
||||
}
|
||||
|
||||
var str='';
|
||||
|
||||
for(var i=0;i<r.length;i++){
|
||||
|
||||
var v=r[i];
|
||||
str+='<li>'+
|
||||
'<div class="topbar">'+
|
||||
'<img src="'+uface(v.small)+'">'+
|
||||
'<div class="jy-u-info">'+
|
||||
'<p class="u-name">'+v.name+'</p>'+
|
||||
'<p class="time">'+getTime(v.time)+'</p>'+
|
||||
'</div>'+delbtn(on,v.id)+
|
||||
'</div>'+
|
||||
'<div class=\"jyurl\" pid=\"'+v.id+'\">'+
|
||||
'<div class="jy-con">'+getfaces(v.content)+'</div>'+jyimgs(v.img)+'<div class="groupbody">'+
|
||||
'<div class="icon-wrap">'+
|
||||
'<span class="liulan">'+v.eye+'</span>'+
|
||||
'<span class="ping">'+v.ping+'</span>'+
|
||||
'<span class="zan">'+v.agree+'</span>'+
|
||||
'</div>'+
|
||||
'</div></div>'+
|
||||
'</li>';
|
||||
}
|
||||
if(p==1){
|
||||
$.pullToRefreshDone('.pull-to-refresh-content');
|
||||
e.html(str);
|
||||
|
||||
if(r.length<10){
|
||||
loading=true;
|
||||
$('.infinite-scroll-preloader').remove();
|
||||
}else{
|
||||
page=2;
|
||||
loading=false;
|
||||
$('.infinite-scroll-preloader').html('<div class="preloader"></div>');
|
||||
|
||||
}
|
||||
}else{
|
||||
e.append(str);
|
||||
if(r.length<10){
|
||||
$('.infinite-scroll-preloader').html('没有更多了...');
|
||||
}else{
|
||||
loading=false;
|
||||
page++;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 删除自己的按钮
|
||||
function delbtn(on,id){
|
||||
|
||||
if(on==1){
|
||||
return '<span class=\"icon icon-remove\" pid=\"'+id+'\"> 删除</span>';
|
||||
}else{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 表情字符替换
|
||||
function getfaces(str){
|
||||
var reg = /\[([^\]]+)\]/g;
|
||||
return str.replace(reg,"<img src='/Public/images/$1.png'/>");
|
||||
|
||||
}
|
||||
// 经验图片
|
||||
function jyimgs(s){
|
||||
if(s==''){
|
||||
return '';
|
||||
}
|
||||
var ss = s.split(",");
|
||||
var str='<div class="jy-img row">';
|
||||
|
||||
if(ss.length>3){
|
||||
for(var i=0;i<3;i++){
|
||||
str+='<p class="jy-imgs col-33" style="background-image: url('+imgUrl+'/jy/'+ss[i]+');">'+imgcount(i,ss.length)+'</p>';
|
||||
}
|
||||
}else{
|
||||
for(var i=0;i<ss.length;i++){
|
||||
|
||||
str+='<p class="jy-imgs col-33" style="background-image: url('+imgUrl+'/jy/'+ss[i]+');"></p>';
|
||||
}
|
||||
|
||||
}
|
||||
return str+'</div>';
|
||||
}
|
||||
// 经验图片
|
||||
function jyimgs2(s){
|
||||
if(s==''){
|
||||
return '';
|
||||
}
|
||||
var ss = s.split(",");
|
||||
var str='<div class="img-box">';
|
||||
for(var i=0;i<ss.length;i++){
|
||||
|
||||
str+='<img src=\"'+imgUrl+'/jy/'+ss[i]+'\">';
|
||||
}
|
||||
|
||||
|
||||
return str+'</div>';
|
||||
}
|
||||
// 经验总图数
|
||||
function imgcount(a,b){
|
||||
if(a==2){
|
||||
return '<span class="total-img"><span class="total-img-text">'+b+'</span></span>'
|
||||
}else{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
// 选择表情
|
||||
function faces(i){
|
||||
|
||||
var str='微笑/撇嘴/色/发呆/得意/流泪/害羞/闭嘴/睡/大哭/尴尬/发怒/调皮/呲牙/惊讶/难过/酷/冷汗/抓狂/吐/偷笑/可爱/白眼/傲慢/饥饿/困/惊恐/流汗/憨笑/装逼/奋斗/咒骂/疑问/嘘/晕/折磨/衰/骷髅/敲打/再见/擦汗/抠鼻/鼓掌/糗大了/坏笑/左哼哼/右哼哼/哈欠/鄙视/委屈/快哭了/阴险/亲亲/吓/可怜/菜刀/西瓜/啤酒/篮球/乒乓/咖啡/饭/猪头/玫瑰/凋谢/示爱/爱心/心碎/蛋糕/闪电/炸弹/刀/足球/瓢虫/便便/月亮/太阳/礼物/拥抱/赞/踩/握手/胜利/抱拳/勾引/拳头/差劲/爱你/NO/OK/爱情/飞吻/跳跳/发抖/怄火/转圈/磕头/回头/跳绳/挥手';
|
||||
var f=str.split("/");
|
||||
if(f[i]!=undefined){
|
||||
return '['+f[i]+']';
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 经验图片
|
||||
function jyimgs3(s){
|
||||
if(s==''){
|
||||
return '';
|
||||
}
|
||||
var ss = s.split(",");
|
||||
|
||||
var str='<div class="img-box-container row">';
|
||||
for(var i=0;i<ss.length;i++){
|
||||
|
||||
str+='<div class="img-box col-50">'+
|
||||
'<img src=\"'+imgUrl+'/jy/'+ss[i]+'\">'+
|
||||
'</div>';
|
||||
}
|
||||
return str+'</div>';
|
||||
}
|
||||
|
||||
//经验 回复 多重回复
|
||||
function commentto(r){
|
||||
if(r==0||r==null)return '';
|
||||
(r.img !='') ? a='<span>[图片]</span>' : a='';
|
||||
return '<div class="ref-comment">'+
|
||||
'<span><span>'+r.name+'</span>: </span>'+
|
||||
a+
|
||||
'<span>'+getfaces(r.con)+'</span>'+
|
||||
'</div>';
|
||||
}
|
||||
|
||||
function comment(r,p){
|
||||
var com='';
|
||||
|
||||
for(var i=0;i<r.length;i++){
|
||||
var s=r[i];
|
||||
(s.isagree!=0)?liked='liked':liked='';
|
||||
(s.my!=0)?my='<span class=\"js-btn-action btn-action delete\" pid=\"'+s.id+'\">删除</span>':my='';
|
||||
com+='<li class="list section-1px">'+
|
||||
'<div class="comment-wrapper">'+
|
||||
'<div class="user-avatar">'+
|
||||
'<img src=\"'+imgUrl+'/face/'+s.small+'\">'+
|
||||
'</div>'+
|
||||
'<div class="name-wrap">'+
|
||||
'<div class="name-section1">'+
|
||||
'<span class="author user-nick">'+s.name+'</span>'+
|
||||
'<label class=\"l-level\">LV.'+s.total.i+'</label>'+
|
||||
'<label class="author-male"></label>'+
|
||||
'<span class="floor">'+s.floor+'楼</span>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'<div class="content-wrapper">'+
|
||||
'<div class="comment-con">'+getfaces(s.con)+'</div>'+
|
||||
jyimgs(s.img)+
|
||||
commentto(s.mid)+
|
||||
|
||||
'</div>'+
|
||||
'<div class="actions">'+
|
||||
'<span class="btn-action time">'+s.time+'</span>'+my+
|
||||
|
||||
'<span class=\"btn-action reply\" pid=\"'+s.id+'\"></span>'+
|
||||
'<span class=\"js-btn-action btn-action clike like '+liked+' \" pid=\"'+s.id+'\">'+s.agree+'</span>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</li>';
|
||||
}
|
||||
|
||||
|
||||
if(p==1){
|
||||
|
||||
|
||||
$('.lists').html(com);
|
||||
|
||||
}else if(p==2){
|
||||
|
||||
$('.lists').append(com);
|
||||
$('#noping').hide();
|
||||
$('#to_reply').text(parseInt($('#to_reply').text())+1);
|
||||
}else{
|
||||
|
||||
$('.lists').append(com);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//获取更多评论
|
||||
function commore(id,p){
|
||||
$.get(url+'Jingyan/commore',{id:id,p:p},function(r){
|
||||
if(r.length<10){
|
||||
$.detachInfiniteScroll($('.infinite-scroll'));
|
||||
$('.infinite-scroll-preloader').html('没有更多了');
|
||||
}else{
|
||||
page++;
|
||||
}
|
||||
comment(r,3);
|
||||
$.refreshScroller();
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//清空编辑器
|
||||
function clertbjq(){
|
||||
$('.addjy').hide();
|
||||
$('.pub-pics').hide();
|
||||
$('.pub-faces').hide();
|
||||
$('.pub-pics .up-pic').remove();
|
||||
$('.editor').val('');
|
||||
|
||||
}
|
||||
|
||||
function editorpanel(){
|
||||
//插入表情面板
|
||||
$('.pub-face').click(function(){
|
||||
|
||||
$('.pub-faces').show();
|
||||
$('.pub-pics').hide();
|
||||
$(".swiper-container").swiper();
|
||||
})
|
||||
|
||||
$('.pub-cancel').click(function(){
|
||||
|
||||
$('.addjy').hide();
|
||||
})
|
||||
|
||||
//插入图片
|
||||
$('#selectPic').click(function(){
|
||||
$(this).addClass('active');
|
||||
$('.pub-pics').show();
|
||||
$('.pub-faces').hide();
|
||||
})
|
||||
|
||||
//插入表情
|
||||
$('.face-panel span').click(function(){
|
||||
var str=faces($(this).attr('index'));
|
||||
if(str){
|
||||
$('.editor').val($('.editor').val()+str);
|
||||
}else{
|
||||
|
||||
var str=$('.editor').val();
|
||||
var a=str.substring(str.length-1);
|
||||
if(a==']'){
|
||||
var ab=str.lastIndexOf('[');
|
||||
$('.editor').val(str.substring(0,ab))
|
||||
}else{
|
||||
$('.editor').val(str.substring(0,str.length-1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
// 删除图片
|
||||
$('.pub-pics').on('click','.btn-del',function(){
|
||||
$(this).parent('li').remove();
|
||||
if($('.pub-pics').children('li').length<9){
|
||||
$('.up-entry').show();
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
function jyfile(){
|
||||
document.querySelector('#files').addEventListener('change', function () {
|
||||
$.showPreloader('图片上传中...');
|
||||
lrz(this.files[0])
|
||||
.then(function (rst) {
|
||||
|
||||
/**************************/
|
||||
$.post(url+'Img/jy',{img:rst.base64},function(r){
|
||||
$.hidePreloader();
|
||||
var str='<li class=\"up-pic up-over\" pid=\"'+r+'\">'+
|
||||
'<div class="clip">'+
|
||||
'<img src=\"'+web+'Uploads/jy/'+r+'\" style=\"width: 65px; height: 104px; display: block; margin-top: -19.5px;\">'+
|
||||
'</div>'+
|
||||
'<a class="btn-del" href="javascript:void(0)" title="关闭"> </a>'+
|
||||
'</li>';
|
||||
$('.up-entry').before(str);
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||