login-ikonw.vue 1.6 KB
Newer Older
芊里 已提交
1
<template>
芊里 已提交
2 3
	<view class="login-iknow-wrap">
		<text class="text-sub" v-for="(t, i) in innerText" :key="i" :class="t.to?'link-color':''"
芊里 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
			@click="clickLink(t)">{{t.text || t}}</text>
	</view>
</template>

<script>
	/**
	 * text 政策描述文字
	 * link 高亮关键字及其链接
	 */
	export default {
		name: "login-ikonw",
		props: {
			text: {
				type: String,
				default: ''
			},
			link: {
				type: Array,
芊里 已提交
22
				default: ()=>[]
芊里 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
			}
		},
		data() {
			return {

			};
		},
		computed: {
			innerText() {
				if (this.link.length == 0) return this.text;
				let textList = String(this.text);
				this.link.forEach(item => {
					textList = textList.replace(item.text, '$');
				});
				textList = textList.split('');
				let list = [],
					linkList = JSON.parse(JSON.stringify(this.link));
				textList.forEach((text, tIndex) => {
					if (text == '$') {
						let currLink = linkList.shift();
						currLink.text.split('').forEach(item => {
							list.push({
								text: item,
								to: currLink.to
							});
						})
					} else {
						list.push({
							text
						})
					}
				});
				return list;
			}
		},
		methods: {
			/**
			 * 点击跳转到协议页面
			 * @param {Object} link
			 */
			clickLink(link) {
				uni.navigateTo({
					url: link.to
				})
			}
		}
	}
</script>

芊里 已提交
72 73 74 75 76 77 78 79 80 81 82 83
<style scoped>
	.login-iknow-wrap{
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		flex-wrap: wrap;
	}
	.text-sub{
		color: #8a8f8b;
		font-size: 26rpx;
	}
芊里 已提交
84 85 86 87
	.link-color {
		color: #04498c;
	}
</style>