advance.vue 4.8 KB
Newer Older
杜庆泉's avatar
init  
杜庆泉 已提交
1
<template>
杜庆泉's avatar
杜庆泉 已提交
2
	<view>
杜庆泉's avatar
杜庆泉 已提交
3
		<page-head :title="title" accordion></page-head>
杜庆泉's avatar
杜庆泉 已提交
4 5


6
		<uni-collapse accordion>
杜庆泉's avatar
杜庆泉 已提交
7 8
			<uni-collapse-item title="延迟任务" :border="false">
				<uni-list>
9
					<uni-list-item @tap="testTimer" title="开启延迟任务"  :clickable="true">
杜庆泉's avatar
杜庆泉 已提交
10 11
					</uni-list-item>
				</uni-list>
12
			</uni-collapse-item>
杜庆泉's avatar
杜庆泉 已提交
13

杜庆泉's avatar
杜庆泉 已提交
14 15 16
			<uni-collapse-item title="定时任务" :border="false">

				<uni-list>
17
					<uni-list-item @tap="testInterval" title="开启定时任务"  :clickable="true">
杜庆泉's avatar
杜庆泉 已提交
18
					</uni-list-item>
19
					<uni-list-item @tap="testClearInterval" title="关闭定时任务" :clickable="true">
杜庆泉's avatar
杜庆泉 已提交
20 21
					</uni-list-item>
				</uni-list>
22
			</uni-collapse-item>
杜庆泉's avatar
杜庆泉 已提交
23 24
			<uni-collapse-item title="语法示例" :border="false">
				<uni-list>
25
					<uni-list-item @tap="testSyntax" title="进阶语法示例" :clickable="true" link>
杜庆泉's avatar
杜庆泉 已提交
26
					</uni-list-item>
杜庆泉's avatar
杜庆泉 已提交
27 28
					<uni-list-item @tap="testParams" title="参数传递示例" :clickable="true" link>
					</uni-list-item>
杜庆泉's avatar
杜庆泉 已提交
29 30
					<uni-list-item @tap="testConsole" title="日志打印示例" :clickable="true" link>
					</uni-list-item>
杜庆泉's avatar
杜庆泉 已提交
31
				</uni-list>
32
			</uni-collapse-item>
杜庆泉's avatar
杜庆泉 已提交
33 34
			<uni-collapse-item title="资源加载示例" :border="false">
				<uni-list>
35
					<uni-list-item @tap="gotoResourceDemo" title="图片加载示例" :clickable="true" link>
杜庆泉's avatar
杜庆泉 已提交
36 37
					</uni-list-item>
				</uni-list>
38
			</uni-collapse-item>
39 40 41 42 43 44 45 46 47
			<uni-collapse-item title="组件开发示例" :border="false">
			
				<uni-list>
					<uni-list-item @tap="testHelloUTSComponent" title="Hello UTS Component" :clickable="true" link />
			
				</uni-list>
			
			</uni-collapse-item>
			
杜庆泉's avatar
杜庆泉 已提交
48 49 50 51
			<uni-collapse-item title="android平台示例" :border="false">

				<uni-list>

52
					<uni-list-item @tap="testLifecyle" title="activity生命周期监听" :clickable="true" link />
打打卡夫卡's avatar
打打卡夫卡 已提交
53
					<uni-list-item @tap="testAssetLoad" title="播放asset音频(需自定义基座)" :clickable="true" link/>
54
					<uni-list-item @tap="gotoDecorView" title="操作DecorView" :clickable="true" link />
杜庆泉's avatar
杜庆泉 已提交
55
					<uni-list-item @tap="testMetaRead" title="读取meta配置" :clickable="true" />
杜庆泉's avatar
杜庆泉 已提交
56
					<uni-list-item @tap="testQuitApp" title="退出当前应用" :clickable="true" />
杜庆泉's avatar
杜庆泉 已提交
57 58
				</uni-list>

59
			</uni-collapse-item>
60 61 62 63 64 65
			
			<uni-collapse-item title="iOS平台示例" :border="false">
				<uni-list>
					<uni-list-item @tap="testGetResourcePath" title="资源路径获取示例" :clickable="true" link />
				</uni-list>
			</uni-collapse-item>
66
		</uni-collapse>
杜庆泉's avatar
杜庆泉 已提交
67

68

杜庆泉's avatar
杜庆泉 已提交
69
	</view>
杜庆泉's avatar
init  
杜庆泉 已提交
70
</template>
杜庆泉's avatar
杜庆泉 已提交
71 72
<script>
	import {
杜庆泉's avatar
杜庆泉 已提交
73 74 75
		doTimerTask,
		doIntervalTask,
		clearIntervalTask,
杜庆泉's avatar
杜庆泉 已提交
76
		playAssetAudio,
杜庆泉's avatar
杜庆泉 已提交
77 78
		getMetaConfig,
		quitApp
打打卡夫卡's avatar
打打卡夫卡 已提交
79
	} from "../../uni_modules/uts-advance";
杜庆泉's avatar
杜庆泉 已提交
80

杜庆泉's avatar
杜庆泉 已提交
81

