Authored by liuyue

限购商品

... ... @@ -93,34 +93,34 @@ edit.prototype={
});
/*时间插件初始化*/
var fdatepicker={};
$("input[jsaction]",that.el)
.add("input[jsaction]",that.el)
.each(function(){
var $this=$(this);
var name=$this.attr("id"),
arr=String.prototype.split.call($this.attr("jsaction"),':');
var obj=$("#"+name).fdatepicker({
format: arr[0]=="date"?'yyyy-mm-dd':'yyyy-mm-dd hh:ii:ss',
pickTime: arr[0]=="date"?false:true
}).data("datepicker");
var fdatepicker = {};
$("input[jsaction]", that.el)
.add("input[jsaction]", that.el)
.each(function() {
var $this = $(this);
var name = $this.attr("id"),
arr = String.prototype.split.call($this.attr("jsaction"), ':');
var obj = $("#" + name).fdatepicker({
format: arr[0] == "date" ? 'yyyy-mm-dd' : 'yyyy-mm-dd hh:ii:ss',
pickTime: arr[0] == "date" ? false : true
}).data("datepicker");
fdatepicker[name]={
obj:obj,
action:arr[1]?(arr[1]==="end"?"setEndDate":"setStartDate"):false,
target:arr[2]?"#"+arr[2]:false
};
});
for(var key in fdatepicker){
var obj=fdatepicker[key].obj;
var action=fdatepicker[key].action;
var target=fdatepicker[key].target;
if(action){
(function(obj,action,target){
$("#"+key).click(function(){
obj[action]($(target).val().replace(/\s.*/,''));
fdatepicker[name] = {
obj: obj,
action: arr[1] ? (arr[1] === "end" ? "setEndDate" : "setStartDate") : false,
target: arr[2] ? "#" + arr[2] : false
};
});
for (var key in fdatepicker) {
var obj = fdatepicker[key].obj;
var action = fdatepicker[key].action;
var target = fdatepicker[key].target;
if (action) {
(function(obj, action, target) {
$("#" + key).click(function() {
obj[action]($(target).val().replace(/\s.*/, ''));
});
})(obj,action,target);
})(obj, action, target);
}
}
... ...
... ... @@ -161,8 +161,6 @@ common.edit.ajaxfileupload("#upload-input", {
if (response.data.succesList && response.data.succesList.length > 0) {
common.util.__tip(response.message, 'success');
} else {
common.util.__tip('没有成功导入的数据', 'warning');
}
} else {
common.util.__tip(response.message, 'warning');
... ...
... ... @@ -8,6 +8,7 @@ var $ = require('jquery'),
common = require('../common/common');
require('../common/bootstrap-wysihtml5');
require('../util/datepicker');
var ENMA = {
attachType: {
... ... @@ -28,6 +29,8 @@ if ($("#saleTime").data("time")) {
$("#saleTime").val(date);
}
//测试数据
var g = new common.grid({
el: "#baseTable",
... ... @@ -108,22 +111,29 @@ e.on("validate", function() {
return "请上传默认封面";
}
});
e.on("validate",function(){
var limitProductType=$("#limitProductType").val();
var activityId=$.trim($("#activityId").val());
if(limitProductType==2&&activityId==""){
e.on("validate", function() {
var limitProductType = $("#limitProductType").val();
var activityId = $.trim($("#activityId").val());
if (limitProductType == 2 && activityId == "") {
return "请填写排队限购ID";
}
})
e.init();
console.log($('#saleTime').val().slice(0, -3));
//添加修改
$('.limit-add-btn').click(function(option) {
e.submit($('#limit-add-form').attr('action'), function(option) {
var saleTime = new Date(option.data.saleTime.replace(/-/g, '/'));
//option.debug=true;
option.data.attachmentContent = JSON.stringify(g.__rows);
option.data.saleTime = new Date(option.data.saleTime.replace('-', ',')).getTime() / 1000;
/*if ($('input[name="dayFlag"]:checked').val() == 0) {
saleTime = new Date(option.data.saleTime.slice(0, -3).replace(/-/g, '/'));
}*/
option.data.saleTime = saleTime.getTime() / 1000;
console.log(option.data);
option.success = function(res) {
res = res.data;
if (res.code == "200") {
... ... @@ -145,30 +155,31 @@ $('.limit-add-btn').click(function(option) {
// var $editor = $('#editor'), //文字,图片,视频容器
// type = $('#limit-add-form').attr('type');
var Bll={
imgVideo:function(title,item,index){
if(item.attachType==2||item.__attachType==2){item.extend="mp4"};
common.dialog.confirm(title,common.util.__template($("#picDialogTemp").html(),item),function(){
var _html=$.trim($("#imgVideoText").val());
if(_html){
if(item.attachType){
//修改
g.__rows[index].attachUrl=_html;
}
else{
//添加
g.__rows.push({
"attachType": item.__attachType,
"attachUrl": _html,
"isDefault": 0,
"attachName":$("#attachName").val()
});
}
g.reload();
e1.init();
}
var Bll = {
imgVideo: function(title, item, index) {
if (item.attachType == 2 || item.__attachType == 2) {
item.extend = "mp4"
};
common.dialog.confirm(title, common.util.__template($("#picDialogTemp").html(), item), function() {
var _html = $.trim($("#imgVideoText").val());
if (_html) {
if (item.attachType) {
//修改
g.__rows[index].attachUrl = _html;
} else {
//添加
g.__rows.push({
"attachType": item.__attachType,
"attachUrl": _html,
"isDefault": 0,
"attachName": $("#attachName").val()
});
}
g.reload();
e1.init();
}
});
var a = new common.edit("#upload-wrapper");
a.on("callback", function(obj) {
... ... @@ -233,165 +244,4 @@ $('body').on('click', ".delete", function() {
$('body').on('click', ".edit", function() {
var item = g.rows[$(this).data("index")];
Bll[item.attachType == 3 ? "wenZi" : "imgVideo"]("修改" + ENMA.attachType[item.attachType], item, $(this).data("index"));
});
// //添加图片
// $('body').on('click', '#picDialog', function() {
// common.dialog.confirm("添加图片",common.util.__template($("#picDialogTemp").html(),{name:"图片", fileId: "imgUpload"}),function(){
// var imgStr = '<img src="' + $('#imgUpload').attr('value') + '">';
// var $oImg = $('<div class="quota-content quota-img" data-type="1">' + imgStr + '<a href="javascript:;" class="editor-delete btn btn-default">删除</a></div>');
// $oImg.appendTo($editor);
// });
// var a = new common.edit("#upload-wrapper");
// a.init();
// return false;
// });
// //添加视频
// $('body').on('click', '#videoDialog', function() {
// common.dialog.confirm("添加视频",common.util.__template($("#picDialogTemp").html(),{name:"视频"}),function(){
// /*var imgStr = '<img src="http://img11.static.yhbimg.com/goodsimg/2015/07/07/08/01315b5bbfd72bc5b59fa2fda6c28b9ae6.jpg">';
// var $oVideo = $('<div class="quota-imf"><img src="' + imgStr + '" alt="" /></div>');
// $('.quota-video').html(imgStr);*/
// });
// var a = new common.edit("#upload-wrapper");
// a.init();
// return false;
// });
// // 表单验证
// var limitAddForm = new common.edit("#limit-add-form");
// limitAddForm.init();
// limitAddForm.on("validate", function(){
// var param = {
// batchNo: $('#batchNo').val()
// }
// if (type == 'update') {
// param.id = $('#batchNo').data('id');
// }
// /*common.util.__ajax2({
// });*/
// });
// //表单提交
// $('.limit-add-btn').click(function () {
// var $this = $(this);
// var param = {
// batchNo: $('#batchNo').val()
// }
// if (type == 'update') {
// param.id = $('#batchNo').data('id');
// }
// common.util.__ajax2({
// url:'/limit/checkBatch',
// data: param
// }, function(res) {
// if (res.code == 200) {
// limitAddForm.submit($('#limit-add-form').attr('action'), function(option, that) {
// option.beforeSend = function () {
// $this.attr('disabled', 'disabled');
// var param = {
// batchNo: $('#batchNo').val()
// }
// if (type == 'update') {
// param.id = $('#batchNo').data('id');
// }
// };
// option.success=function(res){
// if (res.data.code == 200) {
// //成功返回列表页
// limitAddForm.$tip('提交成功',function(){
// //window.location.href = '/limit/product/index';
// }, 'growl-success');
// $this.removeAttr('disabled');
// } else {
// limitAddForm.$tip(res.data.message);
// $this.removeAttr('disabled');
// }
// return false;
// };
// option.error=function(res){
// limitAddForm.$tip(res.message);
// $this.removeAttr('disabled');
// };
// //文字,图片,视频上传数据
// option.data.attachmentContent = [];
// option.data.attachmentContent.push({
// attachUrl:option.data.coverImg,
// isDefault: 1,
// attachType: 1,
// orderBy: 0
// });
// if ($('.quota-content').size() > 0) {
// $('.quota-content').each(function(i) {
// var editType = $(this).data('type'),
// content = '',
// obj = {
// attachType: editType, //上传内容类型,1:图片, 2:视频,3:文字
// isDefault: 0, //是否封面图
// orderBy: i //排序
// };
// if (editType == 3) {
// content = $(this).find('span').text();
// obj.intro = content; //文字key为intro
// } else if (editType == 1) {
// content = $(this).find('img').attr('src');
// obj.attachUrl = content; //图片key为attachUrl
// }
// option.data.attachmentContent.push(obj)
// });
// }
// //因为只能传字符串,转换为字符串
// option.data.attachmentContent = JSON.stringify(option.data.attachmentContent);
// //时间上传为时间戳
// option.data.saleTime = new Date(option.data.saleTime.replace('-',',')).getTime() / 1000;
// console.log(option.data);
// });
// }
// });
// });
// //编辑页,时间戳转换
// $('#saleTime').val(function() {
// if ($(this).data('time')) {
// var date = new Date($(this).data('time') * 1000);
// return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
// }
// });
// //富文本删除事件
// $('#limit-add-form').on('click', '.editor-delete', function() {
// $(this).parents('.quota-content').remove();
// });
// $('input[name="hotFlag"]').on('click', function() {
// if ($(this).val() == 0) {
// $('#orderBy').attr('disabled', true);
// } else {
// $('#orderBy').removeAttr('disabled');
// }
// });
\ No newline at end of file
});
\ No newline at end of file
... ...
... ... @@ -2,213 +2,188 @@ exports.domain = require('../config/common.js').domain;
//exports.domain = 'http://172.16.6.240:8088/platform';
//路由配置
exports.res = [
{
//【限购商品】页面渲染
route: '/limit/product/index',
method: 'GET',
view: 'pages/limit/index',
src: '/product/limit'
}, {
// 【限购商品】ajax分页
route: '/limit/product/page',
method: 'POST',
url: '/limitProduct/getLimitProductList',
params: [
{
name: 'hotFlag',
type: 'Number'
},{
name: 'saleFlag',
type: 'Number'
},{
name: 'showFlag',
type: 'Number'
},{
name: 'productName',
type: 'String'
},{
name: 'productSkn',
type: 'String'
},{
name: 'page',
type: 'Number'
},{
name: 'size',
type: 'Number'
}
]
},{
// 【限购商品】添加页面渲染
route: '/limit/product/add',
method: 'GET',
view: 'pages/limit/add',
src: '/product/limit-add',
data: {
data: {},
action: '/limit/product/add'
exports.res = [{
//【限购商品】页面渲染
route: '/limit/product/index',
method: 'GET',
view: 'pages/limit/index',
src: '/product/limit'
}, {
// 【限购商品】ajax分页
route: '/limit/product/page',
method: 'POST',
url: '/limitProduct/getLimitProductList',
params: [{
name: 'hotFlag',
type: 'Number'
}, {
name: 'saleFlag',
type: 'Number'
}, {
name: 'showFlag',
type: 'Number'
}, {
name: 'productName',
type: 'String'
}, {
name: 'productSkn',
type: 'String'
}, {
name: 'page',
type: 'Number'
}, {
name: 'size',
type: 'Number'
}
},{
// 【限购商品】ajax添加
route: '/limit/product/add',
method: 'POST',
url: '/limitProduct/addLimitProduct',
params: [
{
name: 'productName',
type: 'String'
},
{
name: 'attachmentContent',
type: 'String'
},
{
name: 'batchNo',
type: 'Number'
},{
name: 'saleTime',
type: 'String'
},{
name: 'hotFlag',
type: 'Number'
},{
name:'orderBy',
type: 'Number'
},{
name: 'notSaleOrderBy',
type: 'Number'
},{
name:'limitProductType',
type:'Number'
},
{
name:'activityId',
type:'Number'
}
]
}, {
route: '/limit/edit/:id',
method: 'GET',
view: 'pages/limit/add',
url: '/limitProduct/getLimitProduct',
data:{
action:"/limit/update",
type:"update"
},
src:'/product/limit-add',
params:[
{name:"id",type:"String"}
]
}, {
route: '/limit/update',
method: 'POST',
url: '/limitProduct/updateLimitProduct',
params: [
{
name: 'id',
type: 'Number'
},
{
name: 'productName',
type: 'String'
},
{
name: 'attachmentContent',
type: 'String'
},
{
name: 'batchNo',
type: 'Number'
},{
name: 'saleTime',
type: 'String'
},{
name: 'hotFlag',
type: 'Number'
},{
name:'orderBy',
type: 'Number'
},{
name: 'notSaleOrderBy',
type: 'Number'
}, {
name: 'dayFlag',
type: 'Number'
}
]
}, {
route: '/limit/ajax/getCodeCount',
method: 'POST',
url: '/limitProduct/getCountByStatus',
params: [
{
name: 'hotFlag',
type: 'Number'
},{
name: 'saleFlag',
type: 'Number'
},{
name: 'showFlag',
type: 'Number'
},{
name: 'productName',
type: 'String'
},{
name: 'productSkn',
type: 'String'
}
]
}, {
route: '/limit/audit',
method: 'POST',
url: '/limitProduct/auditLimitProduct',
params: [
{
name: 'id',
type: 'Number'
},
{
name: 'showFlag',
type: 'Number'
},
{
name: 'hotFlag',
type: 'Number'
},
{
name: 'orderBy',
type: 'Number'
},
{
name: 'notSaleOrderBy',
type: 'Number'
}
]
}, {
route: '/limit/delete',
method: 'POST',
url: '/limitProduct/deleteLimitProduct',
params: [
{
name: 'id',
type: 'Number'
}
]
}, {
route: '/limit/checkBatch',
method: 'POST',
url: '/limitProduct/checkBatchNoExist',
params: [
{
name: 'batchNo',
type: 'Number'
},
{
name: 'id',
type: 'Number'
}
]
]
}, {
// 【限购商品】添加页面渲染
route: '/limit/product/add',
method: 'GET',
view: 'pages/limit/add',
src: '/product/limit-add',
data: {
data: {},
action: '/limit/product/add'
}
];
}, {
// 【限购商品】ajax添加
route: '/limit/product/add',
method: 'POST',
url: '/limitProduct/addLimitProduct',
params: [{
name: 'productName',
type: 'String'
}, {
name: 'attachmentContent',
type: 'String'
}, {
name: 'batchNo',
type: 'Number'
}, {
name: 'saleTime',
type: 'String'
}, {
name: 'hotFlag',
type: 'Number'
}, {
name: 'orderBy',
type: 'Number'
}, {
name: 'notSaleOrderBy',
type: 'Number'
}, {
name: 'limitProductType',
type: 'Number'
}, {
name: 'activityId',
type: 'Number'
}]
}, {
route: '/limit/edit/:id',
method: 'GET',
view: 'pages/limit/add',
url: '/limitProduct/getLimitProduct',
data: {
action: "/limit/update",
type: "update"
},
src: '/product/limit-add',
params: [{
name: "id",
type: "String"
}]
}, {
route: '/limit/update',
method: 'POST',
url: '/limitProduct/updateLimitProduct',
params: [{
name: 'id',
type: 'Number'
}, {
name: 'productName',
type: 'String'
}, {
name: 'attachmentContent',
type: 'String'
}, {
name: 'batchNo',
type: 'Number'
}, {
name: 'saleTime',
type: 'String'
}, {
name: 'hotFlag',
type: 'Number'
}, {
name: 'orderBy',
type: 'Number'
}, {
name: 'notSaleOrderBy',
type: 'Number'
}, {
name: 'dayFlag',
type: 'Number'
}]
}, {
route: '/limit/ajax/getCodeCount',
method: 'POST',
url: '/limitProduct/getCountByStatus',
params: [{
name: 'hotFlag',
type: 'Number'
}, {
name: 'saleFlag',
type: 'Number'
}, {
name: 'showFlag',
type: 'Number'
}, {
name: 'productName',
type: 'String'
}, {
name: 'productSkn',
type: 'String'
}]
}, {
route: '/limit/audit',
method: 'POST',
url: '/limitProduct/auditLimitProduct',
params: [{
name: 'id',
type: 'Number'
}, {
name: 'showFlag',
type: 'Number'
}, {
name: 'hotFlag',
type: 'Number'
}, {
name: 'orderBy',
type: 'Number'
}, {
name: 'notSaleOrderBy',
type: 'Number'
}]
}, {
route: '/limit/delete',
method: 'POST',
url: '/limitProduct/deleteLimitProduct',
params: [{
name: 'id',
type: 'Number'
}]
}, {
route: '/limit/checkBatch',
method: 'POST',
url: '/limitProduct/checkBatchNoExist',
params: [{
name: 'batchNo',
type: 'Number'
}, {
name: 'id',
type: 'Number'
}]
}];
\ No newline at end of file
... ...
var request = require('request');
var fs = require('fs');
var domain = require('../../config/common.js').domain;
//var domain = require('../../config/common.js').domain;
//var domain = 'http://172.16.6.227:8083/yohobuy-platform-web'; //马力
//var domain = 'http://192.168.102.202:8088/platform';
var domain = 'http://192.168.102.202:8088/platform';
var env = process.env.NODE_ENV || 'development';
... ... @@ -14,8 +14,8 @@ exports.uploadFile = function(req, res) {
url: domain + '/batch/import',
formData: req.body
}, function optionalCallback(err, httpResponse, body) {
var json=JSON.parse(body);
json.status=true;
var json = JSON.parse(body);
json.status = true;
res.json(json);
});
} else {
... ... @@ -23,8 +23,8 @@ exports.uploadFile = function(req, res) {
url: domain + '/fileupload/upload',
formData: req.body
}, function optionalCallback(err, httpResponse, body) {
var json=JSON.parse(body);
json.status=true;
var json = JSON.parse(body);
json.status = true;
res.json(json);
});
}
... ... @@ -34,4 +34,4 @@ exports.uploadFile = function(req, res) {
message: "请求类型错误"
});
}
}
}
\ No newline at end of file
... ...