提交 378fa6d9 编写于 作者: 杜庆泉's avatar 杜庆泉

hello uts 修改为 uvue模式

上级 12847428
...@@ -74,5 +74,10 @@ ...@@ -74,5 +74,10 @@
"uniStatistics": { "uniStatistics": {
"enable": false "enable": false
}, },
"vueVersion": "3" "vueVersion": "3",
"uni-app-x" : {
"uvue" : {
"flex-direction" : "cloum"
}
}
} }
\ No newline at end of file
<template> <template>
<view>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
逐一点击执行,观察测试反馈
</view>
</view>
<button @click="getAppContextClick">getAppContext</button>
<button @click="getUniActivityClick">getUniActivity</button>
<button @click="getAppTempPathClick">getAppTempPath</button>
<button @click="typeofClick">typeof</button>
<button @click="arrayPermissionFlowClick">组权限申请流程测试</button>
<button @click="singlePermissionFlowClick">单权限申请流程测试</button>
<button @click="dispatchAsyncClick">任务分发测试</button>
<button @click="pathTestClick">路径转换测试</button>
<button @click="privacyStateClick">隐私协议状态测试</button>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。
</view>
<view class="uni-hello-text">
2. 手动切换其他APP再返回,可在控制台和界面观察事件日志
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<view class="text-box" scroll-y="true">
<text>{{text}}</text>
</view>
</view>
<button @click="gotoSystemPermissionActivityClick">手动申请权限测试</button>
<button @tap="testGoOtherActivity">跳转拍照界面</button>
<button @tap="testUnRegLifecycle">取消注册周期函数</button>
<image :src="selectImage" v-if="selectImage"></image>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
获取设备信息,观察是否符合预期
</view>
</view>
<button @tap="getDeviceInfoClick">获取设备基础信息</button>
</view>
</template> </template>
<script> <script>
import {
getAppContextTest,
getUniActivityTest,
getAppTempPathTest,
typeofClickTest,
gotoSystemPermissionActivityTest,
arrayPermissionFlowTest,
singlePermissionFlowTest,
dispatchAsyncTest,
convert2AbsFullPathTest,
unRegLifecycle,
initAppLifecycle,
gotoCameraTake,
getDeviceInfoTest,
privacyStateTest
} from '@/uni_modules/uts-platform-api'
/**
* 测试在页面生命周期之外,使用api
*/
export default {
data() {
return {
text: '',
selectImage:''
}
},
onLoad:function(){
let that = this;
initAppLifecycle(function(eventLog){
// 展示捕捉到的声明周期日志
let nextLine = that.text + eventLog;
that.text = nextLine;
let nextLineFlag = that.text + '\n';
that.text = nextLineFlag
});
},
methods: {
privacyStateClick(){
privacyStateTest(function(ret,desc){
if (ret) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
},
getDeviceInfoClick(){
this.text = getDeviceInfoTest()
},
testGoOtherActivity(){
var that = this;
let ret = gotoCameraTake(function(file){
// 展示捕捉到的声明周期日志
console.log(file);
that.selectImage = "file://" + file;
});
if(!ret){
uni.showToast({
icon:'none',
title:'测试失败'
})
}
},
testUnRegLifecycle(){
// 取消注册生命周期
unRegLifecycle();
},
getAppContextClick() {
if (getAppContextTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
getUniActivityClick() {
if (getUniActivityTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
pathTestClick() {
if (convert2AbsFullPathTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
getAppTempPathClick() {
if (getAppTempPathTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
dispatchAsyncClick() {
dispatchAsyncTest(function(ret,desc){
if (ret) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
},
typeofClick() {
if (typeofClickTest()) {
uni.showToast({
title: '测试通过'
})
} else {
uni.showToast({
icon: 'error',
title: '测试失败'
})
}
},
gotoSystemPermissionActivityClick() {
gotoSystemPermissionActivityTest()
},
arrayPermissionFlowClick() {
arrayPermissionFlowTest(function(ret,desc){
if (ret) {
uni.showToast({
icon: 'none',
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
},
singlePermissionFlowClick() {
singlePermissionFlowTest(function(ret,desc){
if (ret) {
uni.showToast({
icon: 'none',
title: '测试通过'
})
} else {
uni.showToast({
icon: 'none',
title: '失败:' + desc
})
}
})
}
}
}
</script> </script>
<style> <style>
.testButton{
width:100%
}
</style> </style>
\ No newline at end of file
...@@ -3,14 +3,13 @@ ...@@ -3,14 +3,13 @@
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-panel" v-for="(item, index) in list" :key="index"> <view class="uni-panel" v-for="(item, index) in list" :key="index">
<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index)"> <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)">
<text class="uni-panel-text">{{item.name}}</text> <text class="uni-panel-text">{{item.name}}</text>
<image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon" <image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon"
class="uni-icon"></image> class="uni-icon"></image>
</view> </view>
<view class="uni-panel-c" v-if="item.open"> <view class="uni-panel-c" v-if="item.open">
<view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)" <view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)" hover-class="uni-navigate-item-active">
hover-class="uni-navigate-item-active">
<text class="uni-navigate-text">{{page.name}}</text> <text class="uni-navigate-text">{{page.name}}</text>
<image :src="arrowRightIcon" class="uni-icon" v-if="page.url"></image> <image :src="arrowRightIcon" class="uni-icon" v-if="page.url"></image>
</view> </view>
...@@ -18,26 +17,16 @@ ...@@ -18,26 +17,16 @@
</view> </view>
</view> </view>
</template> </template>
<script lang="ts"> <script>
import { import {
doTimerTask, doTimerTask,
doIntervalTask, doIntervalTask,
clearIntervalTask, clearIntervalTask,
playAssetAudio,
getMetaConfig, getMetaConfig,
quitApp, quitApp
TimerOptions
} from "../../uni_modules/uts-advance"; } from "../../uni_modules/uts-advance";
type Page = {
name : string,
url ?: string
function ?: string
}
type ListItem = {
name : string,
open : boolean,
pages : Page[],
}
export default { export default {
data() { data() {
return { return {
...@@ -50,7 +39,7 @@ ...@@ -50,7 +39,7 @@
pages: [{ pages: [{
name: "开启延迟任务", name: "开启延迟任务",
function: "testTimer" function: "testTimer"
}] as Page[] }]
}, },
{ {
name: "定时任务", name: "定时任务",
...@@ -61,7 +50,7 @@ ...@@ -61,7 +50,7 @@
}, { }, {
name: "关闭定时任务", name: "关闭定时任务",
function: "testClearInterval" function: "testClearInterval"
}] as Page[] }]
}, },
{ {
name: "语法示例", name: "语法示例",
...@@ -72,22 +61,40 @@ ...@@ -72,22 +61,40 @@
}, { }, {
name: "参数传递示例", name: "参数传递示例",
url: "SyntaxCase/paramTest" url: "SyntaxCase/paramTest"
}, { },{
name: "日志打印示例",
url: "SyntaxCase/consoleTest"
}, {
name: "实例测试示例", name: "实例测试示例",
url: "SyntaxCase/instanceTest" url: "SyntaxCase/instanceTest"
}] as Page[] }]
}, },
] as ListItem[], {
name: "日志打印",
open: false,
pages: [{
name: "console示例",
url: "SyntaxCase/consoleTest"
}]
},
{
name: "平台代码示例",
open: false,
pages: [{
name: "UTSAndroid",
url: "SyntaxCase/utsAndroid"
}, {
name: "UTSiOS",
url: "SyntaxCase/utsiOS"
}]
},
],
arrowUpIcon: '/static/icons/arrow-up.png', arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png', arrowDownIcon: '/static/icons/arrow-down.png',
arrowRightIcon: '/static/icons/arrow-right.png', arrowRightIcon: '/static/icons/arrow-right.png',
} }
}, },
methods: { methods: {
triggerCollapse(index : number) { triggerCollapse(index) {
for (var i = 0; i < this.list.length; ++i) { for (var i = 0; i < this.list.length; ++i) {
if (index == i) { if (index == i) {
this.list[i].open = !this.list[i].open; this.list[i].open = !this.list[i].open;
...@@ -96,26 +103,9 @@ ...@@ -96,26 +103,9 @@
} }
} }
}, },
goDetailPage(e : Page) { goDetailPage(e) {
if (e.function != null) { if (e.function) {
const funName = e.function this[e.function]()
switch (funName) {
case 'testTimer':
this.testTimer()
break
case 'testInterval':
this.testInterval()
break
case 'testClearInterval':
this.testClearInterval()
break
case 'testMetaRead':
this.testMetaRead()
break
case 'testQuitApp':
this.testQuitApp()
break
}
return return
} }
uni.navigateTo({ uni.navigateTo({
...@@ -126,56 +116,54 @@ ...@@ -126,56 +116,54 @@
/** /**
* 测试延迟任务 * 测试延迟任务
*/ */
testTimer: function () { testTimer: function() {
doTimerTask({ doTimerTask({
start: function (response) { start: function(response) {
uni.showToast({ uni.showToast({
title: response, title: response,
icon: 'none' icon: 'none'
}); });
}, },
work: function (response) { work: function(response) {
uni.showToast({ uni.showToast({
title: response, title: response,
icon: 'none' icon: 'none'
}); });
}, },
} as TimerOptions); });
}, },
/** /**
* 测试周期任务 * 测试周期任务
*/ */
testInterval: function () { testInterval: function() {
var ret = doIntervalTask({ var ret = doIntervalTask({
start: function (response) { start: function(response) {
uni.showToast({ uni.showToast({
title: response, title: response,
icon: 'none' icon: 'none'
}); });
}, },
work: function (response) { work: function(response) {
uni.showToast({ uni.showToast({
title: response, title: response,
icon: 'none' icon: 'none'
}); });
}, },
} as TimerOptions); });
if (ret.taskId != null) { this.taskId = ret.taskId;
this.taskId = ret.taskId!;
}
}, },
/** /**
* 取消周期任务 * 取消周期任务
*/ */
testClearInterval: function () { testClearInterval: function() {
console.log(this.taskId); console.log(this.taskId);
clearIntervalTask(this.taskId); clearIntervalTask(this.taskId);
}, },
// testInputDialog() { testInputDialog() {
// getUserInput(function (res) { getUserInput(function(res) {
// console.log(res); console.log(res);
// }); });
// }, },
testQuitApp() { testQuitApp() {
quitApp() quitApp()
}, },
...@@ -194,4 +182,8 @@ ...@@ -194,4 +182,8 @@
<style> <style>
@import '@/common/uni-uvue.css'; @import '@/common/uni-uvue.css';
.uni-container {
min-height: 100%;
}
</style> </style>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册