Authored by 王钱钧

Merge branch 'develop' of http://git.dev.yoho.cn/platform/yohobuy-portal-fe into develop

... ... @@ -31,11 +31,11 @@ function batchExport(el, type) {
},
onStart: function(params) {
params.brandId=common.util.__input("brandId");
params.shopId=common.util.__input("shopId");
params.shopsId=common.util.__input("shopId");
params.supplierId=common.util.__input("supplierId");
params.brandName=params.brandId?$("#brandId").find("option[value="+$("#brandId").val()+"]").text():"";
params.shopsName=params.shopId?$("#shopId").find("option[value="+$("#shopId").val()+"]").text():"";
params.shopsName=params.shopsId?$("#shopId").find("option[value="+$("#shopId").val()+"]").text():"";
params.supplierName=params.supplierId?$("#supplierId").find("option[value="+$("#supplierId").val()+"]").text():"";
console.log("params",params);
... ...
... ... @@ -101,7 +101,8 @@ var g = new common.grid({
name: 'picImgUrl',
render: function(item) {
if (item.picImgUrl) {
return '<a target="_blank" href="' + item.productUrl + '"><img src="' + item.picImgUrl + '" width="100" height="60"></a>';
return '<a class="list-img" target="_blank" href="' + item.productUrl + '">' +
'<img src="' + item.picImgUrl + '"></a>';
} else {
return '';
}
... ...
... ... @@ -51,7 +51,25 @@ $(document).on("click",".tag a",function(){
$("#taglist").html(common.util.__template2($("#template4").html(),{tags:g.selected}));
return false;
});
var Brand={},Brands=[];
$(document).on("click","#addBrands",function(){
common.util.__ajax({url:'/goods/brands/queryBrandsByStatus'},function(res){
res.data.forEach(function(item,index){
var brandAlif=item.brandAlif.toUpperCase();
if(/^[0-9]$/.test(item.brandAlif)){
brandAlif="0-9";
}
if(/^\W$/.test(item.brandAlif)){
brandAlif="#";
}
Brand[brandAlif]=Brand[brandAlif]||[];
Brand[brandAlif].push(item);
});
for(var i in Brand){
Brands.push({name:i,items:Brand[i]});
}
console.log(JSON.stringify(Brands));
},true);
});
var e=new common.edit("#panel-body",{});
... ...
... ... @@ -30,7 +30,10 @@ $(document).on('click', '#searchSku', function () {
headList.push({
display: "参考尺码(" + item.genderName + ")", name: "referenceName", render: function (item) {//参考尺码列
var refName = item.referenceName ? item.referenceName : "";//非空判断
return '<input class="form-control refInfo" data-index="' + item.__index + '"' + 'value="' + refName + '"/>';
var a =refName.split(/[|/]/g);
var refName1=a[0]||"",refName2=a[1]||"";
console.log("refName",item);
return '<input class="col-sm-2 refInfo refInfo1" data-index="' + item.__index + '"' + 'value="' + refName1 + '"/>'+'<div class="col-sm-1">'+'/</div>'+'<input class="col-sm-2 refInfo refInfo2" data-index="' + item.__index + '"' + 'value="' + refName2 + '"/>';
}
});
for (var i = 0; i < item.sizeRelationsList[0].prdSizeAttributeBoList.length; i++) {//尺码列
... ... @@ -97,13 +100,15 @@ $(document).on('click', '#searchSku', function () {
}
//商品参考尺码
var productSizeReferList = [];
for (var i = 0; i < $(".refInfo").length; i++) {
var ref = $($(".refInfo")[i]);
for (var i = 0; i < $(".refInfo").length/2; i++) {
var ref1 = $($(".refInfo1")[i]);
var ref2 = $($(".refInfo2")[i]);
productSizeReferList.push({
sizeId: grid.rows[ref.data("index")].sizeId,
sizeId: grid.rows[ref1.data("index")].sizeId,
gender: item.gender,
referenceName: ref.val()
referenceName: ref1.val()+'/'+ref2.val()
});
console.log("productSizeReferList",productSizeReferList);
}
common.util.__ajax({
url: "/meterManage/productSize/saveProdSizeInfo",
... ...
... ... @@ -63,6 +63,7 @@ var g = new common.grid({
},
{
display: "操作", name: "", render: function (item) {
console.log("item",item);
var arr = [];
arr.push('<a class="btn btn-info add2" data-index="' + item.__index + '">编辑</a>');
return arr.join("");
... ... @@ -129,13 +130,15 @@ var Bll = {
}
//商品参考尺码
var productSizeReferList = [];
for (var i = 0; i < $(".refInfo").length; i++) {
var ref = $($(".refInfo")[i]);
for (var i = 0; i < $(".refInfo").length/2; i++) {
var ref1 = $($(".refInfo1")[i]);
var ref2 = $($(".refInfo2")[i]);
productSizeReferList.push({
sizeId: grid.rows[ref.data("index")].sizeId,
sizeId: grid.rows[ref1.data("index")].sizeId,
gender: item.gender,
referenceName: ref.val()
referenceName: ref1.val()+'/'+ref2.val()
});
console.log("productSizeReferList",productSizeReferList);
}
common.util.__ajax({
url: url,
... ... @@ -170,7 +173,10 @@ var Bll = {
headList.push({
display: "参考尺码(" + item.genderName + ")", name: "referenceName", render: function (item) {//参考尺码列
var refName = item.referenceName ? item.referenceName : "";//非空判断
return '<input class="form-control refInfo" data-index="' + item.__index + '"' + 'value="' + refName + '"/>';
var a =refName.split(/[,|/]/g);
var refName1=a[0]||"",refName2=a[1]||"";
console.log("refName",item);
return '<input class="col-sm-2 refInfo refInfo1" data-index="' + item.__index + '"' + 'value="' + refName1 + '"/>'+'<div class="col-sm-1">'+'/</div>'+'<input class="col-sm-2 refInfo refInfo2" data-index="' + item.__index + '"' + 'value="' + refName2 + '"/>';
}
});
for (var i = 0; i < item.sizeRelationsList[0].prdSizeAttributeBoList.length; i++) {//尺码列
... ...
... ... @@ -59,7 +59,7 @@ var g = new common.grid({
{display: "衣服尺码", name: "dressSize"},
{
display: "模特卡", name: "modelCard ", render: function (item) {
return '<img src="' + item.modelCard + '?imageView/2/w/100/h/100" width="100" height="60"/>'
return '<img src="' + item.modelCard + '" width="100" height="60"/>'
}
},
{
... ...
... ... @@ -137,14 +137,24 @@ var Bll = {
},
valid_extensions: ['png', 'jpg', 'jpeg'],
onComplete: function (response) {
//if (response.status && response.code == 200) {
// var file = $("#picfile").val();
// var fileName = Bll.getFileName(file);
// var data = {
// "fileName": response.data,
// "originalName": fileName
// };
// Bll.pictureBoList.push(data);
// Bll.rendBoList(Bll.pictureBoList);
//}
if (response.status && response.code == 200) {
var file = $("#picfile").val();
var fileName = Bll.getFileName(file);
var data = {
"fileName": response.data,
"originalName": fileName
};
Bll.pictureBoList.push(data);
console.log("response", response);
for(var i=0;i<response.data.length;i++){
Bll.pictureBoList.push({
"fileName": response.data[i],
"originalName": response.names[i]
})
}
Bll.rendBoList(Bll.pictureBoList);
}
else {
... ...
... ... @@ -2,6 +2,21 @@
border-top: 1px solid #e7e7e7;
}
.list-img {
display: block;
width: 78px;
height: 78px;
line-height: 78px;
font-size: 0;
text-align: center;
img {
vertical-align: middle;
max-width: 100%;
max-height: 100%;
}
}
.red {
color: red;
font-family: bold;
... ...
... ... @@ -3,7 +3,7 @@
* @type {Object}
*/
module.exports = {
url:'http://admin.portal.yohobuy.com',
url:'http://admin.yohobuy.com',//'http://admin.portal.yohobuy.com',
sessionKeep:'/account/profile/display',
timeout:30000
};
\ No newline at end of file
... ...
... ... @@ -67,7 +67,8 @@ exports.res = [
{name: 'status', type: 'Number'},//模特状态:0 禁用 1 启用
{name: 'vitalStatistics', type: 'string'},//三围
{name: 'weight', type: 'Number'},//体重
{name: 'avatar', type: 'string'}//头像
{name: 'avatar', type: 'string'},//头像
{name: 'modelCard', type: 'string'}//模特卡
]
}
];
\ No newline at end of file
... ...
... ... @@ -25,11 +25,7 @@ var errorMessage = {
util.setLogger(res.app.logger);
var options = {
url:oldService.login,
form:{
account:user,
password:password,
website:WEBSITE
}
form:'["'+user+'","'+password+'",1]'//'["zhiyuan","lzy111111",1]'//
}
//调用登陆
... ... @@ -38,8 +34,9 @@ var errorMessage = {
res.json(errorMessage);
return;
} else {
console.log(ret);
//调用菜单
_callGetMenu(ret.data.pid,function(err,data){
_callGetMenu(ret.data.pid,ret.data.role_id,function(err,data){
if(err) {
res.json(errorMessage);
} else {
... ... @@ -66,24 +63,22 @@ var errorMessage = {
* @param {Number} pid 操作员ID
* @param {Function} callback 回调
*/
function _callGetMenu(pid,callback) {
function _callGetMenu(pid,roleid,callback) {
var options = {
url:oldService.getResourceByPid,
form:{
pid:pid,
website:WEBSITE
}
form:'['+pid+','+roleid+',1]'
}
console.log(options);
util.httpCall(options,function(err,ret){
if(err) {
callback(err);
} else {
var menuData = {menu:[],right:{}};
if(ret.data && ret.data.length>0) {
if(ret.data) {
menuData = _makeMenu(ret.data);
}
_getAllMenu(function(ret){
filterRight(ret,menuData);
menuData.noRight = filterRight(ret,menuData);
delete menuData.right;
callback(null,menuData);
... ... @@ -102,14 +97,17 @@ function _callGetMenu(pid,callback) {
function filterRight(ret,menuData) {
var noRight = {};
//匹配没有权限
_.forEach(ret,function(v,k){
if(v.module_url!=='') {
if(!menuData.right[v.module_url]) {
noRight[v.module_url] = true;
for(var key in ret){
var item=ret[key];
for(var i in item.sub){
var v=item.sub[i];
if(v.menu_url!=='') {
if(!menuData.right[v.menu_url]) {
noRight[v.menu_url] = true;
}
}
}
}
});
return noRight;
}
... ... @@ -120,7 +118,7 @@ function filterRight(ret,menuData) {
function _getAllMenu (callback) {
var options = {
url:oldService.getAllResByWebsite+'?website='+WEBSITE+'&sort=',
method:'GET'
form:'['+WEBSITE+']'
}
util.httpCall(options,function(err,ret){
... ... @@ -140,27 +138,51 @@ function _getAllMenu (callback) {
function _makeMenu (data) {
var menu = [];
var right = {};
_.forEach(data,function(v){
for(var key in data){
var v=data[key];
var item = {
title:v.resource_name,
title:v.menu_name,
}
if(v.parent_id === "0") {
item.parent = 'menu-template';
var itemSubs = [];
_.forEach(v.sub,function(val) {
var sub = {
title:val.resource_name,
href:val.module_url,
title:val.menu_name,
href:val.menu_url,
icon: 'list-alt'
}
right[val.module_url] = true;
right[val.menu_url] = true;
itemSubs.push(sub);
});
item.menu = itemSubs;
}
menu.push(item);
});
}
// _.forEach(data,function(v){
// var item = {
// title:v.menu_name,
// }
// if(v.parent_id === "0") {
// item.parent = 'menu-template';
// var itemSubs = [];
// _.forEach(v.sub,function(val) {
// console.log(v.sub);
// var sub = {
// title:val.menu_name,
// href:val.menu_url,
// icon: 'list-alt'
// }
// right[val.menu_url] = true;
// itemSubs.push(sub);
// });
// item.menu = itemSubs;
// }
// menu.push(item);
// });
return {
menu:menu,
... ...
var oldSerDomain = 'http://service.api.yohobuy.com';
// var oldSerDomain = 'http://service.api.yohobuy.com';
// module.exports = {
// login: oldSerDomain + '/account/api/v1/profile/login',
// getResourceByPid: oldSerDomain + '/account/api/v1/profile/getResourceByPid',
// getAllResByWebsite: oldSerDomain + '/account/api/v1/resources/getAllResByWebsite'
// };
var oldSerDomain = 'http://lserve.yohobuy.com';
module.exports = {
login: oldSerDomain + '/account/api/v1/profile/login',
getResourceByPid: oldSerDomain + '/account/api/v1/profile/getResourceByPid',
getAllResByWebsite: oldSerDomain + '/account/api/v1/resources/getAllResByWebsite'
login: oldSerDomain + '/service/account/v1/Profile/login',
getResourceByPid: oldSerDomain + '/service/account/v1/Profile/getMenuByPid',
getAllResByWebsite: oldSerDomain + '/service/setting/v1/menu/getAllMenu'
};
... ...
... ... @@ -11,42 +11,53 @@ var oldUploadUrl = 'http://upload.static.yohobuy.com';
var errBackMsg = {
code: "500",
message: "接口异常"
};
};
//var domain = 'http://172.16.6.227:8088/platform'; //马力
// var domain = 'http://172.16.6.162:8088/platform';
//var domain = 'http://172.16.6.240:8088/platform';
exports.uploadFile = function(req, res) {
exports.uploadFile = function (req, res) {
var headers = {};
if (req.session && req.session.user) {
var ipObject = ipaddr.process(req.ip).octets
var ipObject = ipaddr.process(req.ip).octets;
var ip = ipObject ? ipObject.join('.') : req.ip;
headers = {
'x-user-id': req.session.user.auth.pid,
'x-user-name': req.session.user.auth.account,
'x-site-type': 1,
'x-client-ip': ip
};
}else{
}
else {
res.json({
code: "501",
message: "用户失效,请重新登录"
});
}
if (req.is("multipart/form-data")) {
console.log(req.body);
var url=[];
for(var key in req.body){
url.push(key+"="+req.body[key]);
var url = [];
for (var key in req.body) {
url.push(key + "=" + req.body[key]);
}
//req.body.file = fs.createReadStream(req.files[req.body.filename].path);
var files = req.files[req.body.filename];
//判断是单张传还是多张传
var flag = Object.prototype.toString.call(files) === '[object Array]';
//如果是单张,则数组化
if (!flag) {
files = [];
files.push(req.files[req.body.filename]);
}
req.body.files = [];
req.body.fileNames = [];
for (var index = 0; index < files.length; index++) {
req.body.files[index] = fs.createReadStream(files[index].path);
req.body.fileNames[index] = files[index].name;
}
req.body.file = fs.createReadStream(req.files[req.body.filename].path);
if (req.body.__type == "batch-import") {
request.post({
url: domain + '/batch/import?'+url.join("&"),
url: domain + '/batch/import?' + url.join("&"),
formData: req.body,
headers: headers
}, function optionalCallback(error, httpResponse, body) {
... ... @@ -56,33 +67,37 @@ exports.uploadFile = function(req, res) {
if (!error && httpResponse.statusCode == 200) {
var json = JSON.parse(body);
json.status = true;
// console.log(json);
res.json(json);
} else {
res.json(errBackMsg);
}
});
} else {
//如果是goodsimg(商品)的图片,灰度到老系统的上传地址
if(req.body.bucket === 'goodsimg') {
req.body.filename = req.files[req.body.filename].path;
if (req.body.bucket === 'goodsimg') {
//req.body.filename = req.files[req.body.filename].path;
request.post({
url: oldUploadUrl,
formData:{
fileData:req.body.file,
project:req.body.bucket
formData: {
fileData: req.body.files,
project: req.body.bucket
}
},function(error,resd,body) {
if(!error && resd.statusCode == 200) {
}, function (error, resd, body) {
if (!error && resd.statusCode == 200) {
var ret = JSON.parse(body);
if(ret.code === 200) {
var imgUrl = ret.data.imagesList[0];
if (ret.code === 200) {
//var imgUrl = ret.data.imagesList[0];
var imgs = ret.data.imagesList || [];
var datas = [];
for (var i = 0; i < imgs.length; i++) {
datas.push(joinimg(imgs[i]))
}
res.json({
code:200,
data:joinimg(imgUrl),
message:'上传成功',
status:true
code: 200,
data: datas,
names: req.body.fileNames,
message: '上传成功',
status: true
});
return;
}
... ... @@ -90,12 +105,11 @@ exports.uploadFile = function(req, res) {
res.json(errBackMsg);
});
} else {
req.body.file = fs.createReadStream(req.files[req.body.filename].path);
request.post({
url: domain + '/fileupload/upload',
formData: req.body
}, function optionalCallback(error, httpResponse, body) {
console.log(body);
if (!error && httpResponse.statusCode == 200) {
var json = JSON.parse(body);
json.status = true;
... ... @@ -112,7 +126,7 @@ exports.uploadFile = function(req, res) {
message: "请求类型错误"
});
}
}
};
/**
* 组合全路径的图片地址
... ... @@ -120,12 +134,12 @@ exports.uploadFile = function(req, res) {
function joinimg(url) {
var urlArr = url.split('/');
var domain = 'static.yhbimg.com/goodsimg';
var num = urlArr[urlArr.length-1].substr(1,1);
var url = domain + url;
if(num == 1) {
return 'http://img11.' + url;
var num = urlArr[urlArr.length - 1].substr(1, 1);
var url1 = domain + url;
if (num == 1) {
return 'http://img11.' + url1;
} else {
return 'http://img12.'+ url;
return 'http://img12.' + url1;
}
}
... ... @@ -153,7 +167,7 @@ function joinimg(url) {
exports.ueditor = function(req, res) {
var headers = {};
if (req.session && req.session.user) {
var ipObject = ipaddr.process(req.ip).octets
var ipObject = ipaddr.process(req.ip).octets;
var ip = ipObject ? ipObject.join('.') : req.ip;
headers = {
... ... @@ -169,8 +183,6 @@ exports.ueditor = function(req, res) {
message: "用户失效,请重新登录"
});
}
console.log(req.files);
if (req.is("multipart/form-data")) {
req.body.file = fs.createReadStream(req.files.upfile.path);
req.body.bucket="goodsimg";
... ...
... ... @@ -244,3 +244,26 @@
<span class="tag"><span>[[tag.tagName]]</span><a href="#" title="Removing tag" data-index='[[__index]]'>x</a></span>
[[/each]]
</script>
<script type="text/template" id="template5">
<div class="row">
<div class="form-group">
[[each Brands as brand index]]
<a>[[brand.name]]</a>
[[/each]]
</div>
<div class="form-group">
[[each Brands as brand index]]
<div class="form-group" name="[[brand.name]]">
[[each brand.items as item __index ]]
<input type="checkbox" value="[[item.id]]" name="brandCheckBox">
<label>[[item.brandName]]</label>
[[/each]]
</div>
[[/each]]
</div>
</div>
</script>
\ No newline at end of file
... ...
... ... @@ -38,7 +38,7 @@
<div id="content-list"></div>
<div id="add-saveArea">
<a class="btn btn-success" id="add-saveBtn" href="">保存</a>
<a class="btn btn-primary" href="/meterManage/meterSize/index">返回</a>
<a class="btn btn-primary" href="/meterManage/meterSize/index">取消</a>
</div>
</div>
</div>
... ... @@ -47,16 +47,11 @@
<div id="base-form">
<table style="width: 100%">
<tr>
<th>SKN</th>
<td width="60px;">[[productSkn]]</td>
<th> 名称:</th>
<td>[[productName]]</td>
<th> 品牌:</th>
<td>[[brandName]]</td>
<th> 分类:</th>
<td>[[maxSortName]]</td>
<th> 性别:</th>
<td>[[genderName]]</td>
<th>SKN[[productSkn]]</th>
<th> 名称:[[productName]]</th>
<th> 品牌:[[brandName]]</th>
<th>分类:[[maxSortName]]</th>
<th> 性别:[[genderName]]</th>
<input type="hidden" id="productSkn" value="[[productSkn]]" />
</tr>
</table>
... ...
... ... @@ -75,7 +75,7 @@
<li class="cover-image-item fileinput-button">
<div class="goods-img">
<a class="fileinput-button-icon" href="javascript:void(0);">+</a>
<input type="file" class="goods-img-upload picfile" name="picfile" required="required" id="picfile" placeholder="图片">
<input type="file" class="goods-img-upload picfile" name="picfile" required="required" id="picfile" placeholder="图片" multiple="true">
</div>
</li>
</ul>
... ...