Authored by 陶雨

Merge branch 'yohobuy_portak_dev_v4.8_20160620' of http://git.yoho.cn/fe/yohobuy…

…-portal-fe2 into yohobuy_portak_dev_v4.8_20160620
... ... @@ -4,6 +4,7 @@ module.exports = {
queryRefundExchangeList: {
title: '特殊商品列表数据',
url: '/refundExchangeAttribute/queryRefundExchangeList',
timeout:3000,
params: [
{name: 'productSkn', type: 'Number'},
{name: 'brandId', type: 'Number'},
... ...
... ... @@ -251,7 +251,7 @@
<input type="radio" name="isOutLets" value="Y"></label>
<label class="radio-inline">
<input type="radio" name="isOutLets" value="N"></label>
<input type="hidden" id="isOutLets" value="[[isOutLets == 'B' ? 'N' : (isOutLets||'N')]]" for="radio" />
<input type="hidden" id="isOutLets" value="[[isOutLets||'N']]" for="radio" />
</div>
... ...
... ... @@ -137,12 +137,10 @@
<label class="col-sm-1 control-label">展示店铺:</label>
<div class="col-sm-4">
[[each shopList as a index]]
[[if index==0]]
<input id="shopIds" value="[[shopIds||a.shopsId]]" type="hidden" for="checkbox">
[[/if]]
<label class="radio-inline"><input type="checkbox" name="shopIds" value="[[a.shopsId]]">[[a.shopName]]</label>
[[/each]]
</div>
<input id="shopIds" value="[[shopIds]]" type="hidden" for="checkbox">
</div>
</div>
[[/if]]
... ...
... ... @@ -6,7 +6,7 @@
module.exports=function(app) {
/*公告管理首页*/
app.get("/hotRankTag/index","operations.hotRankTag.Index", function () {
app.get("/operations/hotranktag/index","operations.hotRankTag.Index", function () {
this.$extend = {
moduleName: "运营管理",
pageName: "Top 100标签"
... ...
... ... @@ -140,7 +140,7 @@ Controller.prototype.client=function(res,views,model,clientmodel){
var src="";
if(process.env.NODE_ENV==="production"){
if(process.env.NODE_ENV==="production"||process.env.NODE_ENV==="gray"){
src="http://cdn.yoho.cn/"+config.name+"/"+config.version;
html=html.replace(/\/static\/index\.min\.css/g,function($1){
return src+"/index.min.css";
... ...
... ... @@ -102,10 +102,6 @@ function __requestApi(config, apiOpt, req, callback) {
for (var i in o) {
fns.push(o[i]);
}
//return apiOpt.call(0, req, function (err, result) {
// req._yoheaders = req._yoheaders;
// return callback(null, result);
//});
return apiOpt.apply(0, [req, function (err, result) {
req._yoheaders = req._yoheaders;
return callback(null, result);
... ... @@ -113,42 +109,46 @@ function __requestApi(config, apiOpt, req, callback) {
}
var options = __requestOption(req, apiOpt, config, me.CONSTS);
Request(options, function (error, response, body) {
var _err_ = new Error();
if (error) {
console.info("Error [request"+options.url+"]:" + options.title);
console.error(error);
return callback(error, null);
}
try {
if (response && response.statusCode === 200) {
var obj = JSON.parse(body)
if (!(typeof obj == "object")) {
_err_.message = "Error[json parse@" + options.title + "--"+options.url+"]:" + body;
console.info(_err_.message);
console.error(_err_);
return callback(_err_, null);
}
} else {
_err_.message = "Error[response state @" + options.title + "--"+options.url+"]:" + response;
console.info(_err_.message);
console.error(_err_);
return callback(_err_, null);
}
} catch (err) {
console.info("Error[response to json @" + options.title + "--"+options.url+"]");
console.info(response);
console.error(err);
return callback(err, null);
}
return callback(null, JSON.parse(body));
});
__sendRequest(options, function (result) {
return callback(null, result);
}, function (result) {
return callback(result, null);
}, {len:1}, 0, []);
//Request(options, function (error, response, body) {
// var _err_ = new Error();
// if (error) {
// console.info("Error [request"+options.url+"]:" + options.title);
// console.error(error);
// return callback(error, null);
// }
// try {
// if (response && response.statusCode === 200) {
// var obj = JSON.parse(body)
// if (!(typeof obj == "object")) {
// _err_.message = "Error[json parse@" + options.title + "--"+options.url+"]:" + body;
// console.info(_err_.message);
// console.error(_err_);
// return callback(_err_, null);
// }
// } else {
// _err_.message = "Error[response state @" + options.title + "--"+options.url+"]:" + response;
// console.info(_err_.message);
// console.error(_err_);
// return callback(_err_, null);
// }
// } catch (err) {
// console.info("Error[response to json @" + options.title + "--"+options.url+"]");
// console.info(response);
// console.error(err);
// return callback(err, null);
// }
// return callback(null, JSON.parse(body));
//});
};
function __requestOption(req, apiOpt, config, consts) {
var method = (apiOpt.method || "POST").toLocaleUpperCase();
var method = (apiOpt.method || "POST").toLocaleUpperCase(), errs = [];
var data = {};
if (apiOpt.params && (_.isArray(apiOpt.params) || _.isPlainObject(apiOpt.params))) {
if (_.isArray(apiOpt.params)) {
... ... @@ -168,6 +168,7 @@ function __requestOption(req, apiOpt, config, consts) {
});
} else
if (_.isPlainObject(apiOpt.params)) {
var fns = [];
for (var name in apiOpt.params) {
if (req.param("@" + name)) {
continue;
... ... @@ -179,10 +180,34 @@ function __requestOption(req, apiOpt, config, consts) {
if (req.param(name)) {
data[name] = param.type(req.param(name));
}
if (param.coerce && typeof param.coerce == "function") {
fns.push({ param: param,name:name});
}
}
fns.forEach(function (fn) {
var d = fn.param.coerce.call(data, req);
if (d) {
data[fn.name] = param.type(d);
}
});
//验证
for (var name in apiOpt.params) {
var param = apiOpt.params[name];
if (param.required && !data[name]) {
errs.push("params "+name + "is required!!!");
}
if (param.validator&&typeof param.validator=="function") {
var isSuc = param.validator.call(data, data[name]);
if (isSuc===false) {
errs.push("params " +name + " validator error!!!");
}
}
}
}
}
var options = { method: method };
options.errs = errs;
options.title = apiOpt.title || '';
options.outobj = apiOpt.outobj || '';
if (options.method == "GET") {
... ... @@ -240,6 +265,9 @@ function __requestOption(req, apiOpt, config, consts) {
if (req._yoheaders) {
options.headers = _.merge(options.headers, req._yoheaders);
}
if(apiOpt.timeout){
options.timeout=apiOpt.timeout;
}
console.log("*************************************");
console.log("Http", options.url, data, options.headers);
console.log("*************************************");
... ... @@ -336,12 +364,20 @@ queue.prototype = {
},
}
function __sendRequest(options, success, fail,wlen,i,args) {
function __sendRequest(options, success, fail, wlen, i, args) {
var _err_ = new Error(), obj;
if (options.errs instanceof Array&&options.errs.length) {
_err_.message = options.errs.join(',');
console.info("Error [options" + options.url + "]:" + options.title);
console.error(_err_);
wlen.len = 0;
fail && fail(_err_);
return;
}
Request(options, function (error, response, body) {
if (!wlen.len) {
return;
}
var _err_ = new Error(), obj;
if (error) {
console.info("Error [request"+options.url+"]:" + options.title);
console.error(error);
... ...
... ... @@ -512,7 +512,7 @@ $(document).on("click","#btnReview",function(){
option.data.sortId=select[3]?select[3].id:"";
option.data.isVip=option.data.isVip||'B';
option.data.isOutLets=option.data.isOutLets||'B';
option.data.isOutLets=option.data.isOutLets||'N';
// option.data.shopId=$("#shopId").val();
option.data.brandId=$("#brandId").val();
... ...
... ... @@ -142,11 +142,15 @@ common.util.__ajax({
if (productExtBo.shopIdList && productExtBo.shopIdList.length > 0) {
//如有选择店铺
productExtBo.shopIds = productExtBo.shopIdList ? productExtBo.shopIdList.join('|') : '';
} else if (res.data.length > 0) {
//如没有已选择店铺,默认选择全部
$.each(res.data, function(i, value) {
productExtBo.shopIds += value.shopsId + '|';
});
}
// else if (res.data.length > 0) {
// //如没有已选择店铺,默认选择全部
// $.each(res.data, function(i, value) {
// productExtBo.shopIds += value.shopsId + '|';
// });
// }
else{
productExtBo.shopIds=NETSALEDATA.baseProductInfo.baseProduct.shopId;
}
//
$('#product-ext').html(common.util.__template2($('#productExtBoTemp').html(), productExtBo));
... ...
... ... @@ -33,7 +33,6 @@ module.exports=function(app) {
moduleName: "分类管理",
pageName: "编辑分类"
};
console.log(response);
});
/*分类列表*/
... ...
... ... @@ -6,7 +6,7 @@
module.exports=function(app) {
/*公告管理首页*/
app.get("/hotRankTag/index","operations.hotRankTag.Index", function () {
app.get("/operations/hotranktag/index","operations.hotRankTag.Index", function () {
this.$extend = {
moduleName: "运营管理",
pageName: "Top 100标签"
... ...
... ... @@ -140,7 +140,7 @@ Controller.prototype.client=function(res,views,model,clientmodel){
var src="";
if(process.env.NODE_ENV==="production"){
if(process.env.NODE_ENV==="production"||process.env.NODE_ENV==="gray"){
src="http://cdn.yoho.cn/"+config.name+"/"+config.version;
html=html.replace(/\/static\/index\.min\.css/g,function($1){
return src+"/index.min.css";
... ...
... ... @@ -39,9 +39,9 @@
<a href="/product/class/edit/<%item.id%>"
class="btn btn-info btn-xs edit-class-btn">编辑</a>
<a href=""
class="btn btn-xs open-close-btn <%if item.booleanStatus%>btn-success <%else%>btn-danger<%/if%>"
class="btn btn-xs open-close-btn <%if item.booleanStatus%>btn-danger <%else%>btn-success<%/if%>"
data-status="<%item.status%>">
<%if item.booleanStatus%>开启<%else%>关闭<%/if%>
<%if item.booleanStatus%>关闭<%else%>开启<%/if%>
</a>
</td>
</tr>
... ...
... ... @@ -251,7 +251,7 @@
<input type="radio" name="isOutLets" value="Y"></label>
<label class="radio-inline">
<input type="radio" name="isOutLets" value="N"></label>
<input type="hidden" id="isOutLets" value="[[isOutLets == 'B' ? 'N' : (isOutLets||'N')]]" for="radio" />
<input type="hidden" id="isOutLets" value="[[isOutLets||'N']]" for="radio" />
</div>
... ...
... ... @@ -137,12 +137,10 @@
<label class="col-sm-1 control-label">展示店铺:</label>
<div class="col-sm-4">
[[each shopList as a index]]
[[if index==0]]
<input id="shopIds" value="[[shopIds||a.shopsId]]" type="hidden" for="checkbox">
[[/if]]
<label class="radio-inline"><input type="checkbox" name="shopIds" value="[[a.shopsId]]">[[a.shopName]]</label>
[[/each]]
</div>
<input id="shopIds" value="[[shopIds]]" type="hidden" for="checkbox">
</div>
</div>
[[/if]]
... ...