yoho-plugin-helper.js
742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* Created by TaoHuang on 2017/5/11.
*/
/**
* 使用skn ,sku 拿到商品图片
* @param skn
* @param sku
* @param size
* @returns {string}
*/
function sknImage ({skn, sku, size}) {
let baseUrl = '/Api/platform/getRemoteImageUrlBySku';
let params = [];
if (skn) {
params.push(`skn_id=${skn}`);
}
if (sku) {
params.push(`sku_id=${sku}`);
}
params.push(size ? `size=${size}` : 'size=80x80');
return `${baseUrl}?${params.join('&')}`;
}
let helper = {
install(vue) {
Object.defineProperty(vue.prototype, '$helper', {
get(){
return {
sknImage
}
}
});
}
};
export default helper;