uni-agreements.vue 1.6 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1 2
<template>
	<view class="root">
3
		<checkbox-group @change="setAgree" class="checkbox-group">
4
			<checkbox :checked="isAgree" style="transform: scale(0.7);" />
5
			<text>{{$t('common.agree')}}</text>
6
		</checkbox-group>
7
		<view class="item" v-for="(agreement,index) in agreements" :key="index">
DCloud_JSON's avatar
DCloud_JSON 已提交
8
			<text class="agreement" @click="navigateTo(agreement)">{{agreement.title}}</text>
9
			<text class="hint" v-if="hasAnd(agreements,index)">&</text>
10
		</view>
DCloud_JSON's avatar
DCloud_JSON 已提交
11 12 13 14 15 16 17 18
	</view>
</template>

<script>
	export default {
		name:"uni-agreements",
		computed:{
			agreements(){
study夏羽's avatar
study夏羽 已提交
19
				return getApp({allowDefault: true}).globalData.config.about.agreements||[]
DCloud_JSON's avatar
DCloud_JSON 已提交
20 21 22 23 24 25 26 27 28 29
			}
		},
		methods:{
			navigateTo({url,title}){
				uni.navigateTo({
					url: '/pages/common/webview/webview?url='+url+'&title='+title,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
DCloud_JSON's avatar
DCloud_JSON 已提交
30 31 32
			},
			hasAnd(agreements,index){
				return agreements.length-1>index
33 34 35 36
			},
			setAgree(e){
				this.isAgree = !this.isAgree
				this.$emit('setAgree',this.isAgree)
DCloud_JSON's avatar
DCloud_JSON 已提交
37 38
			}
		},
39 40
		created() {
			uni.$on('setAgreementsAgree',state=>{
41 42
				console.log('setAgreementsAgree',state);
				this.isAgree = state
43 44 45
				this.$emit('setAgree',state)
			})
		},
DCloud_JSON's avatar
DCloud_JSON 已提交
46 47
		data() {
			return {
48
				isAgree:false
DCloud_JSON's avatar
DCloud_JSON 已提交
49 50 51 52 53
			};
		}
	}
</script>

54 55 56 57 58 59 60 61
<style lang="scss" scoped>
/* #ifndef APP-NVUE */
view{
	display: flex;
	box-sizing: border-box;
	flex-direction: column;
}
/* #endif */
DCloud_JSON's avatar
DCloud_JSON 已提交
62 63
.root{
	flex-direction: row;
64
	align-items: center;
DCloud_JSON's avatar
DCloud_JSON 已提交
65 66 67
	font-size: 28rpx;
	color: #8a8f8b;
}
68
.checkbox-group{
69
	align-items: center;
70 71 72
	display: flex;
	flex-direction: row;
}
73 74 75
.item{
	flex-direction: row;
}
DCloud_JSON's avatar
DCloud_JSON 已提交
76 77 78 79
.agreement{
	color:#04498c;
}
</style>