Authored by 李奇

修改

... ... @@ -68,4 +68,5 @@ typings/
# IDE
.idea
*.iml
.vscode
\ No newline at end of file
... ...
{
"navigationBarTitleText": "搜索"
"navigationBarTitleText": "红人小店"
}
\ No newline at end of file
... ...
... ... @@ -8,7 +8,7 @@
"newFeature": true
},
"compileType": "miniprogram",
"libVersion": "1.6.6",
"libVersion": "1.9.1",
"appid": "wx084ab813d88c594b",
"projectname": "%E7%BA%A2%E4%BA%BA%E5%B0%8F%E5%BA%97",
"condition": {
... ...
/* global getRegExp */
var regExpWidth = getRegExp('{width}', 'g');
var regExpHeight = getRegExp('{height}', 'g');
var regExpMode = getRegExp('{mode}', 'g');
var regExpQg = getRegExp('/q/d+', 'g');
var regExpQ = getRegExp('/q/d+');
var regExpQuality = getRegExp('/quality/d+');
var regExpQualityg = getRegExp('/quality/d+', 'g');
var regExpImageView = getRegExp('imageView');
var regExpImageMogr = getRegExp('imageMogr');
var defaultQuality = 75;
function image(imgUrl, w, h, mode, q) {
var urls,
query,
url;
var params = {
w: w,
h: h,
mode: mode || 2,
q: q || defaultQuality
};
if (imgUrl && (typeof imgUrl === 'string')) {
urls = imgUrl.split('?');
query = urls[1] || '';
url = urls[0];
if (url.indexOf('http:') === 0) {
url = url.replace('http:', 'https:');
}
if (!query || query === 'imageslim') {
url += params.q === defaultQuality ? '?imageslim' : '?imageView2/0/interlace/1/q/' + params.q;
imgUrl = url;
} else {
imgUrl = imgUrl.replace(regExpWidth, params.w)
.replace(regExpHeight, params.h)
.replace(regExpMode, (params.mode));
if (regExpImageView.test(query)) { // imageView2 || imageView
if (!regExpQ.test(query)) {
imgUrl += '/q/' + params.q;
} else {
imgUrl = imgUrl.replace(regExpQg, '/q/' + params.q);
}
} else if (regExpImageMogr.test(query)) {
if (!regExpQuality.test(query)) {
imgUrl += '/quality/' + params.q;
} else {
imgUrl = imgUrl.replace(regExpQualityg, '/quality/' + params.q);
}
}
}
return imgUrl;
} else {
return '';
}
}
module.exports = {
image: image
};
... ...