<template>
	<view class="flex-grow-1">
		<block v-if="type==4 ||type==7 || type==8">
			<view @click="bindCate(type,text.link.id||'')" :style="style" v-if="name==''"
				class="box-pack-between flex-y-center border-b">
				<text>{{ text.t }}</text>
				<text class="iconfont icon-jiantou"></text>
			</view>
			<view :style="style" class="text-overflow" v-else>{{ name }}</view>
		</block>
		<block v-else>
			<view :style="style" v-if="name==''">{{ text.t }}</view>
			<view :style="style" class="text-overflow" v-else>{{ name }}</view>
		</block>
		<!-- {{type}} -->
		<!-- <span :style="style" v-if="name==''">{{ text.t }}</span>
	        <span :style="style" v-else>{{ name }}</span>-->
	</view>
</template>

<script>
	import store from '../../store/index.js'
	export default {
		name: 'moduleText',
		props: {
			'text': {
				type: Object
			},
			'name': {
				default: ''
			},
			'type': {
				default: 1
			},
		},
		computed: {
			style() {
				if (this.text.d) {
					let style = `font-size:${this.text.f}px;color:${this.text.c};`;
					if (this.text.b) {
						style += 'font-weight:bold;';
					}
					if (this.text.i) {
						style += 'font-style:italic;';
					}
					if (this.text.u) {
						style += 'text-decoration:underline;';
					}
					return style;
				}
			}
		},

		methods: {
			bindCate(type, id) {
				console.log(id, type, "id")
				if (type == 4) {
					store.commit('SET_CATE_ID', id || '')
					uni.switchTab({
						url: "../../pages/index/index"
					})
				}
				if (type == 7) {
					uni.navigateTo({
						url: "../../pintuan/list"
					})
				}
				if (type == 8) {
					uni.navigateTo({
						url: "../../subscribe/shopsSubscrbe"
					})
				}

			}
		},

	};
</script>
<style>
	.icon-jiantou {
		font-size: 24rpx;
	}

	/* 	view{
		font-size: 24rpx;
	} */
	.text-overflow {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
</style>
