123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <template>
-
- <view @click="onclick" v-if="name" class="tm-icons vertical-align-top" style="display: inline-block;font-size: 0;" >
- <view class="flex-center " :style="{
- width: sizes,
- height: sizes,
- lineHeight:sizes,
-
- }">
- <block v-if="vtype == false">
- <image :src="name" :style="{
- width: sizes,
- height: sizes
- }" mode="scaleToFill"></image>
- </block>
- <block v-if="vtype == true">
-
- <text :style="{
- fontSize: sizes,
- fontFamily:'iconfontTM'
- }" class="icons "
- :class="[ black_tmeme ? colors+'-bk':colors, dense ? '' : 'pa-10', black ? 'opacity-6' : '']">{{iconName}}</text>
-
-
-
- <text :style="{
- fontSize: sizes,
- }" class="icons mt--4"
- :class="[prefx_computed, black_tmeme ? 'bk' : '', iconName, colorTheme ? colors : '', dense ? '' : 'pa-10', black ? 'opacity-6' : '']"></text>
-
-
- <text :style="{
- fontSize: sizes,
- }" class="icons "
- :class="[prefx_computed, black_tmeme ? 'bk' : '', iconName, colorTheme ? colors : '', dense ? '' : 'pa-10', black ? 'opacity-6' : '']"></text>
-
-
- </block>
- </view>
- </view>
- </template>
- <script>
-
- export default {
- props: {
- dense: {
-
- type: Boolean,
- default: false
- },
- black: {
- type: Boolean,
- default: null
- },
- prefx: {
- type: String,
- default: 'iconfont'
- },
- name: {
- type: String,
- default: ''
- },
- size: {
- type: String | Number,
- default: 28
- },
- color: {
- type: String,
- default: 'primary'
- },
-
- iconType: {
- type: String,
- default: ''
- },
-
- fllowTheme: {
- type: Boolean | String,
- default: false
- }
- },
- computed: {
- iconName: function() {
-
- let fontList = require('@/tm-vuetify/scss/iconfonts/iconfont.json');
- let name = this.name.replace('icon-', '');
-
-
- let itemIcon = fontList.glyphs.find((item, index) => {
- return item.font_class == name;
- })
- return eval('"\\u' + itemIcon.unicode + '"');
-
- return this.name;
- },
- prefx_computed(){
- let prefix = this.name.split('-')[0];
- if(prefix=='icon') return 'iconfont';
- if(prefix=='mdi') return 'mdi';
-
- return prefix;
- },
- black_tmeme: function() {
- return this.$tm.vx.state().tmVuetify.black;
- },
- vtype: function() {
- if (this.name[0] == "." ||
- this.name[0] == "/" ||
- this.name.substring(0, 4) == 'http' ||
- this.name.substring(0, 5) == 'https' ||
- this.name.substring(0, 3) == 'ftp'
- ) {
- return false;
- }
- return true;
- },
- sizes: function() {
- if (typeof this.size === 'string') {
- if (/[rpx|upx|rem|em|vx|vh|px]$/.test(this.size)) {
- return this.size;
- }
- return uni.upx2px(parseInt(this.size)) + 'px';
- }
- if (typeof this.size === 'number' && !isNaN(this.size)) {
- return uni.upx2px(this.size) + 'px';
- }
- },
- color_tmeme: function() {
- if (this.$tm.vx.state().tmVuetify.color !== null && this.$tm.vx.state().tmVuetify.color && this
- .fllowTheme) {
- return this.$tm.vx.state().tmVuetify.color;
- }
- return this.color;
- },
- colors: {
- get: function() {
- if (!this.color_tmeme) return 'text-primary';
- if (!this.$TestColor(this.color_tmeme)) {
- return this.color_tmeme;
- }
- return 'text-' + this.color_tmeme;
- },
- set: function() {
- if (!this.$TestColor(this.color_tmeme)) {
- this.colorTheme = false;
- return this.color_tmeme;
- }
- this.colorTheme = true;
- }
- }
- },
- data() {
- return {
- colorTheme: true
- };
- },
- methods: {
- onclick(e) {
- this.$emit('click', e);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .tm-icons {
- vertical-align: middle;
- .icons {
- &.black {
- color: #fff;
- }
- }
- }
- </style>
|