|
|
const _ = require('lodash');
|
|
|
const config = global.yoho.config;
|
|
|
|
|
|
/**
|
|
|
* 参数列表
|
...
|
...
|
@@ -66,12 +67,33 @@ const getParams = (url) => { |
|
|
|
|
|
/**
|
|
|
* 生成链接
|
|
|
* @param {参数} queryParams
|
|
|
*/
|
|
|
const generateUrl = () => {
|
|
|
return '';
|
|
|
const generatePathUrl = (queryParams) => {
|
|
|
let pathUrlParams = []; // 可以找到对应关系的参数
|
|
|
let noFindParams = []; // 没有找到对应关系的
|
|
|
let pathUrl = '';
|
|
|
|
|
|
_.forEach(queryParams, (value, key) => {
|
|
|
let paramKey = _.findKey(PARAMMAP, o => {
|
|
|
return o === key;
|
|
|
});
|
|
|
|
|
|
if (paramKey) {
|
|
|
pathUrlParams.push(paramKey + value + '');
|
|
|
} else {
|
|
|
noFindParams.push(key + '=' + value);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
pathUrl = pathUrlParams.length ? pathUrlParams.join('-') : '';
|
|
|
pathUrl += noFindParams.length ? '?' + noFindParams.join('&') : '';
|
|
|
pathUrl = (pathUrl && !_.startsWith(pathUrl, '?')) ? `/${pathUrl}` : pathUrl;
|
|
|
|
|
|
return `//m.yohobuy.com/list${pathUrl}`;
|
|
|
};
|
|
|
|
|
|
module.exports = {
|
|
|
getParams,
|
|
|
generateUrl
|
|
|
generatePathUrl
|
|
|
}; |
...
|
...
|
|