SystemAPI.uvue 2.1 KB
Newer Older
杜庆泉's avatar
杜庆泉 已提交
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 94
<template>
	<view>
		<page-head :title="title"></page-head>
		<uni-collapse>
			<uni-collapse-item title="设备相关" :border="false">
				<uni-list>
					<uni-list-item @tap="testGetBatteryCapacity" title="获取电池电量" class="itemButton" :clickable="true"/>
				</uni-list>
			</uni-collapse-item>
		</uni-collapse>
		
		<uni-collapse>
			<uni-collapse-item title="系统事件" :border="false">
				<uni-list>
					<uni-list-item @tap="gotoScreenListen" title="监听系统截屏" class="itemButton" :clickable="true" link/>
				</uni-list>
			</uni-collapse-item>
		</uni-collapse>
		
		<uni-collapse>
			<uni-collapse-item title="Alert系统弹窗" :border="false">
				<uni-list>
					<uni-list-item @tap="gotoAlert" title="Alert弹窗" class="itemButton" :clickable="true" link/>
				</uni-list>
			</uni-collapse-item>
		</uni-collapse>
		
		<uni-collapse>
			<uni-collapse-item title="android平台" :border="false">
				<uni-list>
					<uni-list-item @tap="testGotoDemoActivity" title="自定义activity(需自定义基座)" class="itemButton" :clickable="true" link/>
					
				</uni-list>
			</uni-collapse-item>
		</uni-collapse>
		
		
	</view>
</template>
<script>
	import gotoDemoActivity from "@/uni_modules/uts-nativepage";
	import getBatteryInfo from "@/uni_modules/uts-getbatteryinfo";
	

	export default {
		data() {
			return {
				title: '系统API示例',
				
			}
		},
		onUnload: function() {},
		methods: {
			testGetBatteryCapacity() {
				getBatteryInfo({
					success(res) {
						uni.showToast({
							title: "当前电量:" + res.level + '%',
							icon: 'none'
						});
					}
				})
			},
			gotoScreenListen(){
				uni.navigateTo({
					url:'/pages/SystemAPI/ScreenListen/screenlisten'
				})
			},
			gotoAlert(){
				uni.navigateTo({
					url:'/pages/SystemAPI/Alert/alert'
				})
			},
			testGotoDemoActivity() {
				let ret = gotoDemoActivity();
				if(!ret){
					uni.showToast({
						icon:'none',
						title:'需要在自定义基座中运行'
					})
				}
			}
			
		}
	}
</script>

<style>
.screenImage{
	width: 100%;
	height: 380px;
}

</style>