<template>
	<view>
		
		<u-navbar 
		title="设置" 
		title-color="#fff" 
		:custom-back="customBack" 
		:border-bottom="false" 
		back-icon-color="#CCE8FF" 
		:background="{background: 'linear-gradient(145deg, #41AFF9 0%, #2D8CFB 100%)' }"></u-navbar>
		
		<view class="cell-group" style="margin-top: 30rpx;">
			<u-cell-group>				
				<u-cell-item title="修改密码" @click="openPage('pages/modifypwd/modifypwd')">
					<u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
				</u-cell-item>
				<u-cell-item title="打印走纸" @click="onPrintFeed()">
					<u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
				</u-cell-item>
				<u-cell-item title="退出登录" @click="onLoginOut()">
					<u-icon slot="icon" custom-prefix="custom-icon" size="35" name="wodecheliang"></u-icon>
				</u-cell-item>
			</u-cell-group>
		</view>
		
	</view>
</template>

<script>
	//#ifdef APP-PLUS
	var device = uni.requireNativePlugin("DeviceInfo")
	//#endif
	export default{
		data(){
			return{
				
			}
		},
		onLoad(){
			
		},
		onShow(){
			
		},
		methods:{
			customBack(){
				this.$u.route({
					// type:'switchTab',
					url: 'pages/index/index'
				});
			},
			openPage(path) {
				// console.log('path',path);
				this.$u.route({ 
					url: path
				});
			},
			onPrintFeed(){
				//#ifdef APP-PLUS
				device.printFeed(10);
				//#endif
				//#ifdef H5
				uni.showToast({
					title: '非APP环境',
					duration: 2000
				});
				//#endif
			},
			onLoginOut(){
				uni.showModal({
				  title: '温馨提示',  
				  content: '是否确认退出?',  
				  success: (res) => { 
					   if (res.confirm) {
							  this.$u.api.loginOut({})
							  .then(res=>{
									uni.showToast({
										title: '退出成功',
										duration: 2000
									});
							  	uni.redirectTo({
							  		url:'../login/login'
							  	});
							  }).catch(err=>{
								  uni.showToast({
								  	title: '退出失败',
								  	duration: 2000
								  });
							  });
						  } else if (res.cancel) {
							  
						  }
					  
				  }  
				})  
				
			}
			
		}
	}
</script>

<style lang="scss">
	@import  './setting.scss'
</style>
