settings.nvue 1.8 KB
Newer Older
芊里 已提交
1 2 3 4 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 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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
<template>
	<view class="content">
		<uni-list class="content">
			<uni-list-item v-for="(item , index) in agreeList" :key="index" :title="item.title" :to="item.to" :clickable="true" @click="itemClick(item)" :showSwitch="item.showSwitch" :switchChecked="item.isChecked"></uni-list-item>
		</uni-list>
		<button class="bottom-back" @click="clickLogout"><text class="bottom-back-text">退出登录</text></button>
	</view>
</template>

<script>
	import { isOn, setting } from '@/common/dc-push/push.js';
	import { mapMutations } from 'vuex';
	export default {
		data() {
			return {
				agreeList:[
					{
						title:'个人资料',
						to:''
					},
					{
						title:'修改密码',
						to:''
					},{
						title:'注销用户',
						event:''
					},{
						title:'推送功能',
						name:'push',
						event:'openSetting',
						isChecked:false,
						showSwitch:true
					},{
						title:'清理缓存',
						event:''
					}
				]
			}
		},
		onShow() {
			let pushIsOn = isOn();
			this.agreeList.forEach(item=>{
				item.name == 'push' ? (item.isChecked = pushIsOn) : '';
			})
		},
		methods:{
			...mapMutations({
				logout:'user/logout'
			}),
			clickLogout(){
				this.logout();
				uni.navigateBack();
			},
			itemClick(item){
				if(!item.to && item.event){
					this[item.event]();
				}
			},
			/**
			 * 打开设置页面
			 */
			openSetting(){
				setting();
			}
		}
	}
</script>

<style>
	.content{
		width: 750rpx;
		display: flex;
		flex-direction: column;
		/* align-items: center; */
		flex: 1;
	}
	
	.bottom-back{
		width: 750rpx;
		height: 120rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		border: none;
		border-width: 0;
		border-radius: 0;
	}
	.bottom-back-text{
		font-size: 40rpx;
		color: #DD524D;
	}
</style>