64 lines
2.3 KiB
JavaScript
64 lines
2.3 KiB
JavaScript
Component({
|
|
properties: {
|
|
// icon-lujing | icon-jizhumima | icon-a-jizhumima | icon-weixindenglu | icon-kehuxinxi | icon-yewuyuanqizi | icon-chakanquanbukehu | icon-biyan | icon-bianji | icon-daikuan | icon-cangku | icon-guanlidingdan | icon-mima | icon-guanbi | icon-jianshao | icon-dingwei | icon-saomiao | icon-peihuo | icon-shaixuan | icon-paiming | icon-shanchusousuoxinxi | icon-shijian | icon-sousuo | icon-shouhou | icon-sousuofanhui | icon-sousuoshanchu | icon-tuikuan | icon-tishi | icon-xianxiahuizong | icon-xinzeng | icon-yonghuming | icon-yanjing | icon-yufukuan | icon-wodekefu | icon-dizhi | icon-shouhouzhongxin | icon-wodeshoucang | icon-shoukuanliebiao | icon-madanguanli | icon-qusechazhao | icon-pandiansaoma | icon-yaoqingma | icon-duizhang | icon-tihuoliebiao | icon-yangpinduibi | icon-yansequyang | icon-fahuoliebiao | icon-yuncangkucun | icon-xiaoshou | icon-qianzhicangkucun | icon-lingquseka | icon-gouwu1 | icon-dingdan1 | icon-gerenzhongxin1 | icon-shouye1 | icon-gerenzhongxin | icon-dingdan | icon-shouye | icon-gouwu
|
|
name: {
|
|
type: String,
|
|
},
|
|
// string | string[]
|
|
color: {
|
|
type: null,
|
|
observer: function(color) {
|
|
this.setData({
|
|
colors: this.fixColor(),
|
|
isStr: typeof color === 'string',
|
|
});
|
|
}
|
|
},
|
|
size: {
|
|
type: Number,
|
|
value: 18,
|
|
observer: function(size) {
|
|
this.setData({
|
|
svgSize: size / 750 * wx.getSystemInfoSync().windowWidth,
|
|
});
|
|
},
|
|
},
|
|
},
|
|
data: {
|
|
colors: '',
|
|
svgSize: 18 / 750 * wx.getSystemInfoSync().windowWidth,
|
|
quot: '"',
|
|
isStr: true,
|
|
},
|
|
methods: {
|
|
fixColor: function() {
|
|
var color = this.data.color;
|
|
var hex2rgb = this.hex2rgb;
|
|
|
|
if (typeof color === 'string') {
|
|
return color.indexOf('#') === 0 ? hex2rgb(color) : color;
|
|
}
|
|
|
|
return color.map(function (item) {
|
|
return item.indexOf('#') === 0 ? hex2rgb(item) : item;
|
|
});
|
|
},
|
|
hex2rgb: function(hex) {
|
|
var rgb = [];
|
|
|
|
hex = hex.substr(1);
|
|
|
|
if (hex.length === 3) {
|
|
hex = hex.replace(/(.)/g, '$1$1');
|
|
}
|
|
|
|
hex.replace(/../g, function(color) {
|
|
rgb.push(parseInt(color, 0x10));
|
|
return color;
|
|
});
|
|
|
|
return 'rgb(' + rgb.join(',') + ')';
|
|
}
|
|
}
|
|
});
|