Authored by weiqingting

文件上传

... ... @@ -18,7 +18,7 @@ $("button").click(function(){
var $=require('jquery');
var Validator = require('../util/validate');
var file=require('./upload');
require('./upload');
require('../util/datepicker')($);
require('../util/jquery.gritter');
... ... @@ -146,22 +146,41 @@ edit.prototype={
}
/*初始化文件上传*/
// $(".fileinput-button-icon").each(function(){
// var id=$(this).attr("id");
// file({
// button:id,
// uptoken:$("#uptoken").val(),
// callback:function(src){
// var _img=$("#"+id).find("img");
// if(_img.length>0){
// _img.attr("src",src);
// }else{
// $("#"+id).prepend("<img width='76' height='80' src='"+src+"' />");
// }
// $("#"+id).find(":hidden").val(src);
// }
// });
// });
if($('input[type="file"]').length>0){
$('input[type="file"]').each(function(){
var Temp='<ul class="upload-image-list">';
Temp+='<li class="fileinput-button">';
Temp+='<a class="fileinput-button-icon" href="javascript:void(0);">';
if($(this).val()){
Temp+='<img width="76" height="80" src="'+$(this).val()+'">';
}else{
Temp+='+';
}
Temp+='</a>';
Temp+='</li>';
Temp+='</ul>';
$(this).after(Temp);
});
$('input[type="file"]').ajaxfileupload({
'action': '/ajax/upload',
'params':{"userId":543883,"bucket":'smart'},
'onComplete': function(response) {
var _w=$(this).next().find('.fileinput-button-icon');
if(_w.find('img').length>0){
_w.find('img').attr("src",response.data);
}else{
_w.prepend('<img width="76" height="80" src="'+response.data+'">');
}
},
'onStart': function() {
},
'onCancel': function() {
console.log('no file selected');
}
});
}
that.__listen("render");
},
bind:function(){
... ... @@ -257,6 +276,7 @@ edit.prototype={
$("input:text",that.el)//number
.add("input[type=number]",that.el)
.add("input:hidden",that.el)
.add("input[type=file]",that.el)
.add("select",that.el)
.add("textarea",that.el)
.each(function(){
... ...
var jQuery=require('jquery');
var $=require('jquery');
// var Qiniu=require("../util/qiniu");
$.fn.ajaxfileupload = function(options) {
var settings = {
params: {},
action: '',
onStart: function() { },
onComplete: function(response) { },
onCancel: function() { },
validate_extensions : true,
valid_extensions : ['gif','png','jpg','jpeg'],
submit_button : null
};
var uploader = function(option){
jQuery.extend({
createUploadIframe: function(id, uri){
//create frame
var frameId = 'jUploadFrame' + id;
var iframeHtml = '<iframe id="' + frameId + '" name="' + frameId + '" style="position:absolute; top:-9999px; left:-9999px"';
if(window.ActiveXObject){
if(jQuery.browser.version=="9.0" || jQuery.browser.version=="10.0"){
var io = document.createElement('iframe');
io.id = frameId;
io.name = frameId;
}else if(jQuery.browser.version=="6.0" || jQuery.browser.version=="7.0" || jQuery.browser.version=="8.0"){
var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
if(typeof uri== 'boolean'){
io.src = 'javascript:false';
} else if(typeof uri== 'string'){
io.src = uri;
}
}
var uploading_file = false;
if ( options ) {
$.extend( settings, options );
}
iframeHtml += ' />';
jQuery(iframeHtml).appendTo(document.body);
return jQuery('#' + frameId).get(0);
},
createUploadForm: function(id, fileElementId, data){
//create form
var formId = 'jUploadForm' + id;
var fileId = 'jUploadFile' + id;
var form = jQuery('<form action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
if(data){
for(var i in data){
jQuery('<input type="hidden" name="' + i + '" value="' + data[i] + '" />').appendTo(form);
return this.each(function() {
var $element = $(this);
if($element.data('ajaxUploader-setup') === true) return;
$element.change(function()
{
uploading_file = false;
if (settings.submit_button == null)
{
upload_file();
}
}
//single
if(typeof(fileElementId) == 'string'){
fileElementId = [fileElementId];
}
for(var i in fileElementId){
var oldElement = jQuery('#' + fileElementId[i]);
var newElement = jQuery(oldElement).clone();
jQuery(oldElement).attr('id', fileId);
jQuery(oldElement).attr('name', "image");
jQuery(oldElement).before(newElement);
jQuery(oldElement).appendTo(form);
}
//set attributes
jQuery(form).css('position', 'absolute');
jQuery(form).css('top', '-1200px');
jQuery(form).css('left', '-1200px');
jQuery(form).appendTo('body');
return form;
},
ajaxFileUpload: function(s) {
// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
s = jQuery.extend({}, jQuery.ajaxSettings, s);
var id = new Date().getTime()
var form = jQuery.createUploadForm(id, s.fileElementId, (typeof(s.data)=='undefined'?false:s.data));
var io = jQuery.createUploadIframe(id, s.secureuri);
var frameId = 'jUploadFrame' + id;
var formId = 'jUploadForm' + id;
// Watch for a new set of requests
if ( s.global && ! jQuery.active++ ){
jQuery.event.trigger( "ajaxStart" );
}
var requestDone = false;
// Create the request object
var xml = {};
if ( s.global )
jQuery.event.trigger("ajaxSend", [xml, s]);
// Wait for a response to come back
var uploadCallback = function(isTimeout){
var io = document.getElementById(frameId);
var execontent = function(){
try
{
if(io.contentWindow)
{
xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
});
}else if(io.contentDocument)
{
xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
}
}catch(e)
{
jQuery.handleError(s, xml, null, e);
}
if ( xml || isTimeout == "timeout"){
requestDone = true;
var status;
try {
status = isTimeout != "timeout" ? "success" : "error";
// Make sure that the request was successful or notmodified
if ( status != "error" )
{
// process the data (runs the xml through httpData regardless of callback)
var data = jQuery.uploadHttpData( xml, s.dataType );
// If a local callback was specified, fire it and pass it the data
if ( s.success )
s.success( data, status );
// Fire the global callback
if( s.global )
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
} else
jQuery.handleError(s, xml, status);
} catch(e)
{
status = "error";
jQuery.handleError(s, xml, status, e);
}
// The request was completed
if( s.global )
jQuery.event.trigger( "ajaxComplete", [xml, s] );
// Handle the global AJAX counter
if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" );
// Process result
if ( s.complete )
s.complete(xml, status);
jQuery(io).unbind();
setTimeout(function(){
try{
jQuery(io).remove();
jQuery(form).remove();
} catch(e){
jQuery.handleError(s, xml, null, e);
}
}, 100);
xml = null;
}
};
execontent();
}
// Timeout checker
if ( s.timeout > 0 ){
setTimeout(function(){
// Check to see if the request is still happening
if( !requestDone ) uploadCallback( "timeout" );
}, s.timeout);
}
try{
var form = jQuery('#' + formId);
jQuery(form).attr('action', s.url);
jQuery(form).attr('method', 'POST');
jQuery(form).attr('target', frameId);
if(form.encoding)
if (settings.submit_button == null)
{
} else
{
settings.submit_button.click(function(e)
{
e.preventDefault();
if (!uploading_file)
{
upload_file();
}
});
}
var upload_file = function()
{
if($element.val() == '') return settings.onCancel.apply($element, [settings.params]);
var ext = $element.val().split('.').pop().toLowerCase();
if(true === settings.validate_extensions && $.inArray(ext, settings.valid_extensions) == -1)
{
jQuery(form).attr('encoding', 'multipart/form-data');
}else{
jQuery(form).attr('enctype', 'multipart/form-data');
settings.onComplete.apply($element, [{status: false, message: 'The select file type is invalid. File must be ' + settings.valid_extensions.join(', ') + '.'}, settings.params]);
} else
{
uploading_file = true;
wrapElement($element);
var ret = settings.onStart.apply($element, [settings.params]);
if(ret !== false)
{
$element.parent('form').submit(function(e) { e.stopPropagation(); }).submit();
}
}
jQuery(form).submit();
} catch(e){
jQuery.handleError(s, xml, null, e);
}
jQuery('#' + frameId).load(uploadCallback );
return {abort: function () {}};
},
uploadHttpData: function( r, type ) {
var data = !type;
data = type == "xml" || data ? r.responseXML : r.responseText;
// If the type is "script", eval it in global context
if ( type == "script" )
jQuery.globalEval( data );
// Get the JavaScript object, if JSON is used.
if ( type == "json" )
eval( "data = " + data );
// evaluate scripts within html
if ( type == "html" )
jQuery("<div>").html(data).evalScripts();
return data;
},
handleError: function( s, xhr, status, e ){
// If a local callback was specified, fire it
if ( s.error ) {
s.error.call( s.context || s, xhr, status, e );
}
// Fire the global callback
if ( s.global ) {
(s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
}
}
});
};
$element.data('ajaxUploader-setup', true);
var handleResponse = function(loadedFrame, element) {
var response, responseStr = $(loadedFrame).contents().text();
try {
response = JSON.parse(responseStr);
} catch(e) {
response = responseStr;
}
element.siblings().remove();
element.unwrap();
uploading_file = false;
settings.onComplete.apply(element, [response, settings.params]);
};
var wrapElement = function(element) {
var frame_id = 'ajaxUploader-iframe-' + Math.round(new Date().getTime() / 1000)
$('body').after('<iframe width="0" height="0" style="display:none;" name="'+frame_id+'" id="'+frame_id+'"/>');
$('#'+frame_id).get(0).onload = function() {
handleResponse(this, element);
};
element.wrap(function() {
return '<form action="' + settings.action + '" method="POST" enctype="multipart/form-data" target="'+frame_id+'" />'
})
.before(function() {
var key, html = '';
for(key in settings.params) {
var paramVal = settings.params[key];
if (typeof paramVal === 'function') {
paramVal = paramVal();
}
html += '<input type="hidden" name="' + key + '" value="' + paramVal + '" />';
}
html+='<input type="hidden" name="filename" value="' + $element.attr("name") + '" />'
return html;
});
}
// document.domain = 'yohobuy.com';
//document.domain = "http://192.168.102.215:8080";
});
}
jQuery('#fileupload').on('change', function() {
jQuery.ajaxFileUpload({
url:'http://192.168.102.215:8080/platform/fileupload/upload/',
//url: 'http://upload.static.yohobuy.com',
secureuri:false,
fileElementId:'fileupload',//file标签的id
dataType: 'json',//返回数据的类型
data:{userId:543883,bucket:'smart'},//一同上传的数据
// data:{pid:0, project:"", is_public:"N",exporttype:"html"},
success: function (data, status) {
console.log(data);
//把图片替换
// var obj = jQuery.parseJSON(data);
// $("#upload").attr("src", "../image/"+obj.fileName);
// if(typeof(data.error) != 'undefined') {
// if(data.error != '') {
// alert(data.error);
// } else {
// alert(data.msg);
// }
// }
},
error: function (data, status, e) {
alert(e);
}
});
});
}
module.exports=uploader;
\ No newline at end of file
module.exports=$;
\ No newline at end of file
... ...
var $ = require('jquery');
require('../util/datepicker')($);
var Validator = require('../util/jquery.validate');// 浏览器就不用这句了,Validator是全局变量
/*获取优惠码信息渲染页面*/
exports.renderview = function(id, callback) {
var _content = $("#basicForm");
var options = {
type: 'post',
url: '/getPromotionCode',
data: {
id: id
},
dataType: "json",
success: function(res) {
res = res.data;
if (res.code == 200) {
for (var key in res.data) {
if (key == 'promotionInfo') {
var __promotionInfo = JSON.parse(res.data["promotionInfo"]);
$("#promotionInfo-type").val(__promotionInfo["type"]);
$("#promotionInfo-condition-amount_at_least").val(__promotionInfo["condition"]["amount_at_least"]);
$("#promotionInfo-condition-count_at_least").val(__promotionInfo["condition"]["count_at_least"]);
$("#promotionInfo-action-discount").val(__promotionInfo["action"]["discount"]);
$("#promotionInfo-action-discount_at_most").val(__promotionInfo["action"]["discount_at_most"]);
if ($("#promotionInfo-type").val() == "3") {
$("#resultdiscount").hide();
}
} else if (key == 'reqDepartment') {
$("#" + key).val(res.data[key]);
var arr = String.prototype.split.call(res.data["reqDepartment"], '/');
$("#department1").val(arr[0]);
if (arr[1]) {
$("#department2").val(arr[1]).show();
} else {
$("#department2").hide();
}
} else {
$("#" + key).val(res.data[key]);
if (key == "staff") {
$("#" + key).html(res.data[key]);
}
}
}
$("input:hidden", _content).each(function() {
var _value = $(this).val();
var _name = $(this).attr("id");
$("#" + _name).prev("div").find("[name='" + _name + "']").each(function() {
if (_value.indexOf($(this).val()) > -1) {
$(this).prop("checked", true);
}
});
});
callback && callback(res.data)
}
},
error: function(err) {
console.log(err);
}
};
$.ajax(options);
};
/*点击按钮提交(优惠码添加修改)*/
exports.submit = function(url, callback) {
var $submit = $('#basicForm'),
$startTime = $('#limitDateFrom'),
$endTime = $("#limitDateTo");
//初始化时间控件
//.add($endTime)
var a = $startTime.fdatepicker({
format: 'yyyy-mm-dd hh:ii:ss',
pickTime: true
}).data('datepicker');
$startTime.click(function() {
a.setEndDate($endTime.val());
});
var b = $endTime.fdatepicker({
format: 'yyyy-mm-dd hh:ii:ss',
pickTime: true
}).data('datepicker');
$endTime.click(function() {
b.setStartDate($startTime.val());
});
//点击radio,checkbox,获取相关数据,录入相关隐藏控件中
$discount = $("#promotionInfo-action-discount");
$("input:checkbox").add("input:radio").change(function() {
var _name = $(this).attr("name"),_value = [];
var $checked = $("input[name=" + _name + "]:checked");
if ($checked.prop("name") == "promotionInfo-type") {
if ($checked.val() == "3") {
$discount.prop("disabled", true).val("0.00").parents("#resultdiscount").hide();
} else {
$discount.prop("disabled", false).parents("#resultdiscount").show();
}
}
$checked.each(function() {
_value.push($(this).val());
});
$("#" + _name).val(_value.join(','));
});
//选择部门
var departmentArr = String.prototype.split.call($("#reqDepartment").val(), '/'),
$department1 = $("#department1"),
$department2 = $("#department2");
$("select").change(function() {
if ($(this).is($department1)) {
departmentArr.length = 0;
departmentArr[0] = $(this).val();
if ($(this).val() === "零售运营部") {
$department2.show();
departmentArr[1] = $department2.val();
} else {
$department2.hide();
}
} else {
departmentArr[1] = $(this).val();
}
$("#reqDepartment").val(departmentArr.join('/'));
});
function __isRepeat(arr) {
var hash = {};
for (var i in arr) {
if (hash[arr[i]]) {
return true;
}
hash[arr[i]] = true;
}
return false;
}
function validate() {
var rules = {},data = {};
$("input:text").each(function() {
var id = $(this).attr("id");
var value = $(this).val();
var rule = [];
if ($(this).attr("required")) {
rule.push("required");
}
if ($(this).attr("maxlength")) {
rule.push("max:" + $(this).attr("maxlength"));
}
if ($(this).attr("minlength")) {
rule.push("max:" + $(this).attr("minlength"));
}
if ($(this).attr("pattern")) {
rule.push("regex:" + $(this).attr("pattern"));
}
rules[id] = rule.join('|');
data[id] = value;
});
console.log(rules);
console.log(data);
var v = Validator.make(data, rules);
if (v.fails()) {
console.log(v.messages());
return false;
}
if (v.passes()) {
if ($startTime.val() && $endTime.val()) {
var startTime = new Date($startTime.val().replace(/-/g, "/"));
var endTime = new Date($endTime.val().replace(/-/g, "/"));
if (endTime > startTime) {
return true;
}
}
var arr = String.prototype.split.call($("#code").val(), ',');
if (__isRepeat(arr)) {
validity.valid = false;
return validity;
}
$.ajax({
type: 'POST',
url: '/checkPromotionCode',
data: {
code:$("#code").val()
},
dataType: 'json'
}).then(function(data) {
data = data.data;
if (data.code == "20001") {
var badcode = [];
$.each(data.data, function(index, item) {
if (item.flag == "1") {
badcode.push(item.code);
}
});
if (badcode.length == 0) {
return true
}
}
return false;
}, function() {
console.log("验证codeAjax", false);
return false;
});
return false;
}
}
$("#save_brand").click(function() {
if (validate()) {
var data = {},key2,data2 = {};
$submit.find("input").each(function() {
var _key = $(this).attr("id");
if (_key) {
var _value = $(this).val();
if (_key.indexOf('-') > -1) {
var arr = _key.split('-');
key2 = arr[0];
data[arr[0]] = data[arr[0]] || {};
if (arr.length == 2) {
data2[arr[1]] = _value;
}
if (arr.length == 3) {
data2[arr[1]] = data2[arr[1]] || {};
data2[arr[1]][arr[2]] = _value;
}
} else {
data[_key] = _value;
}
}
});
data[key2] = JSON.stringify(data2);
if (data.status === "2") {
data.status = "0";
}
var options = {
type: 'post',
url: url,
data: data,
dataType: "json",
success: function(res) {
location.href = "/list";
callback && callback(res);
},
error: function(err) {
console.log(err);
}
};
//console.log("AJAX");
$.ajax(options);
return false;
} else {
console.log("验证不通过");
}
});
}
ul {
margin-top: 0;
margin-top: 0;
}
.admin-icon-yellow {
color: #ffbe40;
color: #ffbe40;
}
.admin-header {
font-size: 1.4rem;
margin-bottom: 0;
font-size: 1.4rem;
margin-bottom: 0;
}
.admin-header-list a:hover :after {
content: none;
content: none;
}
.admin-main {
background: #f3f3f3;
background: #f3f3f3;
}
.admin-menu {
position: fixed;
z-index: 10;
bottom: 30px;
right: 20px;
position: fixed;
z-index: 10;
bottom: 30px;
right: 20px;
}
.admin-sidebar {
width: 260px;
min-height: 100%;
float: left;
border-right: 1px solid #cecece;
width: 260px;
min-height: 100%;
float: left;
border-right: 1px solid #cecece;
}
.admin-sidebar-list {
margin-bottom: 0;
margin-bottom: 0;
}
.admin-sidebar-list li a {
color: #5c5c5c;
padding-left: 24px;
color: #5c5c5c;
padding-left: 24px;
}
.admin-sidebar-list li:first-child {
border-top: none;
border-top: none;
}
.admin-sidebar-sub {
margin-top: 0;
margin-bottom: 0;
box-shadow: 0 16px 8px -15px #e2e2e2 inset;
background: #ececec;
padding-left: 24px;
margin-top: 0;
margin-bottom: 0;
box-shadow: 0 16px 8px -15px #e2e2e2 inset;
background: #ececec;
padding-left: 24px;
}
.admin-sidebar-sub li:first-child {
border-top: 1px solid #dedede;
border-top: 1px solid #dedede;
}
.admin-sidebar-panel {
margin: 10px;
margin: 10px;
}
.admin-content {
width: auto;
overflow: hidden;
height: 100%;
background: #fff;
width: auto;
overflow: hidden;
height: 100%;
background: #fff;
}
.admin-content-list {
border: 1px solid #e9ecf1;
margin-top: 0;
border: 1px solid #e9ecf1;
margin-top: 0;
}
.admin-content-list li {
border: 1px solid #e9ecf1;
border-width: 0 1px;
margin-left: -1px;
border: 1px solid #e9ecf1;
border-width: 0 1px;
margin-left: -1px;
}
.admin-content-list li:first-child {
border-left: none;
border-left: none;
}
.admin-content-list li:last-child {
border-right: none;
border-right: none;
}
.admin-content-table a {
color: #535353;
color: #535353;
}
.admin-content-file {
margin-bottom: 0;
color: #666;
margin-bottom: 0;
color: #666;
}
.admin-content-file p {
margin: 0 0 5px 0;
font-size: 1.4rem;
margin: 0 0 5px 0;
font-size: 1.4rem;
}
.admin-content-file li {
padding: 10px 0;
padding: 10px 0;
}
.admin-content-file li:first-child {
border-top: none;
border-top: none;
}
.admin-content-file li:last-child {
border-bottom: none;
border-bottom: none;
}
.admin-content-file li .am-progress {
margin-bottom: 4px;
margin-bottom: 4px;
}
.admin-content-file li .am-progress-bar {
line-height: 14px;
line-height: 14px;
}
.admin-content-task {
margin-bottom: 0;
margin-bottom: 0;
}
.admin-content-task li {
padding: 5px 0;
border-color: #eee;
padding: 5px 0;
border-color: #eee;
}
.admin-content-task li:first-child {
border-top: none;
border-top: none;
}
.admin-content-task li:last-child {
border-bottom: none;
border-bottom: none;
}
.admin-task-meta {
font-size: 1.2rem;
color: #999;
font-size: 1.2rem;
color: #999;
}
.admin-task-bd {
font-size: 1.4rem;
margin-bottom: 5px;
font-size: 1.4rem;
margin-bottom: 5px;
}
.admin-content-comment {
margin-bottom: 0;
margin-bottom: 0;
}
.admin-content-comment .am-comment-bd {
font-size: 1.4rem;
font-size: 1.4rem;
}
.admin-content-pagination {
margin-bottom: 0;
margin-bottom: 0;
}
.admin-content-pagination li a {
padding: 4px 8px;
padding: 4px 8px;
}
@media only screen and (min-width: 641px) {
.admin-sidebar {
display: block;
position: static;
background: none;
}
.admin-offcanvas-bar {
position: static;
width: auto;
background: none;
-webkit-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.admin-offcanvas-bar:after {
content: none;
}
.admin-sidebar {
display: block;
position: static;
background: none;
}
.admin-offcanvas-bar {
position: static;
width: auto;
background: none;
-webkit-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.admin-offcanvas-bar:after {
content: none;
}
}
@media only screen and (max-width: 640px) {
.admin-sidebar {
width: inherit;
}
.admin-offcanvas-bar {
background: #f3f3f3;
}
.admin-offcanvas-bar:after {
background: #BABABA;
}
.admin-sidebar-list a:hover, .admin-sidebar-list a:active{
-webkit-transition: background-color .3s ease;
-moz-transition: background-color .3s ease;
-ms-transition: background-color .3s ease;
-o-transition: background-color .3s ease;
transition: background-color .3s ease;
background: #E4E4E4;
}
.admin-content-list li {
padding: 10px;
border-width: 1px 0;
margin-top: -1px;
}
.admin-content-list li:first-child {
border-top: none;
}
.admin-content-list li:last-child {
border-bottom: none;
}
.admin-form-text {
text-align: left !important;
}
.admin-sidebar {
width: inherit;
}
.admin-offcanvas-bar {
background: #f3f3f3;
}
.admin-offcanvas-bar:after {
background: #BABABA;
}
.admin-sidebar-list a:hover, .admin-sidebar-list a:active {
-webkit-transition: background-color .3s ease;
-moz-transition: background-color .3s ease;
-ms-transition: background-color .3s ease;
-o-transition: background-color .3s ease;
transition: background-color .3s ease;
background: #E4E4E4;
}
.admin-content-list li {
padding: 10px;
border-width: 1px 0;
margin-top: -1px;
}
.admin-content-list li:first-child {
border-top: none;
}
.admin-content-list li:last-child {
border-bottom: none;
}
.admin-form-text {
text-align: left !important;
}
}
/*
* user.html css
*/
.user-info {
margin-bottom: 15px;
margin-bottom: 15px;
}
.user-info .am-progress {
margin-bottom: 4px;
margin-bottom: 4px;
}
.user-info p {
margin: 5px;
margin: 5px;
}
.user-info-order {
font-size: 1.4rem;
font-size: 1.4rem;
}
/*
... ... @@ -249,7 +251,7 @@ ul {
*/
.error-log .am-pre-scrollable {
max-height: 40rem;
max-height: 40rem;
}
/*
... ... @@ -257,27 +259,27 @@ ul {
*/
.table-main {
font-size: 1.4rem;
padding: .5rem;
font-size: 1.4rem;
padding: .5rem;
}
.table-main button {
background: #fff;
background: #fff;
}
.table-check {
width: 30px;
width: 30px;
}
.table-id {
width: 50px;
width: 50px;
}
@media only screen and (max-width: 640px) {
.table-select {
margin-top: 10px;
margin-left: 5px;
}
.table-select {
margin-top: 10px;
margin-left: 5px;
}
}
/*
... ... @@ -285,25 +287,25 @@ gallery.html css
*/
.gallery-list li {
padding: 10px;
padding: 10px;
}
.gallery-list a {
color: #666;
color: #666;
}
.gallery-list a:hover {
color: #3bb4f2;
color: #3bb4f2;
}
.gallery-title {
margin-top: 6px;
font-size: 1.4rem;
margin-top: 6px;
font-size: 1.4rem;
}
.gallery-desc {
font-size: 1.2rem;
margin-top: 4px;
font-size: 1.2rem;
margin-top: 4px;
}
/*
... ... @@ -311,44 +313,52 @@ gallery.html css
*/
.page-404 {
background: #fff;
border: none;
width: 200px;
margin: 0 auto;
background: #fff;
border: none;
width: 200px;
margin: 0 auto;
}
/*
fixed-layout 固定头部和边栏布局
fixed-layout 鍥哄畾澶撮儴鍜岃竟鏍忓竷灞€
*/
.fixed-layout,
.fixed-layout body {
height: 100%;
overflow: hidden;
height: 100%;
overflow: hidden;
}
.fixed-layout .admin-header {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1500;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1500;
}
.fixed-layout .admin-main {
position: relative;
height: 100%;
padding-top: 51px;
position: relative;
height: 100%;
padding-top: 51px;
}
.fixed-layout .admin-content,
.fixed-layout .admin-sidebar {
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
height: 100%;
overflow-x: hidden;
overflow-y: scroll;
}
.fixed-layout .admin-sidebar.am-active {
z-index: 1600;
z-index: 1600;
}
input[type=file] {
display: block;
opacity: 0;
height: 60px;
width: 100px;
position: absolute;
z-index: 99;
}
\ No newline at end of file
... ...
... ... @@ -314,7 +314,7 @@ gallery.html css
}
/*
fixed-layout 固定头部和边栏布局
fixed-layout 鍥哄畾澶撮儴鍜岃竟鏍忓竷灞€
*/
.fixed-layout,
.fixed-layout body {
... ... @@ -347,86 +347,13 @@ gallery.html css
z-index: 1600;
}
.list-filter input[type="text"], .list-filter select {
display: inline-block;
width: 200px;
}
.list-tabs {
margin: 50px 0 0;
}
.list-table {
margin: 20px 0 0;
}
.coupon-list-table {
margin: 20px 0 0;
}
.coupon-list-table th {
text-align: center;
}
.coupon-list-table td {
display: table-cell;
vertical-align: middle !important;
line-height: 1;
text-align: center;
}
.coupon-list-table td p {
margin: 0;
}
.coupon-list-table td.id {
width: 18%;
}
.coupon-list-table td.info {
width: 23%;
text-align: left;
}
.coupon-list-table td.time {
width: 11%;
}
.coupon-list-table td.describe {
width: 16%;
}
.coupon-list-table td.staff {
width: 7%;
}
.coupon-list-table td.state {
width: 11%;
}
.coupon-list-table td.state .state-reason {
color: red;
word-break: break-all;
}
.coupon-list-table td.operate.wait a.apply-success, .coupon-list-table td.operate.wait a.apply-back, .coupon-list-table td.operate.wait a.apply-cancel {
display: inline-block;
}
.coupon-list-table td.operate.success a.apply-cancel {
display: inline-block;
}
.coupon-list-table td.operate.back a.apply-modify {
display: inline-block;
}
.coupon-list-table td.operate p {
margin: 5px 0;
}
.coupon-list-table td.operate a {
display: none;
}
.coupon-list-table td.operate a.apply-detail {
display: inline-block;
}
.send-list td.time {
width: 160px;
}
.send-list td.info {
width: 352px;
}
.couponview .red {
color: #dd514c;
padding: 0 5px;
input[type=file] {
display: block;
opacity: 0;
height: 60px;
width: 100px;
position: absolute;
z-index: 99;
}
.datepicker {
... ... @@ -658,42 +585,6 @@ input[type=date], input[type=time], input[type=datetime-local], input[type=month
width: 280px;
}
/*列表页操作按钮*/
.supplier-manage-operate .btn-freeze {
display: inline-block;
}
.supplier-manage-operate .btn-recovery {
display: none;
}
.supplier-manage-operate.valid0 .btn-freeze {
display: none;
}
.supplier-manage-operate.valid0 .btn-recovery {
display: inline-block;
}
.supplier-manage-operate.status0 .btn-edit, .supplier-manage-operate.status0 .btn-recovery, .supplier-manage-operate.status0 .btn-freeze {
display: none;
}
.supplier-operate.status0 .btn-edit, .supplier-operate.status0 .btn-submit {
display: none;
}
.brand-operate.operate1 .open-brand {
display: none;
}
.brand-operate.operate0 .close-brand {
display: none;
}
.pact-operate.operate0 .btn-edit {
display: none;
}
.pact-manage-operate.operate0 .renew-btn, .pact-manage-operate.operate0 .relieve-btn, .pact-manage-operate.operate2 .renew-btn, .pact-manage-operate.operate2 .relieve-btn, .pact-manage-operate.status0 .renew-btn, .pact-manage-operate.status0 .relieve-btn {
display: none;
}
.contentpanel td a {
margin: 0 3px;
}
... ... @@ -757,5 +648,15 @@ input[type=date], input[type=time], input[type=datetime-local], input[type=month
.panel-input {
display: inline-block;
width: 100%;
}
.panel-col, .panel-col2 {
float: left;
width: 150px;
margin: 0 10px 0 0;
}
.panel-col2 {
width: 280px;
}
... ...
... ... @@ -9,14 +9,15 @@ var auth = require('./mid/auth');//认证中间件
var pageModule = require('./mid/pageModule');//页面加载js中间件
var grayroute = require('./mid/grayroute');//灰度界面中间件
var config = require('./config/common');
var multipart = require('connect-multiparty');
var qiniu = require('qiniu');
qiniu.conf.ACCESS_KEY = 'BwWhoJN536BnV3CzlE20AjNKC9O2bP0l5tFpKsDU';
qiniu.conf.SECRET_KEY = '_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK';
var uptoken = new qiniu.rs.PutPolicy('cmsimg01');
// var qiniu = require('qiniu');
// qiniu.conf.ACCESS_KEY = 'BwWhoJN536BnV3CzlE20AjNKC9O2bP0l5tFpKsDU';
// qiniu.conf.SECRET_KEY = '_x2VtO7fEmylgjojmLi7qwTBtRm30S8BrO0FxOPK';
// var uptoken = new qiniu.rs.PutPolicy('cmsimg01');
var app = yo( {
... ... @@ -33,6 +34,7 @@ var app = yo( {
port:30012,
beforeMid:function(app,mids) {//使用handlebars-layouts
require('handlebars-layouts').register(mids.hbs.handlebars);
app.use(multipart());
},
beforeCustMid: function (app, routers) {
app.use(auth);//权限验证
... ... @@ -43,7 +45,7 @@ var app = yo( {
if (res.locals.layout === false && res.locals.module) {
str += '<script type="text/javascript">seajs.use("' + res.locals.module + '",function(m){m.init();});</script>';
}
str += "<input type='hidden' id='uptoken' value='" + uptoken.token() + "'>"
//str += "<input type='hidden' id='uptoken' value='" + uptoken.token() + "'>"
return str;
}
});
... ...
//"http://172.16.6.220:8080/yohobuy-platform-web";
exports.domain ="http://localhost:30012";//require('../config/common.js').domain;
//"http://172.16.6.220:8080/yohobuy-platform-web";"http://localhost:30012";//
exports.domain =require('../config/common.js').domain;
//路由配置
exports.res = [{
... ...
... ... @@ -16,5 +16,6 @@
"qiniu": "^6.1.9"
},
"devDependencies": {
"connect-multiparty": "^2.0.0"
}
}
... ...
var authService = require('../service/auth');
var uploader=require('../service/upload');
module.exports = {
'/auth_bak':function(req, res){
... ... @@ -69,5 +70,8 @@ module.exports = {
var user = req.body.user||'';
var password = req.body.password||'';
authService.callLogin(user,password,res);
},
'/ajax/upload':function(req,res){
uploader.uploadFile(req,res);
}
}
\ No newline at end of file
... ...
var request=require('request');
var fs=require('fs');
var domain = require('../../config/common.js').domain;
exports.uploadFile=function(req,res){
// TODO 代理上传
// 方法1
if(req.is("multipart/form-data")){
req.body.file=fs.createReadStream(req.files[req.body.filename].path);
request.post({url:domain+'/fileupload/upload',formData:req.body},function optionalCallback(err, httpResponse, body){
res.json(JSON.parse(body));
});
}else{
res.json({code:"500",message:"请求类型错误"});
}
//方法2
// req.pipe(request.post(domain+'/fileupload/upload'))
// .on('error', onerror)
// .pipe(res);
// function onerror(err) {
// console.error(err.stack)
// }
}
\ No newline at end of file
... ...
... ... @@ -11,7 +11,7 @@
</ul>
<div>
<div style="width: 30%;float: left;">
<input type="file" id="fileupload">
<h4>添加供应商</h4>
</div>
</div>
... ... @@ -83,17 +83,7 @@
<div class="form-group">
<label class="col-sm-2 control-label">法人身份证电子版 </label>
<div class="col-sm-8">
<ul class="upload-image-list" style="-webkit-padding-start: 0px;padding-left: 0px;">
<li class="fileinput-button">
<a class="fileinput-button-icon" id="forlegalIdentityCard" href="javascript:void(0);">
{{#legalIdentityCard}}
<img width="76" height="80" src="{{legalIdentityCard}}">
{{/legalIdentityCard}}
<input type="hidden" id="legalIdentityCard" value="{{legalIdentityCard}}">
+</a></li>
</ul>
<input type="file" id="legalIdentityCard" name="legalIdentityCard" value="{{legalIdentityCard}}">
</div>
</div>
... ... @@ -107,43 +97,21 @@
<div class="form-group">
<label class="col-sm-2 control-label">营业执照电子版 </label>
<div class="col-sm-8">
<ul class="upload-image-list" style="-webkit-padding-start: 0px;padding-left: 0px;">
<li class="fileinput-button"><a class="fileinput-button-icon" id="forindustryLicense" href="javascript:void(0);">
{{#industryLicense}}
<img width="76" height="80" src="{{industryLicense}}">
{{/industryLicense}}
<input type="hidden" id="industryLicense" value="{{industryLicense}}">
+</a></li>
</ul>
<input type="file" id="industryLicense" name="industryLicense" value="{{industryLicense}}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">经营许可证 </label>
<div class="col-sm-8">
<ul class="upload-image-list" style="-webkit-padding-start: 0px;padding-left: 0px;">
<li class="fileinput-button"><a class="fileinput-button-icon" id="forbusinessLicensePic" href="javascript:void(0);">
{{#businessLicensePic}}
<img width="76" height="80" src="{{businessLicensePic}}">
{{/businessLicensePic}}
<input type="hidden" id="businessLicensePic" value="{{businessLicensePic}}" >
+</a></li>
</ul>
<input type="file" id="businessLicensePic" name="businessLicensePic" value="{{businessLicensePic}}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">税务登记证 </label>
<div class="col-sm-8">
<ul class="upload-image-list" style="-webkit-padding-start: 0px;padding-left: 0px;">
<li class="fileinput-button"><a class="fileinput-button-icon" id="fortaxpayerQualificationCertificate" href="javascript:void(0);">
{{#taxpayerQualificationCertificate}}
<img width="76" height="80" src="{{taxpayerQualificationCertificate}}">
{{/taxpayerQualificationCertificate}}
<input type="hidden" id="taxpayerQualificationCertificate" value="{{taxpayerQualificationCertificate}}">
+</a></li>
</ul>
<input type="file" id="fortaxpayerQualificationCertificate" name="fortaxpayerQualificationCertificate" value="{{fortaxpayerQualificationCertificate}}">
</div>
</div>
... ...