杜庆泉's avatar
杜庆泉 已提交
82 83 84 85
	export default {
		data() {
			return {
				title: 'UTS进阶示例',
杜庆泉's avatar
杜庆泉 已提交
86
				taskId: 0,
杜庆泉's avatar
杜庆泉 已提交
87 88
			}
		},
杜庆泉's avatar
杜庆泉 已提交
89

杜庆泉's avatar
杜庆泉 已提交
90
		methods: {
杜庆泉's avatar
杜庆泉 已提交
91

92 93 94
			/**
			 * 测试延迟任务
			 */
杜庆泉's avatar
杜庆泉 已提交
95
			testTimer: function() {
杜庆泉's avatar
杜庆泉 已提交
96
				doTimerTask({
杜庆泉's avatar
杜庆泉 已提交
97
					start: function(response) {
杜庆泉's avatar
杜庆泉 已提交
98
						uni.showToast({
杜庆泉's avatar
杜庆泉 已提交
99 100
							title: response,
							icon: 'none'
杜庆泉's avatar
杜庆泉 已提交
101 102
						});
					},
杜庆泉's avatar
杜庆泉 已提交
103
					work: function(response) {
杜庆泉's avatar
杜庆泉 已提交
104
						uni.showToast({
杜庆泉's avatar
杜庆泉 已提交
105 106
							title: response,
							icon: 'none'
杜庆泉's avatar
杜庆泉 已提交
107 108 109 110
						});
					},
				});
			},
111 112 113
			/**
			 * 测试周期任务
			 */
杜庆泉's avatar
杜庆泉 已提交
114
			testInterval: function() {
杜庆泉's avatar
杜庆泉 已提交
115
				var ret = doIntervalTask({
杜庆泉's avatar
杜庆泉 已提交
116
					start: function(response) {
杜庆泉's avatar
杜庆泉 已提交
117
						uni.showToast({
杜庆泉's avatar
杜庆泉 已提交
118 119
							title: response,
							icon: 'none'
杜庆泉's avatar
杜庆泉 已提交
120 121
						});
					},
杜庆泉's avatar
杜庆泉 已提交
122
					work: function(response) {
杜庆泉's avatar
杜庆泉 已提交
123
						uni.showToast({
杜庆泉's avatar
杜庆泉 已提交
124 125
							title: response,
							icon: 'none'
杜庆泉's avatar
杜庆泉 已提交
126 127 128 129 130
						});
					},
				});
				this.taskId = ret.taskId;
			},
131 132 133
			/**
			 * 取消周期任务
			 */
杜庆泉's avatar
杜庆泉 已提交
134
			testClearInterval: function() {
杜庆泉's avatar
杜庆泉 已提交
135
				console.log(this.taskId);
杜庆泉's avatar
杜庆泉 已提交
136
				clearIntervalTask(this.taskId);
杜庆泉's avatar
杜庆泉 已提交
137
			},
杜庆泉's avatar
杜庆泉 已提交
138

139

140 141 142
			/**
			 * 跳转至资源加载演示界面
			 */
杜庆泉's avatar
杜庆泉 已提交
143
			gotoResourceDemo: function() {
杜庆泉's avatar
杜庆泉 已提交
144
				uni.navigateTo({
杜庆泉's avatar
杜庆泉 已提交
145
					url: '/pages/resource/resource'
杜庆泉's avatar
杜庆泉 已提交
146 147
				})
			},
148
			gotoDecorView: function() {
杜庆泉's avatar
杜庆泉 已提交
149 150 151 152 153
				uni.navigateTo({
					url: '/pages/advance/android/decorview'
				})
			},
			testAssetLoad() {
打打卡夫卡's avatar
打打卡夫卡 已提交
154 155 156 157
				// playAssetAudio();
				uni.navigateTo({
					url: '/pages/advance/android/assetaudio'
				})
杜庆泉's avatar
杜庆泉 已提交
158
			},
杜庆泉's avatar
杜庆泉 已提交
159 160 161 162 163
			testInputDialog() {
				getUserInput(function(res){
					console.log(res);
				});
			},
杜庆泉's avatar
杜庆泉 已提交
164 165 166
			testQuitApp(){
				quitApp()
			},
杜庆泉's avatar
杜庆泉 已提交
167

杜庆泉's avatar
杜庆泉 已提交
168 169 170 171 172 173
			testMetaRead() {
				let ret = getMetaConfig();
				uni.showToast({
					icon:"none",
					title: '读取成功,注意查看控制台输出'
				});
174
				console.log(ret);
杜庆泉's avatar
杜庆泉 已提交
175
			},
杜庆泉's avatar
杜庆泉 已提交
176
			testLifecyle: function() {
杜庆泉's avatar
杜庆泉 已提交
177
				uni.navigateTo({
杜庆泉's avatar
杜庆泉 已提交
178
					url: '/pages/lifecycle/lifecycle'
杜庆泉's avatar
杜庆泉 已提交
179 180
				})
			},
181 182
			testHelloUTSComponent: function() {
				uni.navigateTo({
183
					url: '/pages/component/helloView'
184 185
				})
			},
杜庆泉's avatar
杜庆泉 已提交
186
			testSyntax: function() {
杜庆泉's avatar
杜庆泉 已提交
187
				uni.navigateTo({
杜庆泉's avatar
杜庆泉 已提交
188
					url: '/pages/SyntaxCase/index'
杜庆泉's avatar
杜庆泉 已提交
189 190
				})
			},
杜庆泉's avatar
杜庆泉 已提交
191 192 193 194 195
			testParams: function() {
				uni.navigateTo({
					url: '/pages/SyntaxCase/paramTest'
				})
			},
杜庆泉's avatar
杜庆泉 已提交
196 197 198 199 200
			testConsole: function() {
				uni.navigateTo({
					url: '/pages/SyntaxCase/consoleTest'
				})
			},
201 202 203 204 205
			testGetResourcePath: function() {
				uni.navigateTo({
					url: '/pages/advance/iOS/getResourcePath'
				})
			}
杜庆泉's avatar
杜庆泉 已提交
206

杜庆泉's avatar
杜庆泉 已提交
207 208 209
		}
	}
</script>
杜庆泉's avatar
init  
杜庆泉 已提交
210

杜庆泉's avatar
杜庆泉 已提交
211
<style>
212
	
杜庆泉's avatar
杜庆泉 已提交
213
</style>