uni-agreements.vue 1.6 KB
Newer Older
雪洛's avatar
雪洛 已提交
1 2 3
<template>
	<view class="root">
		<checkbox-group @change="setAgree" class="checkbox-group">
4
			<checkbox :checked="isAgree" style="transform: scale(0.7);" />
雪洛's avatar
雪洛 已提交
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
			<text>{{$t('common.agree')}}</text>
		</checkbox-group>
		<view class="item" v-for="(agreement,index) in agreements" :key="index">
			<text class="agreement" @click="navigateTo(agreement)">{{agreement.title}}</text>
			<text class="hint" v-if="hasAnd(agreements,index)">&</text>
		</view>
	</view>
</template>

<script>
	export default {
		name:"uni-agreements",
		computed:{
			agreements(){
				return getApp().globalData.config.about.agreements||[]
			}
		},
		methods:{
			navigateTo({url,title}){
				uni.navigateTo({
					url: '/pages/common/webview/webview?url='+url+'&title='+title,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			hasAnd(agreements,index){
				return agreements.length-1>index
			},
			setAgree(e){
				this.isAgree = !this.isAgree
				this.$emit('setAgree',this.isAgree)
			}
		},
		created() {
			uni.$on('setAgreementsAgree',state=>{
41 42
				console.log('setAgreementsAgree',state);
				this.isAgree = state
雪洛's avatar
雪洛 已提交
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 72 73 74 75 76 77 78 79
				this.$emit('setAgree',state)
			})
		},
		data() {
			return {
				isAgree:false
			};
		}
	}
</script>

<style lang="scss" scoped>
/* #ifndef APP-NVUE */
view{
	display: flex;
	box-sizing: border-box;
	flex-direction: column;
}
/* #endif */
.root{
	flex-direction: row;
	align-items: center;
	font-size: 28rpx;
	color: #8a8f8b;
}
.checkbox-group{
	align-items: center;
	display: flex;
	flex-direction: row;
}
.item{
	flex-direction: row;
}
.agreement{
	color:#04498c;
}
</style>