提交 789f1852 编写于 作者: 杜庆泉's avatar 杜庆泉

hello uts 尝试迁移到 uvue

上级 fb0eb114
{ {
"name" : "HelloUTS", "name": "HelloUTS",
"appid" : "__UNI__70BE9D0", "appid": "__UNI__70BE9D0",
"description" : "", "description": "",
"versionName" : "1.0.9", "versionName": "1.0.9",
"versionCode" : "109", "versionCode": "109",
"transformPx" : false, "transformPx": false,
/* 5+App特有相关 */ /* 5+App特有相关 */
"app-plus" : { "app-plus": {
"usingComponents" : true, "usingComponents": true,
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler": "uni-app",
"compilerVersion" : 3, "compilerVersion": 3,
"splashscreen" : { "splashscreen": {
"alwaysShowBeforeRender" : true, "alwaysShowBeforeRender": true,
"waiting" : true, "waiting": true,
"autoclose" : true, "autoclose": true,
"delay" : 0 "delay": 0
}, },
/* 模块配置 */ /* 模块配置 */
"modules" : {}, "modules": {},
/* 应用发布信息 */ /* 应用发布信息 */
"distribute" : { "distribute": {
/* android打包配置 */ /* android打包配置 */
"android" : { "android": {
"permissions" : [ "permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>", "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>", "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>", "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>", "<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>", "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>", "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>", "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>", "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>", "<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
], ],
"minSdkVersion" : 21, "minSdkVersion": 21,
"abiFilters" : [ "armeabi-v7a" ] "abiFilters": ["armeabi-v7a"]
}, },
/* ios打包配置 */ /* ios打包配置 */
"ios" : { "ios": {
"dSYMs" : false "dSYMs": false
}, },
/* SDK配置 */ /* SDK配置 */
"sdkConfigs" : { "sdkConfigs": {
"ad" : {} "ad": {}
} }
} }
}, },
/* 快应用特有相关 */ /* 快应用特有相关 */
"quickapp" : {}, "quickapp": {},
/* 小程序特有相关 */ /* 小程序特有相关 */
"mp-weixin" : { "mp-weixin": {
"appid" : "", "appid": "",
"setting" : { "setting": {
"urlCheck" : false "urlCheck": false
}, },
"usingComponents" : true "usingComponents": true
}, },
"mp-alipay" : { "mp-alipay": {
"usingComponents" : true "usingComponents": true
}, },
"mp-baidu" : { "mp-baidu": {
"usingComponents" : true "usingComponents": true
}, },
"mp-toutiao" : { "mp-toutiao": {
"usingComponents" : true "usingComponents": true
}, },
"uniStatistics" : { "uniStatistics": {
"enable" : false "enable": false
}, },
"vueVersion" : "3" "vueVersion": "3",
} "uni-app-x": {}
}
\ No newline at end of file
<template>
<div>
<button @tap="changeUrl">播放本地动画资源</button>
<button @tap="changeServerUrl">播放远程动画资源</button>
<button @tap="changeAutoPlay">测试AutoPlay</button>
<button @tap="changeLoop">测试Loop</button>
<button @tap="changeAction(1)">测试action play</button>
<button @tap="changeAction(2)">测试action pause</button>
<button @tap="changeAction(3)">测试action stop</button>
<uts-animation-view ref="animView" :path="animUrl" :autoplay="autoplay" :loop="loop" :action="action"
:hidden="hidden" @bindended="testAnimEnd" @click="lottieClickTest" @longpress="lottieLongpressTest"
:style="{width:widthNum+'rpx',height:heightNum+'px',background:yanse}">
</uts-animation-view>
</div>
</template>
<script>
export default {
data() {
return {
hidden: false,
autoplay: false,
action: "play",
loop: false,
yanse: "red",
widthNum: 750,
heightNum: 200,
comShow: true,
animUrl: "/static/anim_a.json"
}
},
methods: {
changeAutoPlay: function() {
this.autoplay = !this.autoplay
},
changeUrl: function() {
if (this.animUrl == "/static/anim_a.json") {
this.animUrl = "/static/anim_b.json"
} else {
this.animUrl = "/static/anim_a.json"
}
},
changeServerUrl: function() {
this.animUrl = "https://b.bdstatic.com/miniapp/images/lottie_example_one.json"
},
changeAction: function(type) {
if (type == 1) {
this.action = "play"
} else if (type == 2) {
this.action = "pause"
} else if (type == 3) {
this.action = "stop"
}
},
changeLoop: function() {
this.loop = !this.loop
},
testAnimEnd: function(res) {
console.log("testAnimEnd");
console.log(res);
},
changeRepeat: function(res) {
this.$refs["animView"].updateRepeatConfig("RESTART");
},
lottieClickTest: function(res) {
console.log("lottieClickTest");
console.log(res);
},
lottieLongpressTest: function(res) {
console.log("lottieClickTest");
console.log(res);
},
}
}
</script>
<template>
<view>
<page-head :title="title"></page-head>
<uni-list>
<uni-list-item @tap="gotoTencentLocation" title="腾讯定位sdk集成示例" class="itemButton" :clickable="true" link/>
<uni-list-item @tap="gotoToast" title="Toast示例" class="itemButton" :clickable="true" link/>
<uni-list-item @tap="gotoLottie" title="Lottie动画示例" class="itemButton" :clickable="true" link/>
</uni-list>
</view>
</template>
<script>
import {
checkHasIntegration
} from "@/uni_modules/uts-tencentgeolocation";
import {
checkHasLottieIntegration
} from "@/uni_modules/uts-animation-view";
export default {
data() {
return {
title: 'SDK集成示例',
}
},
methods: {
gotoToast:function(e){
uni.navigateTo({
url:'/pages/SDKIntegration/Toast/Toast'
})
},
gotoLottie:function(e){
if(checkHasLottieIntegration()){
uni.navigateTo({
url:'/pages/SDKIntegration/Lottie/index'
})
}else{
uni.showToast({
icon:'none',
title:'需要在自定义基座中运行'
})
}
},
gotoTencentLocation:function(e){
let ret = checkHasIntegration();
if(!ret){
uni.showToast({
icon:'none',
title:'需要在自定义基座中运行'
})
}else{
uni.navigateTo({
url:'/pages/SDKIntegration/TencentLocation/TencentLocation'
})
}
},
gotoTencentMap:function(e){
uni.navigateTo({
url:'/pages/SDKIntegration/TencentMap/TencentMap'
})
}
}
}
</script>
<style>
</style>
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1. 腾讯定位sdk需在腾讯地图官网申请key。 https://lbs.qq.com/
</view>
<view class="uni-hello-text">
2. 按照readme文档配置apikey
</view>
<view class="uni-hello-text">
3. 需要制作自定义基座运行
</view>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="checkLocationPermission">请求定位权限</button>
<button type="primary" @tap="testGetlocation">获取设备位置信息</button>
<button type="primary" @tap="testWatchPosition">监听设备位置信息</button>
<button type="primary" @tap="testClearWatch">停止监听</button>
</view>
</view>
</template>
<script>
import {
checkHasIntegration,
requestPremission,
getLocation,
watchPosition,
clearWatch
} from "@/uni_modules/uts-tencentgeolocation";
export default {
data() {
return {
title: '腾讯定位SDK集成示例',
}
},
methods: {
checkLocationPermission: function(e) {
requestPremission();
},
testGetlocation: function(e) {
let startRet = getLocation({
geocode: true,
success: function(response) {
console.log(response);
var addressDesc = response.name + '-' + response.address
uni.showToast({
title: '执行结果:' + addressDesc,
icon: 'none'
});
},
fail: function(msg) {
uni.showToast({
title: msg,
icon: "none"
})
}
})
if (!startRet) {
uni.showToast({
title: '定位启动失败,请检查配置',
icon: 'none'
});
}
},
testWatchPosition() {
watchPosition({
geocode: true,
success: function(response) {
console.log(response);
var addressDesc = response.name + '-' + response.address
uni.showToast({
title: '执行结果:' + addressDesc,
icon: 'none'
});
},
fail: function(msg) {
uni.showToast({
title: msg,
icon: "none"
})
}
})
},
testClearWatch() {
clearWatch()
}
}
}
</script>
<style>
</style>
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text">
1.Android 平台需要自定义基座运行
</view>
</view>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="testToastShow">调用 Toast 弹窗</button>
</view>
</view>
</template>
<script>
import { showToast } from '@/uni_modules/uts-toast'
export default {
data() {
return {
title:"Toast 示例"
}
},
methods:{
testToastShow(){
let ret = showToast();
if(!ret){
uni.showToast({
icon:'none',
title:'需要在自定义基座中运行'
})
}
}
}
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<button @click="logStr">打印字符串</button>
<button @click="logFloat">打印浮点数</button>
<button @click="logInt">打印整数</button>
<button @click="logObject">打印对象</button>
<button @click="logFunction">打印函数</button>
</template>
<script>
import {
logStrTest,
logIntTest,
logFloatTest,
logObjectTest,
logFunctionTest
} from '@/uni_modules/uts-advance'
export default {
data() {
return {}
},
methods: {
logStr() {
logStrTest()
},
logFloat() {
logFloatTest()
},
logInt() {
logIntTest()
},
logObject() {
logObjectTest()
},
logFunction() {
logFunctionTest()
},
}
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<view>
<button @click="testUtsSync">点击测试uts同步方法</button>
<view>测试return:
{{ format(testUtsSyncResult) }}
</view>
<button @click="testUtsSyncWithCallback">
点击测试uts带callback的同步方法
</button>
<view>测试return:{{ format(testUtsSyncWithCallbackResult.return) }}</view>
<view>测试success:{{ format(testUtsSyncWithCallbackResult.success) }}</view>
<view>测试complete:{{ format(testUtsSyncWithCallbackResult.complete) }}</view>
<button @click="testUtsAsync">点击测试uts异步方法</button>
<view>测试return:{{ format(testUtsAsyncResult.return) }}</view>
<view>测试success:{{ format(testUtsAsyncResult.success) }}</view>
<view>测试complete:{{ format(testUtsAsyncResult.complete) }}</view>
<button @click="testUtsClassConstructor">点击测试uts class构造函数</button>
<view>测试callback:{{ format(testUtsClassConstructorResult.callback) }}</view>
<button @click="testUtsClassStaticProp">点击测试uts class静态属性</button>
<view>测试value:{{ format(testUtsClassStaticPropResult) }}</view>
<button @click="testUtsClassStaticSyncWithCallback">
点击测试uts class静态方法
</button>
<view>测试return:{{ format(testUtsClassStaticSyncWithCallbackResult.return) }}</view>
<view>测试success:{{ format(testUtsClassStaticSyncWithCallbackResult.success) }}</view>
<view>测试complete:{{ format(testUtsClassStaticSyncWithCallbackResult.complete) }}</view>
<button @click="testUtsClassStaticAsync">点击测试uts class静态异步方法</button>
<view>测试return:{{ format(testUtsClassStaticAsyncResult.return) }}</view>
<view>测试success:{{ format(testUtsClassStaticAsyncResult.success) }}</view>
<view>测试complete:{{ format(testUtsClassStaticAsyncResult.complete) }}</view>
<button @click="testUtsClassProp">点击测试uts class实例属性</button>
<view>测试value:{{ format(testUtsClassPropResult) }}</view>
<button @click="testUtsClassSyncWithCallback">
点击测试uts class实例方法
</button>
<view>测试return:{{ format(testUtsClassSyncWithCallbackResult.return) }}</view>
<view>测试success:{{ format(testUtsClassSyncWithCallbackResult.success) }}</view>
<view>测试complete:{{ format(testUtsClassSyncWithCallbackResult.complete) }}</view>
<button @click="testUtsClassAsync">点击测试uts class实例异步方法</button>
<view>测试return:{{ format(testUtsClassAsyncResult.return) }}</view>
<view>测试success:{{ format(testUtsClassAsyncResult.success) }}</view>
<view>测试complete:{{ format(testUtsClassAsyncResult.complete) }}</view>
<button @click="testUtsClassInstance">点击测试uts方法返回类实例</button>
<view>测试prop:{{ format(testUtsClassInstanceResult.prop) }}</view>
<view>测试return:{{ format(testUtsClassInstanceResult.return) }}</view>
<view>测试success:{{ format(testUtsClassInstanceResult.success) }}</view>
<view>测试complete:{{ format(testUtsClassInstanceResult.complete) }}</view>
<view>测试callback:{{ format(testUtsClassInstanceResult.callback) }}</view>
<button @click="testAll">点击测试所有</button>
</view>
</template>
<script>
import {
MAX,
testSync,
testSyncWithCallback,
testAsync,
Test,
request,
} from "../../uni_modules/uts-syntaxcase";
let test
let id = 0
export default {
data() {
return {
testUtsSyncResult: null,
testUtsSyncWithCallbackResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsAsyncResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassConstructorResult: {
callback: null
},
testUtsClassStaticPropResult: null,
testUtsClassStaticSyncWithCallbackResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassStaticAsyncResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassPropResult: null,
testUtsClassSyncWithCallbackResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassAsyncResult: {
return: null,
success: null,
fail: null,
complete: null,
},
testUtsClassInstanceResult: {
prop: null,
return: null,
success: null,
fail: null,
complete: null,
callback: null
}
}
},
methods: {
format(v) {
return v == null ? "--" : v ? "通过" : "未通过";
},
testAll() {
this.testUtsSync();
this.testUtsSyncWithCallback();
this.testUtsAsync();
this.testUtsClassConstructor();
this.testUtsClassStaticProp();
this.testUtsClassStaticSyncWithCallback();
this.testUtsClassStaticAsync();
this.testUtsClassProp();
this.testUtsClassSyncWithCallback();
this.testUtsClassAsync();
this.testUtsClassInstance();
},
testUtsSync() {
this.testUtsSyncResult = false;
try {
if (testSync("dcloud").msg === "hello dcloud") {
this.testUtsSyncResult = true;
}
} catch (e) {
console.error("testUtsSync", e);
}
},
testUtsSyncWithCallback() {
try {
this.testUtsSyncWithCallbackResult.return = false;
this.testUtsSyncWithCallbackResult.success = false;
// testUtsSyncWithCallbackResult.fail = false;
this.testUtsSyncWithCallbackResult.complete = false;
if (
testSyncWithCallback({
type: "success",
success: (res) => {
console.log("testSyncWithCallback.success.callback", res);
this.testUtsSyncWithCallbackResult.success = true;
},
fail: (res) => {
console.log("testSyncWithCallback.fail.callback", res);
// testUtsSyncWithCallbackResult.fail = true;
},
complete: (res) => {
console.log("testSyncWithCallback.complete.callback", res);
this.testUtsSyncWithCallbackResult.complete = true;
},
}).name === "testSyncWithCallback"
) {
this.testUtsSyncWithCallbackResult.return = true;
}
} catch (e) {}
},
async testUtsAsync() {
this.testUtsAsyncResult.return = false;
this.testUtsAsyncResult.success = false;
// testUtsAsyncResult.fail = false;
this.testUtsAsyncResult.complete = false;
try {
const res = await testAsync({
type: "success",
success: (res) => {
console.log("testAsync.success.callback", res);
this.testUtsAsyncResult.success = true;
},
fail: (res) => {
console.log("testAsync.fail.callback", res);
},
complete: (res) => {
console.log("testAsync.complete.callback", res);
this.testUtsAsyncResult.complete = true;
},
});
if (res.name === "testAsync") {
this.testUtsAsyncResult.return = true;
}
} catch (e) {}
},
testUtsClassConstructor() {
this.testUtsClassConstructorResult.callback = false
id++
test = new Test(id, {
name: 'name' + id,
callback: (res) => {
console.log(res)
this.testUtsClassConstructorResult.callback = true
}
})
},
testUtsClassStaticProp() {
this.testUtsClassStaticPropResult = false
if (Test.type === 'Test') {
this.testUtsClassStaticPropResult = true
}
},
testUtsClassStaticSyncWithCallback() {
try {
this.testUtsClassStaticSyncWithCallbackResult.return = false;
this.testUtsClassStaticSyncWithCallbackResult.success = false;
// testUtsClassStaticSyncWithCallbackResult.fail = false;
this.testUtsClassStaticSyncWithCallbackResult.complete = false;
if (
Test.testClassStaticSyncWithCallback({
type: "success",
success: (res) => {
console.log("testStaticSyncWithCallback.success.callback", res);
this.testUtsClassStaticSyncWithCallbackResult.success = true;
},
fail: (res) => {
console.log("testStaticSyncWithCallback.fail.callback", res);
// testUtsClassStaticSyncWithCallbackResult.fail = true;
},
complete: (res) => {
console.log("testStaticSyncWithCallback.complete.callback", res);
this.testUtsClassStaticSyncWithCallbackResult.complete = true;
},
}).name === "testSyncWithCallback"
) {
this.testUtsClassStaticSyncWithCallbackResult.return = true;
}
} catch (e) {}
},
async testUtsClassStaticAsync() {
this.testUtsClassStaticAsyncResult.return = false;
this.testUtsClassStaticAsyncResult.success = false;
// testUtsClassStaticAsyncResult.fail = false;
this.testUtsClassStaticAsyncResult.complete = false;
try {
const res = await Test.testClassStaticAsync({
type: "success",
success: (res) => {
console.log("testAsync.success.callback", res);
this.testUtsClassStaticAsyncResult.success = true;
},
fail: (res) => {
console.log("testAsync.fail.callback", res);
},
complete: (res) => {
console.log("testAsync.complete.callback", res);
this.testUtsClassStaticAsyncResult.complete = true;
},
});
if (res.name === "testAsync") {
this.testUtsClassStaticAsyncResult.return = true;
}
} catch (e) {}
},
testUtsClassProp() {
if (!test) {
this.testUtsClassConstructor()
}
this.testUtsClassPropResult = false
if (test.id > 0) {
this.testUtsClassPropResult = true
}
},
testUtsClassSyncWithCallback() {
if (!test) {
this.testUtsClassConstructor()
}
try {
this.testUtsClassSyncWithCallbackResult.return = false;
this.testUtsClassSyncWithCallbackResult.success = false;
// testUtsClassSyncWithCallbackResult.fail = false;
this.testUtsClassSyncWithCallbackResult.complete = false;
if (
test.testClassSyncWithCallback({
type: "success",
success: (res) => {
console.log("testSyncWithCallback.success.callback", res);
this.testUtsClassSyncWithCallbackResult.success = true;
},
fail: (res) => {
console.log("testSyncWithCallback.fail.callback", res);
// testUtsClassSyncWithCallbackResult.fail = true;
},
complete: (res) => {
console.log("testSyncWithCallback.complete.callback", res);
this.testUtsClassSyncWithCallbackResult.complete = true;
},
}).name === "testSyncWithCallback"
) {
this.testUtsClassSyncWithCallbackResult.return = true;
}
} catch (e) {}
},
async testUtsClassAsync() {
if (!test) {
this.testUtsClassConstructor()
}
this.testUtsClassAsyncResult.return = false;
this.testUtsClassAsyncResult.success = false;
// testUtsClassAsyncResult.fail = false;
this.testUtsClassAsyncResult.complete = false;
try {
const res = await test.testClassAsync({
type: "success",
success: (res) => {
console.log("testAsync.success.callback", res);
this.testUtsClassAsyncResult.success = true;
},
fail: (res) => {
console.log("testAsync.fail.callback", res);
},
complete: (res) => {
console.log("testAsync.complete.callback", res);
this.testUtsClassAsyncResult.complete = true;
},
});
console.log('res', res)
if (res.name === "testAsync") {
this.testUtsClassAsyncResult.return = true;
}
} catch (e) {
console.error(e)
}
},
testUtsClassInstance() {
this.testUtsClassInstanceResult.prop = false;
this.testUtsClassInstanceResult.return = false;
this.testUtsClassInstanceResult.success = false;
// testUtsClassAsyncResult.fail = false;
this.testUtsClassInstanceResult.complete = false;
this.testUtsClassInstanceResult.callback = false;
const url = 'https://dcloud.io/'
const task = request(url)
if (task.url === url && task.abort().url === url) {
this.testUtsClassInstanceResult.prop = true;
}
task.onCallback((res) => {
if (res === 'onCallback') {
this.testUtsClassInstanceResult.callback = true;
}
})
const res = task.sync({
success: (res) => {
console.log("task.sync.success.callback", res);
this.testUtsClassInstanceResult.success = true;
},
fail: (res) => {
console.log("task.sync.fail.callback", res);
},
complete: (res) => {
console.log("task.sync.complete.callback", res);
this.testUtsClassInstanceResult.complete = true;
},
})
if (res === 'sync') {
this.testUtsClassInstanceResult.return = true;
}
}
}
}
</script>
\ No newline at end of file
<template>
<button @click="inputArrayTest">传入数组参数</button>
<button @click="inputParamTest">传入复杂对象参数</button>
<button @click="returnArrayTest">返回数组参数</button>
<button @click="returnParamTest">返回复杂对象参数</button>
<button @click="callbackArrayTest">异步返回数组</button>
<button @click="callbackParamTest">异步返回复杂对象</button>
</template>
<script>
import {
inputArray,
inputParam,
returnArray,
returnParam,
callbackArray,
callbackParam,
} from '@/uni_modules/uts-advance'
export default {
data() {
return {}
},
methods: {
inputArrayTest() {
let ret = inputArray(['a', 'b', 'c'])
if (ret) {
uni.showToast({
title: '测试通过'
})
}
},
inputParamTest() {
let ret = inputParam({
title: "hello",
array: ["1", "2", "3"]
})
if (ret) {
uni.showToast({
title: '测试通过'
})
}
},
returnArrayTest() {
let ret = returnArray()
if ('["1","2","3"]' == JSON.stringify(ret)) {
uni.showToast({
title: '测试通过'
})
}
},
returnParamTest() {
let ret = returnParam()
if ('{"title":"returnParam","array":["1","2","3"]}' == JSON.stringify(ret)) {
uni.showToast({
title: '测试通过'
})
}
},
callbackArrayTest() {
callbackArray(function(res) {
if ('["8","8","8"]' == JSON.stringify(res)) {
uni.showToast({
title: '测试通过'
})
}
});
},
callbackParamTest() {
callbackParam(function(res) {
if ('{"title":"callbackParam","array":["4","5","6"]}' == JSON.stringify(res)) {
uni.showToast({
title: '测试通过'
})
}
});
}
}
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="testShowAlert">确认框</button>
<button @tap="testShowPrompt">输入框</button>
</view>
</view>
</template>
<script>
import { showAlert,showPrompt } from '@/uni_modules/uts-alert'
export default {
data() {
return {
title:"Alert 示例"
}
},
methods:{
testShowAlert(){
showAlert("提示框","这是一个提示框", (index)=> {
var title = null
if (index == 0) {
title = "点击了确认"
} else{
title = "点击了取消"
}
uni.showToast({
title: title,
icon:'none'
})
})
},
testShowPrompt() {
showPrompt("输入框","这是一个输入框","请输入内容", (content)=>{
let title = content.length > 0 ? content : "没有输入内容"
uni.showToast({
title: title,
icon:'none'
})
})
}
}
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<view>
<page-head title="监听系统截屏" accordion></page-head>
<uni-list>
<uni-list-item @tap="testScreenShotListen" title="监听截屏事件" class="itemButton" :clickable="true"/>
<uni-list-item @tap="testScreenShotOff" title="关闭截屏监听" class="itemButton" :clickable="true"/>
</uni-list>
<image :src="screenImage" mode="aspectFit" style="margin-top:10px"></image>
</view>
</template>
<script>
import {
onUserCaptureScreen,
offUserCaptureScreen
} from "@/uni_modules/uts-screenshot-listener";
export default {
data() {
return {
screenImage:""
}
},
methods: {
testScreenShotListen() {
var that = this;
onUserCaptureScreen(function(res) {
console.log(res);
if (uni.getSystemInfoSync().platform == "android") {
// 除android 之外的平台,不需要判断返回状态码
if(res.errCode == -1){
// 启动失败
return ;
}else if(res.errCode == 0){
uni.showToast({
icon:"none",
title:'截屏监听已开启'
})
}else {
uni.showToast({
icon:"none",
title:'捕获截屏事件'
})
that.screenImage = res.image
}
}else{
// 除android 之外的平台,不需要判断返回状态码
uni.showToast({
icon:"none",
title:'捕获截屏事件'
})
}
});
if (uni.getSystemInfoSync().platform != "android") {
// 除android 之外的平台,直接提示监听已开启
uni.showToast({
icon:"none",
title:'截屏监听已开启'
})
}
},
testScreenShotOff() {
var that = this;
offUserCaptureScreen(function(res) {
console.log(res);
});
// 提示已经开始监听,注意观察
uni.showToast({
icon:"none",
title:'截屏监听已关闭'
})
},
}
}
</script>
<style>
</style>
\ No newline at end of file
<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>
<template>
<view>
<page-head :title="title" accordion></page-head>
<uni-collapse accordion>
<uni-collapse-item title="延迟任务" :border="false">
<uni-list>
<uni-list-item @tap="testTimer" title="开启延迟任务" :clickable="true">
</uni-list-item>
</uni-list>
</uni-collapse-item>
<uni-collapse-item title="定时任务" :border="false">
<uni-list>
<uni-list-item @tap="testInterval" title="开启定时任务" :clickable="true">
</uni-list-item>
<uni-list-item @tap="testClearInterval" title="关闭定时任务" :clickable="true">
</uni-list-item>
</uni-list>
</uni-collapse-item>
<uni-collapse-item title="语法示例" :border="false">
<uni-list>
<uni-list-item @tap="testSyntax" title="进阶语法示例" :clickable="true" link>
</uni-list-item>
<uni-list-item @tap="testParams" title="参数传递示例" :clickable="true" link>
</uni-list-item>
<uni-list-item @tap="testConsole" title="日志打印示例" :clickable="true" link>
</uni-list-item>
</uni-list>
</uni-collapse-item>
<uni-collapse-item title="资源加载示例" :border="false">
<uni-list>
<uni-list-item @tap="gotoResourceDemo" title="图片加载示例" :clickable="true" link>
</uni-list-item>
</uni-list>
</uni-collapse-item>
<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>
<uni-collapse-item title="android平台示例" :border="false">
<uni-list>
<uni-list-item @tap="testLifecyle" title="activity生命周期监听" :clickable="true" link />
<uni-list-item @tap="testAssetLoad" title="播放asset音频(需自定义基座)" :clickable="true" link/>
<uni-list-item @tap="gotoDecorView" title="操作DecorView" :clickable="true" link />
<uni-list-item @tap="testMetaRead" title="读取meta配置" :clickable="true" />
<uni-list-item @tap="testQuitApp" title="退出当前应用" :clickable="true" />
</uni-list>
</uni-collapse-item>
<uni-collapse-item title="iOS平台示例" :border="false">
<uni-list>
<uni-list-item @tap="testGetResourcePath" title="资源路径获取示例" :clickable="true" link />
</uni-list>
</uni-collapse-item>
</uni-collapse>
</view>
</template>
<script>
import {
doTimerTask,
doIntervalTask,
clearIntervalTask,
playAssetAudio,
getMetaConfig,
quitApp
} from "../../uni_modules/uts-advance";
export default {
data() {
return {
title: 'UTS进阶示例',
taskId: 0,
}
},
methods: {
/**
* 测试延迟任务
*/
testTimer: function() {
doTimerTask({
start: function(response) {
uni.showToast({
title: response,
icon: 'none'
});
},
work: function(response) {
uni.showToast({
title: response,
icon: 'none'
});
},
});
},
/**
* 测试周期任务
*/
testInterval: function() {
var ret = doIntervalTask({
start: function(response) {
uni.showToast({
title: response,
icon: 'none'
});
},
work: function(response) {
uni.showToast({
title: response,
icon: 'none'
});
},
});
this.taskId = ret.taskId;
},
/**
* 取消周期任务
*/
testClearInterval: function() {
console.log(this.taskId);
clearIntervalTask(this.taskId);
},
/**
* 跳转至资源加载演示界面
*/
gotoResourceDemo: function() {
uni.navigateTo({
url: '/pages/resource/resource'
})
},
gotoDecorView: function() {
uni.navigateTo({
url: '/pages/advance/android/decorview'
})
},
testAssetLoad() {
// playAssetAudio();
uni.navigateTo({
url: '/pages/advance/android/assetaudio'
})
},
testInputDialog() {
getUserInput(function(res){
console.log(res);
});
},
testQuitApp(){
quitApp()
},
testMetaRead() {
let ret = getMetaConfig();
uni.showToast({
icon:"none",
title: '读取成功,注意查看控制台输出'
});
console.log(ret);
},
testLifecyle: function() {
uni.navigateTo({
url: '/pages/lifecycle/lifecycle'
})
},
testHelloUTSComponent: function() {
uni.navigateTo({
url: '/pages/component/helloView'
})
},
testSyntax: function() {
uni.navigateTo({
url: '/pages/SyntaxCase/index'
})
},
testParams: function() {
uni.navigateTo({
url: '/pages/SyntaxCase/paramTest'
})
},
testConsole: function() {
uni.navigateTo({
url: '/pages/SyntaxCase/consoleTest'
})
},
testGetResourcePath: function() {
uni.navigateTo({
url: '/pages/advance/iOS/getResourcePath'
})
}
}
}
</script>
<style>
</style>
<template>
<view>
<page-head title="asset 音频播放示例" accordion></page-head>
<uni-list>
<uni-list-item title="播放asset音频" :clickable="true" @tap="testStart"></uni-list-item>
<uni-list-item title="停止播放asset音频" :clickable="true" @tap="testStop"></uni-list-item>
</uni-list>
</view>
</template>
<script>
import {
playAssetAudio,
stopAssetAudio
} from "../../../uni_modules/uts-advance";
export default {
data() {
return {
}
},
methods: {
/**
* 测试添加View实例至顶层容器
*/
testStart: function() {
playAssetAudio();
},
/**
* 测试移除顶层容器的View实例
*/
testStop: function() {
stopAssetAudio();
}
}
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<view>
<page-head title="DecorView示例" accordion></page-head>
<uni-list>
<uni-list-item title="添加TextView至视图顶层" :clickable="true" @tap="testAddToDecorView"></uni-list-item>
<uni-list-item title="移除视图顶层的TextView" :clickable="true" @tap="testRemoveToDecorView"></uni-list-item>
</uni-list>
</view>
</template>
<script>
import {
addViewToDecorView,
removeViewToDecorView
} from "../../../uni_modules/uts-advance";
export default {
data() {
return {
title: 'UTS进阶示例',
}
},
methods: {
/**
* 测试添加View实例至顶层容器
*/
testAddToDecorView: function() {
addViewToDecorView();
},
/**
* 测试移除顶层容器的View实例
*/
testRemoveToDecorView: function() {
removeViewToDecorView();
}
}
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<view>
<page-head title="资源路径获取示例" accordion></page-head>
<button @tap="getResourcePath">获取本地资源路径</button>
</view>
</template>
<script>
import { getResourcePath } from '@/uni_modules/uts-advance'
import { removeExampleImageView } from '@/uni_modules/uts-advance'
export default {
onUnload() {
removeExampleImageView()
},
methods:{
getResourcePath(){
getResourcePath("/static/logo.png")
}
}
}
</script>
<style>
.text-box {
margin-bottom: 40rpx;
padding: 40rpx 0;
display: flex;
min-height: 300rpx;
background-color: #FFFFFF;
justify-content: center;
align-items: center;
text-align: center;
font-size: 30rpx;
color: #353535;
line-height: 1.8;
}
</style>
<template>
<div>
<uts-hello-view buttonText="点击按钮内容" style="width:375px;height: 375px;background-color: aqua;"></uts-hello-view>
<uts-hello-container>
<text>文本组件</text>
<image src="../../static/logo.png" mode="aspectFit"></image>
</uts-hello-container>
</div>
</template>
<script>
</script>
<style>
</style>
\ No newline at end of file
<template>
<view>
<page-head :title="title"></page-head>
<input class="uni-input" v-model="stringParam" />
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="testDoSthWithCallback">uts异步方法(无参数)</button>
<button type="primary" @tap="testDoSthWithString">uts异步方法(字符串参数)</button>
<button type="primary" @tap="testDoSthWithJSON">uts异步方法(json参数)</button>
</view>
</view>
</template>
<script>
import * as UTSHello from "../../uni_modules/uts-helloworld";
export default {
data() {
return {
title: 'UTS入门示例',
stringParam:"hello world",
}
},
methods: {
/**
* 测试无参数调用
*/
testDoSthWithCallback: function () {
UTSHello.callWithoutParam(
()=>{
uni.showToast({
title:'成功调用uts插件uts-helloworld的callWithoutParam',
icon:'none'
});
}
);
},
/**
* 测试字符串参数回调
*/
testDoSthWithString: function () {
UTSHello.callWithStringParam(
this.stringParam,
function(response){
uni.showToast({
title:'uts插件uts-helloworld的callWithStringParam方法收到了你输入的字符串:'+response,
icon:'none'
});
},
);
},
/**
* 测试json参数回调
*/
testDoSthWithJSON: function () {
var inputObject = {
inputText:this.stringParam,
errCode:0
}
UTSHello.callWithJSONParam({
input:inputObject,
success:function(response){
uni.showToast({
title:'执行结果:' + JSON.stringify(response),
icon:'none'
});
}
});
},
}
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<view>
<page-head :title="title"></page-head>
<button @tap="testGoOtherActivity">跳转选择界面</button>
<image :src="selectImage" v-if="selectImage"></image>
<button @tap="testUnRegLifecycle">取消注册周期函数</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>
</view>
</template>
<script>
import { initAppLifecycle,unRegLifecycle,goOtherActivity } from '../../uni_modules/uts-advance';
export default {
data() {
return {
title: '生命周期监听',
text: '',
selectImage:""
}
},
onLoad:function(){
let that = this;
initAppLifecycle(function(eventLog){
// 展示捕捉到的声明周期日志
that.text = that.text += eventLog;
that.text = that.text += '\n';
});
},
methods:{
testGoOtherActivity(){
var that = this;
let ret = goOtherActivity(function(file){
// 展示捕捉到的声明周期日志
console.log(file);
that.selectImage = "file://" + file;
});
if(!ret){
uni.showToast({
icon:'none',
title:'请授予权限后重试'
})
}
},
testUnRegLifecycle(){
// 取消注册生命周期
unRegLifecycle();
}
}
}
</script>
<style>
.text-box {
margin-bottom: 40rpx;
padding: 40rpx 0;
display: flex;
min-height: 300rpx;
background-color: #FFFFFF;
justify-content: center;
align-items: center;
text-align: center;
font-size: 30rpx;
color: #353535;
line-height: 1.8;
}
</style>
<template>
<view>
<page-head :title="title"></page-head>
<image :src="logo" mode="aspectFit" style="width: 100%;"></image>
</view>
</template>
<script>
import { getLogoPath } from '../../uni_modules/uts-advance'
export default {
data() {
return {
title: '资源加载示例',
logo:""
}
},
onLoad:function(){
this.logo = getLogoPath()
}
}
</script>
<style>
</style>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册