提交 e57d3b9c 编写于 作者: Y yurj26

refactor: support uvue and vue

上级 76cf1a30
/* #ifndef APP-PLUS-NVUE */
/* page {
min-height: 100%;
height: auto;
} */
/* #endif */
/* 解决头条小程序字体图标不显示问题,因为头条运行时自动插入了span标签,且有全局字体 */
/* #ifdef MP-TOUTIAO */
/* text :not(view) {
font-family: uniicons;
} */
/* #endif */
.uni-icon {
/* font-family: uniicons;
font-weight: normal; */
width: 14px;
height: 14px;
}
.uni-container {
padding: 0 15px 15px;
background-color: #f8f8f8;
}
.uni-header-logo {
/* #ifdef H5 */
display: flex;
/* #endif */
padding: 15px 15px;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 10rpx;
}
.uni-header-image {
width: 80px;
height: 80px;
}
.uni-hello-text {
margin-bottom: 20px;
color: #7A7E83;
}
.hello-text {
color: #7A7E83;
font-size: 14px;
line-height: 20px;
}
.hello-link {
color: #7A7E83;
font-size: 14px;
line-height: 20px;
}
.uni-panel {
margin-bottom: 12px;
}
.text-disabled {
color: #a0a0a0;
}
.uni-panel-h {
display: flex;
background-color: #ffffff;
flex-direction: row !important;
justify-content: space-between !important;
align-items: center !important;
padding: 12px;
}
/*
.uni-panel-h:active {
background-color: #f8f8f8;
}
*/
.uni-panel-h-on {
background-color: #f0f0f0;
}
.uni-panel-text {
color: #000000;
font-size: 14px;
font-weight: normal;
}
.uni-panel-icon {
margin-left: 15px;
color: #999999;
font-size: 14px;
font-weight: normal;
transform: rotate(0deg);
transition-duration: 0s;
transition-property: transform;
}
.uni-panel-icon-on {
transform: rotate(180deg);
}
.uni-navigate-item {
display: flex;
flex-direction: row;
align-items: center;
background-color: #FFFFFF;
border-top-style: solid;
border-top-color: #f0f0f0;
border-top-width: 1px;
padding: 12px;
justify-content: space-between;
/* #ifdef H5 */
/* cursor: pointer; */
/* #endif */
}
.uni-navigate-item-active {
background-color: #f8f8f8;
}
.uni-navigate-text {
color: #000000;
font-size: 14px;
font-weight: normal;
}
.uni-navigate-icon {
margin-left: 15px;
color: #999999;
font-size: 14px;
font-weight: normal;
}
\ No newline at end of file
此差异已折叠。
<template name="page-head"> <template name="page-head">
<view class="common-page-head"> <view class="common-page-head">
<view class="common-page-head-title">{{title}}</view> <view class="common-page-head-title-box">
</view> <text class="common-page-head-title">{{title}}</text>
</template> </view>
<script> </view>
export default { </template>
name: "page-head", <script>
props: { export default {
title: { name: "page-head",
type: String, props: {
default: "" title: {
} type: String,
} default: ""
} }
</script> }
}
</script>
<style>
.common-page-head {
display: flex;
padding: 35rpx;
flex-direction: row;
justify-content: center;
}
.common-page-head-title-box {
padding: 0 40rpx;
height: 88rpx;
border-bottom: 2rpx solid #D8D8D8;
}
.common-page-head-title {
line-height: 88rpx;
font-size: 30rpx;
color: #BEBEBE;
}
</style>
\ No newline at end of file
import App from './App' import App from './App'
// #ifndef VUE3
import Vue from 'vue'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue' import { createSSRApp } from 'vue'
export function createApp() { export function createApp() {
const app = createSSRApp(App) const app = createSSRApp(App)
return { return {
app app
} }
} }
// #endif \ No newline at end of file
\ No newline at end of file
...@@ -158,14 +158,14 @@ ...@@ -158,14 +158,14 @@
} }
}, },
{
{ "path" : "pages/SyntaxCase/basicTest",
"path": "pages/test/index", "style" :
"style": { {
"navigationBarTitleText": "", "navigationBarTitleText": "",
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
} }
], ],
......
...@@ -8,15 +8,15 @@ ...@@ -8,15 +8,15 @@
<button @tap="changeAction(1)">测试action play</button> <button @tap="changeAction(1)">测试action play</button>
<button @tap="changeAction(2)">测试action pause</button> <button @tap="changeAction(2)">测试action pause</button>
<button @tap="changeAction(3)">测试action stop</button> <button @tap="changeAction(3)">测试action stop</button>
<uts-animation-view ref="animView" :path="animUrl" :autoplay="autoplay" :loop="loop" :action="action" <!-- <uts-animation-view ref="animView" :path="animUrl" :autoplay="autoplay" :loop="loop" :action="action"
:hidden="hidden" @bindended="testAnimEnd" @click="lottieClickTest" @longpress="lottieLongpressTest" :hidden="hidden" @bindended="testAnimEnd" @click="lottieClickTest" @longpress="lottieLongpressTest"
:style="{width:widthNum+'rpx',height:heightNum+'px',background:yanse}"> :style="{width:widthNum+'rpx',height:heightNum+'px',background:yanse}">
</uts-animation-view> </uts-animation-view> -->
</div> </div>
</template> </template>
<script> <script lang="ts">
export default { export default {
data() { data() {
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
changeServerUrl: function() { changeServerUrl: function() {
this.animUrl = "https://b.bdstatic.com/miniapp/images/lottie_example_one.json" this.animUrl = "https://b.bdstatic.com/miniapp/images/lottie_example_one.json"
}, },
changeAction: function(type) { changeAction: function(type: number) {
if (type == 1) { if (type == 1) {
this.action = "play" this.action = "play"
} else if (type == 2) { } else if (type == 2) {
...@@ -61,21 +61,18 @@ ...@@ -61,21 +61,18 @@
changeLoop: function() { changeLoop: function() {
this.loop = !this.loop this.loop = !this.loop
}, },
testAnimEnd: function(res) { testAnimEnd: function() {
console.log("testAnimEnd"); console.log("testAnimEnd");
console.log(res);
}, },
changeRepeat: function(res) { changeRepeat: function() {
this.$refs["animView"].updateRepeatConfig("RESTART"); // this.$refs["animView"].updateRepeatConfig("RESTART");
}, },
lottieClickTest: function(res) { lottieClickTest: function() {
console.log("lottieClickTest"); console.log("lottieClickTest");
console.log(res);
}, },
lottieLongpressTest: function(res) { lottieLongpressTest: function() {
console.log("lottieClickTest"); console.log("lottieClickTest");
console.log(res);
}, },
} }
} }
......
<template> <template>
<view> <view class="uni-container">
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<uni-list>
<uni-list-item @tap="gotoTencentLocation" title="腾讯定位sdk集成示例" class="itemButton" :clickable="true" link/> <view class="uni-panel" v-for="(item, index) in list" :key="index">
<uni-list-item @tap="gotoToast" title="Toast示例" class="itemButton" :clickable="true" link/> <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="goDetailPage(item)"
<uni-list-item @tap="gotoLottie" title="Lottie动画示例" class="itemButton" :clickable="true" link/> hover-class="uni-navigate-item-active">
</uni-list> <text class="uni-panel-text">{{item.name}}</text>
</view> <image :src="arrowRightIcon" class="uni-icon"></image>
</template> </view>
</view>
<script> </view>
</template>
import { <script lang="ts">
checkHasIntegration // import {
} from "@/uni_modules/uts-tencentgeolocation"; // checkHasIntegration
// } from "@/uni_modules/uts-tencentgeolocation";
import {
checkHasLottieIntegration // import {
} from "@/uni_modules/uts-animation-view"; // checkHasLottieIntegration
// } from "@/uni_modules/uts-animation-view";
export default {
data() { type ListItem = {
return { name : string,
title: 'SDK集成示例', open : boolean,
} function ?: string,
}, url ?: string
methods: { }
gotoToast:function(e){ export default {
uni.navigateTo({ data() {
url:'/pages/SDKIntegration/Toast/Toast' return {
}) title: 'SDK集成示例',
},
gotoLottie:function(e){ list: [{
if(checkHasLottieIntegration()){ name: "腾讯定位sdk集成示例",
uni.navigateTo({ function: "gotoTencentLocation"
url:'/pages/SDKIntegration/Lottie/index' },
}) {
}else{ name: "Toast示例",
uni.showToast({ url: "SDKIntegration/Toast/Toast"
icon:'none', },
title:'需要在自定义基座中运行' {
}) name: "Lottie动画示例",
} function: "gotoLottie"
}
}, ] as ListItem[],
gotoTencentLocation:function(e){ arrowRightIcon: '/static/icons/arrow-right.png',
}
let ret = checkHasIntegration(); },
if(!ret){ methods: {
uni.showToast({ goDetailPage(e : ListItem) {
icon:'none', if (e.function != null) {
title:'需要在自定义基座中运行' const funName = e.function
}) switch (funName) {
}else{ case 'gotoTencentLocation':
uni.navigateTo({ this.gotoTencentLocation()
url:'/pages/SDKIntegration/TencentLocation/TencentLocation' break
}) case 'gotoLottie':
} this.gotoLottie()
break
}, }
gotoTencentMap:function(e){ return
uni.navigateTo({ }
url:'/pages/SDKIntegration/TencentMap/TencentMap' uni.navigateTo({
}) url: `/pages/${e.url!}`
} })
} },
} gotoLottie: function () {
</script> // if (checkHasLottieIntegration()) {
// uni.navigateTo({
<style> // url: '/pages/SDKIntegration/Lottie/index'
// })
</style> // } else {
// uni.showToast({
// icon: 'none',
// title: '需要在自定义基座中运行'
// })
// }
},
gotoTencentLocation: function () {
// let ret = checkHasIntegration();
// if (!ret) {
// uni.showToast({
// icon: 'none',
// title: '需要在自定义基座中运行'
// })
// } else {
// uni.navigateTo({
// url: '/pages/SDKIntegration/TencentLocation/TencentLocation'
// })
// }
},
gotoTencentMap: function () {
uni.navigateTo({
url: '/pages/SDKIntegration/TencentMap/TencentMap'
})
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
</style>
\ No newline at end of file
<template> <template>
<view> <view class="uni-container">
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<uni-list>
<uni-list-item @tap="gotoTencentLocation" title="腾讯定位sdk集成示例" class="itemButton" :clickable="true" link/> <view class="uni-panel" v-for="(item, index) in list" :key="index">
<uni-list-item @tap="gotoToast" title="Toast示例" class="itemButton" :clickable="true" link/> <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="goDetailPage(item)" hover-class="uni-navigate-item-active">
<uni-list-item @tap="gotoLottie" title="Lottie动画示例" class="itemButton" :clickable="true" link/> <text class="uni-panel-text">{{item.name}}</text>
</uni-list> <image :src="arrowRightIcon" class="uni-icon"></image>
</view> </view>
</template> </view>
</view>
<script> </template>
<script>
import { import {
checkHasIntegration checkHasIntegration
} from "@/uni_modules/uts-tencentgeolocation"; } from "@/uni_modules/uts-tencentgeolocation";
import { import {
checkHasLottieIntegration checkHasLottieIntegration
} from "@/uni_modules/uts-animation-view"; } from "@/uni_modules/uts-animation-view";
export default { export default {
data() { data() {
return { return {
title: 'SDK集成示例', title: 'SDK集成示例',
}
}, list: [{
methods: { name: "腾讯定位sdk集成示例",
function: "gotoTencentLocation"
gotoToast:function(e){ },
uni.navigateTo({ {
url:'/pages/SDKIntegration/Toast/Toast' name: "Toast示例",
}) url: "SDKIntegration/Toast/Toast"
}, },
gotoLottie:function(e){ {
if(checkHasLottieIntegration()){ name: "Lottie动画示例",
uni.navigateTo({ function: "gotoLottie"
url:'/pages/SDKIntegration/Lottie/index' }
}) ],
}else{ arrowRightIcon: '/static/icons/arrow-right.png',
uni.showToast({ }
icon:'none', },
title:'需要在自定义基座中运行' methods: {
}) goDetailPage(e) {
} if (e.function) {
this[e.function]()
}, return
gotoTencentLocation:function(e){ }
uni.navigateTo({
let ret = checkHasIntegration(); url: `/pages/${e.url}`
if(!ret){ })
uni.showToast({ },
icon:'none', gotoLottie: function(e) {
title:'需要在自定义基座中运行' if (checkHasLottieIntegration()) {
}) uni.navigateTo({
}else{ url: '/pages/SDKIntegration/Lottie/index'
uni.navigateTo({ })
url:'/pages/SDKIntegration/TencentLocation/TencentLocation' } else {
}) uni.showToast({
} icon: 'none',
title: '需要在自定义基座中运行'
}, })
gotoTencentMap:function(e){ }
uni.navigateTo({
url:'/pages/SDKIntegration/TencentMap/TencentMap' },
}) gotoTencentLocation: function(e) {
} let ret = checkHasIntegration();
} if (!ret) {
} uni.showToast({
</script> icon: 'none',
title: '需要在自定义基座中运行'
<style> })
} else {
</style> uni.navigateTo({
url: '/pages/SDKIntegration/TencentLocation/TencentLocation'
})
}
},
gotoTencentMap: function(e) {
uni.navigateTo({
url: '/pages/SDKIntegration/TencentMap/TencentMap'
})
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
.uni-container {
min-height: 100%;
}
</style>
\ No newline at end of file
...@@ -22,13 +22,13 @@ ...@@ -22,13 +22,13 @@
</template> </template>
<script> <script>
import { // import {
checkHasIntegration, // checkHasIntegration,
requestPremission, // requestPremission,
getLocation, // getLocation,
watchPosition, // watchPosition,
clearWatch // clearWatch
} from "@/uni_modules/uts-tencentgeolocation"; // } from "../../../uni_modules/uts-tencentgeolocation";
export default { export default {
data() { data() {
...@@ -38,58 +38,58 @@ ...@@ -38,58 +38,58 @@
}, },
methods: { methods: {
checkLocationPermission: function(e) { checkLocationPermission: function() {
requestPremission(); // requestPremission();
}, },
testGetlocation: function(e) { testGetlocation: function() {
let startRet = getLocation({ // let startRet = getLocation({
geocode: true, // geocode: true,
success: function(response) { // success: function(response) {
console.log(response); // console.log(response);
var addressDesc = response.name + '-' + response.address // var addressDesc = response.name + '-' + response.address
uni.showToast({ // uni.showToast({
title: '执行结果:' + addressDesc, // title: '执行结果:' + addressDesc,
icon: 'none' // icon: 'none'
}); // });
}, // },
fail: function(msg) { // fail: function(msg) {
uni.showToast({ // uni.showToast({
title: msg, // title: msg,
icon: "none" // icon: "none"
}) // })
} // }
}) // })
if (!startRet) { // if (!startRet) {
uni.showToast({ // uni.showToast({
title: '定位启动失败,请检查配置', // title: '定位启动失败,请检查配置',
icon: 'none' // icon: 'none'
}); // });
} // }
}, },
testWatchPosition() { testWatchPosition() {
watchPosition({ // watchPosition({
geocode: true, // geocode: true,
success: function(response) { // success: function(response) {
console.log(response); // console.log(response);
var addressDesc = response.name + '-' + response.address // var addressDesc = response.name + '-' + response.address
uni.showToast({ // uni.showToast({
title: '执行结果:' + addressDesc, // title: '执行结果:' + addressDesc,
icon: 'none' // icon: 'none'
}); // });
}, // },
fail: function(msg) { // fail: function(msg) {
uni.showToast({ // uni.showToast({
title: msg, // title: msg,
icon: "none" // icon: "none"
}) // })
} // }
}) // })
}, },
testClearWatch() { testClearWatch() {
clearWatch() // clearWatch()
} }
} }
} }
......
此差异已折叠。
<template>
{{ret}}
<button @click="instanceCreate">多实例创建测试</button>
</template>
<script>
import {
User
} from '@/uni_modules/uts-advance'
export default {
data() {
return {
ret:''
}
},
methods: {
instanceCreate() {
const user1 = new User("张三", 20);
let userText1 = user1.describeSelf()
const user2 = new User("李四", 30);
let userText2 = user2.describeSelf()
const user3 = new User("王五", 40);
let userText3 = user3.describeSelf()
if(userText1 == userText2 || userText1 == userText3 || userText2 == userText3){
this.ret = '测试未通过'
}else{
this.ret = '测试通过'
}
}
}
}
</script>
<style>
</style>
\ No newline at end of file
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
returnParam, returnParam,
callbackArray, callbackArray,
callbackParam, callbackParam,
ParamOptions
} from '@/uni_modules/uts-advance' } from '@/uni_modules/uts-advance'
...@@ -38,7 +39,7 @@ ...@@ -38,7 +39,7 @@
let ret = inputParam({ let ret = inputParam({
title: "hello", title: "hello",
array: ["1", "2", "3"] array: ["1", "2", "3"]
}) } as ParamOptions)
if (ret) { if (ret) {
uni.showToast({ uni.showToast({
title: '测试通过' title: '测试通过'
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
testShowAlert(){ testShowAlert(){
showAlert("提示框","这是一个提示框", (index)=> { showAlert("提示框","这是一个提示框", (index)=> {
var title = null let title:string
if (index == 0) { if (index == 0) {
title = "点击了确认" title = "点击了确认"
} else{ } else{
......
<template> <template>
<view> <view>
<page-head title="监听系统截屏" accordion></page-head> <page-head title="监听系统截屏" accordion></page-head>
<uni-list> <button @click="testScreenShotListen">监听截屏事件</button>
<uni-list-item @tap="testScreenShotListen" title="监听截屏事件" class="itemButton" :clickable="true"/> <button @click="testScreenShotOff">关闭截屏监听</button>
<uni-list-item @tap="testScreenShotOff" title="关闭截屏监听" class="itemButton" :clickable="true"/>
</uni-list>
<image :src="screenImage" mode="aspectFit" style="margin-top:10px"></image> <image :src="screenImage" mode="aspectFit" style="margin-top:10px"></image>
...@@ -47,7 +45,9 @@ ...@@ -47,7 +45,9 @@
icon:"none", icon:"none",
title:'捕获截屏事件' title:'捕获截屏事件'
}) })
that.screenImage = res.image if (res.image != null) {
that.screenImage = res.image!
}
} }
}else{ }else{
// 除android 之外的平台,不需要判断返回状态码 // 除android 之外的平台,不需要判断返回状态码
......
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
<view> <view>
<page-head title="监听系统截屏" accordion></page-head> <page-head title="监听系统截屏" accordion></page-head>
<uni-list> <button @click="testScreenShotListen">监听截屏事件</button>
<uni-list-item @tap="testScreenShotListen" title="监听截屏事件" class="itemButton" :clickable="true"/> <button @click="testScreenShotOff">关闭截屏监听</button>
<uni-list-item @tap="testScreenShotOff" title="关闭截屏监听" class="itemButton" :clickable="true"/>
</uni-list>
<image :src="screenImage" mode="aspectFit" style="margin-top:10px"></image> <image :src="screenImage" mode="aspectFit" style="margin-top:10px"></image>
......
<template> <template>
<view> <view class="uni-container">
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<uni-collapse>
<uni-collapse-item title="设备相关" :border="false"> <view class="uni-panel" v-for="(item, index) in list" :key="index">
<uni-list> <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index)">
<uni-list-item @tap="testGetBatteryCapacity" title="获取电池电量" class="itemButton" :clickable="true"/> <text class="uni-panel-text">{{item.name}}</text>
</uni-list> <image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon"
</uni-collapse-item> class="uni-icon"></image>
</uni-collapse> </view>
<view class="uni-panel-c" v-if="item.open">
<uni-collapse> <view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)" hover-class="uni-navigate-item-active">
<uni-collapse-item title="系统事件" :border="false"> <text class="uni-navigate-text">{{page.name}}</text>
<uni-list> <image :src="arrowRightIcon" class="uni-icon" v-if="page.url"></image>
<uni-list-item @tap="gotoScreenListen" title="监听系统截屏" class="itemButton" :clickable="true" link/> </view>
</uni-list> </view>
</uni-collapse-item> </view>
</uni-collapse> </view>
</template>
<uni-collapse> <script lang="ts">
<uni-collapse-item title="Alert系统弹窗" :border="false"> import { gotoDemoActivity } from "@/uni_modules/uts-nativepage";
<uni-list> import { getBatteryInfo, GetBatteryInfoOptions } from "@/uni_modules/uts-getbatteryinfo";
<uni-list-item @tap="gotoAlert" title="Alert弹窗" class="itemButton" :clickable="true" link/>
</uni-list> type Page = {
</uni-collapse-item> name : string,
</uni-collapse> url ?: string
function ?: string
<uni-collapse> }
<uni-collapse-item title="android平台" :border="false"> type ListItem = {
<uni-list> name : string,
<uni-list-item @tap="testGotoDemoActivity" title="自定义activity(需自定义基座)" class="itemButton" :clickable="true" link/> open : boolean,
pages : Page[],
</uni-list> }
</uni-collapse-item> export default {
</uni-collapse> data() {
return {
title: '系统API示例',
</view>
</template> list: [{
<script> name: "设备相关",
import gotoDemoActivity from "@/uni_modules/uts-nativepage"; open: false,
import getBatteryInfo from "@/uni_modules/uts-getbatteryinfo"; pages: [{
name: "获取电池电量",
function: "testGetBatteryCapacity"
export default { }] as Page[]
data() { },
return { {
title: '系统API示例', name: "系统事件",
open: false,
} pages: [{
}, name: "监听系统截屏",
onUnload: function() {}, url: "SystemAPI/ScreenListen/screenlisten"
methods: { }] as Page[]
testGetBatteryCapacity() { },
getBatteryInfo({ {
success(res) { name: "Alert系统弹窗",
uni.showToast({ open: false,
title: "当前电量:" + res.level + '%', pages: [{
icon: 'none' name: "Alert弹窗",
}); url: "SystemAPI/Alert/alert"
} }] as Page[]
}) },
}, {
gotoScreenListen(){ name: "android平台",
uni.navigateTo({ open: false,
url:'/pages/SystemAPI/ScreenListen/screenlisten' pages: [{
}) name: "自定义activity(需自定义基座)",
}, function: "testGotoDemoActivity"
gotoAlert(){ }] as Page[]
uni.navigateTo({ }
url:'/pages/SystemAPI/Alert/alert' ] as ListItem[],
}) arrowUpIcon: '/static/icons/arrow-up.png',
}, arrowDownIcon: '/static/icons/arrow-down.png',
testGotoDemoActivity() { arrowRightIcon: '/static/icons/arrow-right.png',
let ret = gotoDemoActivity(); }
if(!ret){ },
uni.showToast({ methods: {
icon:'none', triggerCollapse(index: number) {
title:'需要在自定义基座中运行' for (var i = 0; i < this.list.length; ++i) {
}) if (index == i) {
} this.list[i].open = !this.list[i].open;
} } else {
this.list[i].open = false;
} }
} }
</script> },
goDetailPage(e: Page) {
<style> if (e.function != null) {
.screenImage{ const funName = e.function
width: 100%; switch (funName) {
height: 380px; case 'testGetBatteryCapacity':
} this.testGetBatteryCapacity()
break
</style> case 'testGotoDemoActivity':
this.testGotoDemoActivity()
break
}
return
}
uni.navigateTo({
url: `/pages/${e.url}`
})
},
testGetBatteryCapacity() {
getBatteryInfo({
success(res) {
uni.showToast({
title: "当前电量:" + (res as UTSJSONObject)['level'] + '%',
icon: 'none'
});
}
} as GetBatteryInfoOptions)
},
testGotoDemoActivity() {
let ret = gotoDemoActivity();
if (!ret) {
uni.showToast({
icon: 'none',
title: '需要在自定义基座中运行'
})
}
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
</style>
\ No newline at end of file
<template> <template>
<view> <view class="uni-container">
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<uni-collapse>
<uni-collapse-item title="设备相关" :border="false"> <view class="uni-panel" v-for="(item, index) in list" :key="index">
<uni-list> <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)">
<uni-list-item @tap="testGetBatteryCapacity" title="获取电池电量" class="itemButton" :clickable="true"/> <text class="uni-panel-text">{{item.name}}</text>
</uni-list> <image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon"
</uni-collapse-item> class="uni-icon"></image>
</uni-collapse> </view>
<view class="uni-panel-c" v-if="item.open">
<uni-collapse> <view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)" hover-class="uni-navigate-item-active">
<uni-collapse-item title="系统事件" :border="false"> <text class="uni-navigate-text">{{page.name}}</text>
<uni-list> <image :src="arrowRightIcon" class="uni-icon" v-if="page.url"></image>
<uni-list-item @tap="gotoScreenListen" title="监听系统截屏" class="itemButton" :clickable="true" link/> </view>
</uni-list> </view>
</uni-collapse-item> </view>
</uni-collapse> </view>
</template>·
<uni-collapse> <script>
<uni-collapse-item title="Alert系统弹窗" :border="false"> import { gotoDemoActivity } from "@/uni_modules/uts-nativepage";
<uni-list> import { getBatteryInfo } from "@/uni_modules/uts-getbatteryinfo";
<uni-list-item @tap="gotoAlert" title="Alert弹窗" class="itemButton" :clickable="true" link/>
</uni-list> export default {
</uni-collapse-item> data() {
</uni-collapse> return {
title: '系统API示例',
<uni-collapse>
<uni-collapse-item title="android平台" :border="false"> list: [{
<uni-list> name: "设备相关",
<uni-list-item @tap="testGotoDemoActivity" title="自定义activity(需自定义基座)" class="itemButton" :clickable="true" link/> open: false,
pages: [{
</uni-list> name: "获取电池电量",
</uni-collapse-item> function: "testGetBatteryCapacity"
</uni-collapse> }]
},
{
</view> name: "系统事件",
</template> open: false,
<script> pages: [{
import gotoDemoActivity from "@/uni_modules/uts-nativepage"; name: "监听系统截屏",
import getBatteryInfo from "@/uni_modules/uts-getbatteryinfo"; url: "SystemAPI/ScreenListen/screenlisten"
}]
},
export default { {
data() { name: "Alert系统弹窗",
return { open: false,
title: '系统API示例', pages: [{
name: "Alert弹窗",
} url: "SystemAPI/Alert/alert"
}, }]
onUnload: function() {}, },
methods: { {
testGetBatteryCapacity() { name: "android平台",
getBatteryInfo({ open: false,
success(res) { pages: [{
uni.showToast({ name: "自定义activity(需自定义基座)",
title: "当前电量:" + res.level + '%', function: "testGotoDemoActivity"
icon: 'none' }]
}); }
} ],
}) arrowUpIcon: '/static/icons/arrow-up.png',
}, arrowDownIcon: '/static/icons/arrow-down.png',
gotoScreenListen(){ arrowRightIcon: '/static/icons/arrow-right.png',
uni.navigateTo({ }
url:'/pages/SystemAPI/ScreenListen/screenlisten' },
}) methods: {
}, triggerCollapse(index) {
gotoAlert(){ for (var i = 0; i < this.list.length; ++i) {
uni.navigateTo({ if (index == i) {
url:'/pages/SystemAPI/Alert/alert' this.list[i].open = !this.list[i].open;
}) } else {
}, this.list[i].open = false;
testGotoDemoActivity() { }
let ret = gotoDemoActivity(); }
if(!ret){ },
uni.showToast({ goDetailPage(e) {
icon:'none', if (e.function) {
title:'需要在自定义基座中运行' this[e.function]()
}) return
} }
} uni.navigateTo({
url: `/pages/${e.url}`
} })
} },
</script>
testGetBatteryCapacity() {
<style> getBatteryInfo({
.screenImage{ success(res) {
width: 100%; uni.showToast({
height: 380px; title: "当前电量:" + res.level + '%',
} icon: 'none'
});
</style> }
})
},
testGotoDemoActivity() {
let ret = gotoDemoActivity();
if (!ret) {
uni.showToast({
icon: 'none',
title: '需要在自定义基座中运行'
})
}
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
.uni-container {
min-height: 100%;
}
</style>
\ No newline at end of file
<template> <template>
<view> <view class="uni-container">
<page-head :title="title" accordion></page-head> <page-head :title="title"></page-head>
<view class="uni-panel" v-for="(item, index) in list" :key="index">
<uni-collapse accordion> <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index)">
<uni-collapse-item title="延迟任务" :border="false"> <text class="uni-panel-text">{{item.name}}</text>
<uni-list> <image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon"
<uni-list-item @tap="testTimer" title="开启延迟任务" :clickable="true"> class="uni-icon"></image>
</uni-list-item> </view>
</uni-list> <view class="uni-panel-c" v-if="item.open">
</uni-collapse-item> <view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)"
hover-class="uni-navigate-item-active">
<uni-collapse-item title="定时任务" :border="false"> <text class="uni-navigate-text">{{page.name}}</text>
<image :src="arrowRightIcon" class="uni-icon" v-if="page.url"></image>
<uni-list> </view>
<uni-list-item @tap="testInterval" title="开启定时任务" :clickable="true"> </view>
</uni-list-item> </view>
<uni-list-item @tap="testClearInterval" title="关闭定时任务" :clickable="true"> </view>
</uni-list-item> </template>
</uni-list> <script lang="ts">
</uni-collapse-item> import {
<uni-collapse-item title="语法示例" :border="false"> doTimerTask,
<uni-list> doIntervalTask,
<uni-list-item @tap="testSyntax" title="进阶语法示例" :clickable="true" link> clearIntervalTask,
</uni-list-item> getMetaConfig,
<uni-list-item @tap="testParams" title="参数传递示例" :clickable="true" link> quitApp,
</uni-list-item> TimerOptions
<uni-list-item @tap="testConsole" title="日志打印示例" :clickable="true" link> } from "../../uni_modules/uts-advance";
</uni-list-item>
</uni-list> type Page = {
</uni-collapse-item> name : string,
<uni-collapse-item title="资源加载示例" :border="false"> url ?: string
<uni-list> function ?: string
<uni-list-item @tap="gotoResourceDemo" title="图片加载示例" :clickable="true" link> }
</uni-list-item> type ListItem = {
</uni-list> name : string,
</uni-collapse-item> open : boolean,
<uni-collapse-item title="组件开发示例" :border="false"> pages : Page[],
}
<uni-list> export default {
<uni-list-item @tap="testHelloUTSComponent" title="Hello UTS Component" :clickable="true" link /> data() {
return {
</uni-list> title: 'UTS进阶示例',
taskId: 0,
</uni-collapse-item>
list: [{
<uni-collapse-item title="android平台示例" :border="false"> name: "延迟任务",
open: false,
<uni-list> pages: [{
name: "开启延迟任务",
<uni-list-item @tap="testLifecyle" title="activity生命周期监听" :clickable="true" link /> function: "testTimer"
<uni-list-item @tap="testAssetLoad" title="播放asset音频(需自定义基座)" :clickable="true" link/> }] as Page[]
<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" /> name: "定时任务",
</uni-list> open: false,
pages: [{
</uni-collapse-item> name: "开启定时任务",
function: "testInterval"
<uni-collapse-item title="iOS平台示例" :border="false"> }, {
<uni-list> name: "关闭定时任务",
<uni-list-item @tap="testGetResourcePath" title="资源路径获取示例" :clickable="true" link /> function: "testClearInterval"
</uni-list> }] as Page[]
</uni-collapse-item> },
</uni-collapse> {
name: "语法示例",
open: false,
</view> pages: [{
</template> name: "进阶语法示例",
<script> url: "SyntaxCase/index"
import { }, {
doTimerTask, name: "参数传递示例",
doIntervalTask, url: "SyntaxCase/paramTest"
clearIntervalTask, }, {
playAssetAudio, name: "日志打印示例",
getMetaConfig, url: "SyntaxCase/consoleTest"
quitApp }, {
} from "../../uni_modules/uts-advance"; name: "实例测试示例",
url: "SyntaxCase/instanceTest"
}, {
export default { name: "基础语法测试例",
data() { url: "SyntaxCase/basicTest"
return { }] as Page[]
title: 'UTS进阶示例', },
taskId: 0, {
} name: "资源加载示例",
}, open: false,
pages: [{
methods: { name: "图片加载示例",
url: "resource/resource"
/** }, {
* 测试延迟任务 name: "文件读取示例",
*/ url: "resource/fileRead"
testTimer: function() { }] as Page[]
doTimerTask({ },
start: function(response) { {
uni.showToast({ name: "组件开发示例",
title: response, open: false,
icon: 'none' pages: [{
}); name: "Hello UTS Component",
}, url: "component/helloView"
work: function(response) { }] as Page[]
uni.showToast({ },
title: response, {
icon: 'none' name: "android平台示例",
}); open: false,
}, pages: [{
}); name: "activity生命周期监听",
}, url: "lifecycle/lifecycle"
/** }, {
* 测试周期任务 name: "播放asset音频(需自定义基座)",
*/ url: "advance/android/assetaudio"
testInterval: function() { }, {
var ret = doIntervalTask({ name: "操作DecorView",
start: function(response) { url: "advance/android/decorview"
uni.showToast({ }, {
title: response, name: "读取meta配置",
icon: 'none' function: "testMetaRead"
}); }, {
}, name: "退出当前应用",
work: function(response) { function: "testQuitApp"
uni.showToast({ }] as Page[]
title: response, },
icon: 'none' {
}); name: "iOS平台示例",
}, open: false,
}); pages: [{
this.taskId = ret.taskId; name: "资源路径获取示例",
}, url: "advance/iOS/getResourcePath"
/** }] as Page[]
* 取消周期任务 },
*/ ] as ListItem[],
testClearInterval: function() { arrowUpIcon: '/static/icons/arrow-up.png',
console.log(this.taskId); arrowDownIcon: '/static/icons/arrow-down.png',
clearIntervalTask(this.taskId); arrowRightIcon: '/static/icons/arrow-right.png',
}, }
},
methods: {
/** triggerCollapse(index : number) {
* 跳转至资源加载演示界面 for (var i = 0; i < this.list.length; ++i) {
*/ if (index == i) {
gotoResourceDemo: function() { this.list[i].open = !this.list[i].open;
uni.navigateTo({ } else {
url: '/pages/resource/resource' this.list[i].open = false;
}) }
}, }
gotoDecorView: function() { },
uni.navigateTo({ goDetailPage(e : Page) {
url: '/pages/advance/android/decorview' if (e.function != null) {
}) const funName = e.function
}, switch (funName) {
testAssetLoad() { case 'testTimer':
// playAssetAudio(); this.testTimer()
uni.navigateTo({ break
url: '/pages/advance/android/assetaudio' case 'testInterval':
}) this.testInterval()
}, break
testInputDialog() { case 'testClearInterval':
getUserInput(function(res){ this.testClearInterval()
console.log(res); break
}); case 'testMetaRead':
}, this.testMetaRead()
testQuitApp(){ break
quitApp() case 'testQuitApp':
}, this.testQuitApp()
break
testMetaRead() { }
let ret = getMetaConfig(); return
uni.showToast({ }
icon:"none", uni.navigateTo({
title: '读取成功,注意查看控制台输出' url: `/pages/${e.url}`
}); })
console.log(ret); },
},
testLifecyle: function() { /**
uni.navigateTo({ * 测试延迟任务
url: '/pages/lifecycle/lifecycle' */
}) testTimer: function () {
}, doTimerTask({
testHelloUTSComponent: function() { start: function (response) {
uni.navigateTo({ uni.showToast({
url: '/pages/component/helloView' title: response,
}) icon: 'none'
}, });
testSyntax: function() { },
uni.navigateTo({ work: function (response) {
url: '/pages/SyntaxCase/index' uni.showToast({
}) title: response,
}, icon: 'none'
testParams: function() { });
uni.navigateTo({ },
url: '/pages/SyntaxCase/paramTest' } as TimerOptions);
}) },
}, /**
testConsole: function() { * 测试周期任务
uni.navigateTo({ */
url: '/pages/SyntaxCase/consoleTest' testInterval: function () {
}) var ret = doIntervalTask({
}, start: function (response) {
testGetResourcePath: function() { uni.showToast({
uni.navigateTo({ title: response,
url: '/pages/advance/iOS/getResourcePath' icon: 'none'
}) });
} },
work: function (response) {
} uni.showToast({
} title: response,
</script> icon: 'none'
});
<style> },
} as TimerOptions);
</style> if (ret.taskId != null) {
this.taskId = ret.taskId!;
}
},
/**
* 取消周期任务
*/
testClearInterval: function () {
console.log(this.taskId);
clearIntervalTask(this.taskId);
},
// testInputDialog() {
// getUserInput(function (res) {
// console.log(res);
// });
// },
testQuitApp() {
quitApp()
},
testMetaRead() {
let ret = getMetaConfig();
uni.showToast({
icon: "none",
title: '读取成功,注意查看控制台输出'
});
console.log(ret);
}
}
}
</script>
<style>
@import '@/common/uni-uvue.css';
</style>
\ No newline at end of file
<template> <template>
<view> <view class="uni-container">
<page-head :title="title" accordion></page-head> <page-head :title="title"></page-head>
<view class="uni-panel" v-for="(item, index) in list" :key="index">
<uni-collapse accordion> <view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index, item)">
<uni-collapse-item title="延迟任务" :border="false"> <text class="uni-panel-text">{{item.name}}</text>
<uni-list> <image :src="item.pages.length > 0 ? item.open ? arrowUpIcon : arrowDownIcon : arrowRightIcon"
<uni-list-item @tap="testTimer" title="开启延迟任务" :clickable="true"> class="uni-icon"></image>
</uni-list-item> </view>
</uni-list> <view class="uni-panel-c" v-if="item.open">
</uni-collapse-item> <view class="uni-navigate-item" v-for="(page,key) in item.pages" :key="key" @click="goDetailPage(page)" hover-class="uni-navigate-item-active">
<text class="uni-navigate-text">{{page.name}}</text>
<uni-collapse-item title="定时任务" :border="false"> <image :src="arrowRightIcon" class="uni-icon" v-if="page.url"></image>
</view>
<uni-list> </view>
<uni-list-item @tap="testInterval" title="开启定时任务" :clickable="true"> </view>
</uni-list-item> </view>
<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-item @tap="testInstance" title="实例测试示例" :clickable="true" link>
</uni-list-item>
<uni-list-item @tap="testGrammar" 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-item @tap="gotoFileReadDemo" 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> </template>
<script> <script>
import { import {
doTimerTask, doTimerTask,
doIntervalTask, doIntervalTask,
clearIntervalTask, clearIntervalTask,
playAssetAudio, playAssetAudio,
getMetaConfig, getMetaConfig,
quitApp quitApp
} from "../../uni_modules/uts-advance"; } from "../../uni_modules/uts-advance";
export default {
export default { data() {
data() { return {
return { title: 'UTS进阶示例',
title: 'UTS进阶示例', taskId: 0,
taskId: 0,
} list: [{
}, name: "延迟任务",
open: false,
methods: { pages: [{
name: "开启延迟任务",
/** function: "testTimer"
* 测试延迟任务 }]
*/ },
testTimer: function() { {
doTimerTask({ name: "定时任务",
start: function(response) { open: false,
uni.showToast({ pages: [{
title: response, name: "开启定时任务",
icon: 'none' function: "testInterval"
}); }, {
}, name: "关闭定时任务",
work: function(response) { function: "testClearInterval"
uni.showToast({ }]
title: response, },
icon: 'none' {
}); name: "语法示例",
}, open: false,
}); pages: [{
}, name: "进阶语法示例",
/** url: "SyntaxCase/index"
* 测试周期任务 }, {
*/ name: "参数传递示例",
testInterval: function() { url: "SyntaxCase/paramTest"
var ret = doIntervalTask({ }, {
start: function(response) { name: "日志打印示例",
uni.showToast({ url: "SyntaxCase/consoleTest"
title: response, },{
icon: 'none' name: "实例测试示例",
}); url: "SyntaxCase/instanceTest"
}, }, {
work: function(response) { name: "基础语法测试例",
uni.showToast({ url: "SyntaxCase/basicTest"
title: response, }]
icon: 'none' },
}); {
}, name: "资源加载示例",
}); open: false,
this.taskId = ret.taskId; pages: [{
}, name: "图片加载示例",
/** url: "resource/resource"
* 取消周期任务 },{
*/ name: "文件读取示例",
testClearInterval: function() { url: "resource/fileRead"
console.log(this.taskId); }]
clearIntervalTask(this.taskId); },
}, {
name: "组件开发示例",
open: false,
/** pages: [{
* 跳转至资源加载演示界面 name: "Hello UTS Component",
*/ url: "component/helloView"
gotoResourceDemo: function() { }]
uni.navigateTo({ },
url: '/pages/resource/resource' {
}) name: "android平台示例",
}, open: false,
gotoFileReadDemo: function() { pages: [{
uni.navigateTo({ name: "activity生命周期监听",
url: '/pages/resource/fileRead' url: "lifecycle/lifecycle"
}) }, {
}, name: "播放asset音频(需自定义基座)",
gotoDecorView: function() { url: "advance/android/assetaudio"
uni.navigateTo({ }, {
url: '/pages/advance/android/decorview' name: "操作DecorView",
}) url: "advance/android/decorview"
}, }, {
testAssetLoad() { name: "读取meta配置",
// playAssetAudio(); function: "testMetaRead"
uni.navigateTo({ }, {
url: '/pages/advance/android/assetaudio' name: "退出当前应用",
}) function: "testQuitApp"
}, }]
testInputDialog() { },
getUserInput(function(res){ {
console.log(res); name: "iOS平台示例",
}); open: false,
}, pages: [{
testQuitApp(){ name: "资源路径获取示例",
quitApp() url: "advance/iOS/getResourcePath"
}, }]
},
testMetaRead() { ],
let ret = getMetaConfig(); arrowUpIcon: '/static/icons/arrow-up.png',
uni.showToast({ arrowDownIcon: '/static/icons/arrow-down.png',
icon:"none", arrowRightIcon: '/static/icons/arrow-right.png',
title: '读取成功,注意查看控制台输出' }
}); },
console.log(ret); methods: {
}, triggerCollapse(index) {
testLifecyle: function() { for (var i = 0; i < this.list.length; ++i) {
uni.navigateTo({ if (index == i) {
url: '/pages/lifecycle/lifecycle' this.list[i].open = !this.list[i].open;
}) } else {
}, this.list[i].open = false;
testHelloUTSComponent: function() { }
uni.navigateTo({ }
url: '/pages/component/helloView' },
}) goDetailPage(e) {
}, if (e.function) {
testSyntax: function() { this[e.function]()
uni.navigateTo({ return
url: '/pages/SyntaxCase/index' }
}) uni.navigateTo({
}, url: `/pages/${e.url}`
testParams: function() { })
uni.navigateTo({ },
url: '/pages/SyntaxCase/paramTest'
}) /**
}, * 测试延迟任务
testConsole: function() { */
uni.navigateTo({ testTimer: function() {
url: '/pages/SyntaxCase/consoleTest' doTimerTask({
}) start: function(response) {
}, uni.showToast({
testGrammar: function() { title: response,
uni.navigateTo({ icon: 'none'
url: '/pages/test/index' });
}) },
}, work: function(response) {
testInstance: function() { uni.showToast({
uni.navigateTo({ title: response,
url: '/pages/SyntaxCase/instanceTest' icon: 'none'
}) });
}, },
testGetResourcePath: function() { });
uni.navigateTo({ },
url: '/pages/advance/iOS/getResourcePath' /**
}) * 测试周期任务
} */
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);
},
testInputDialog() {
getUserInput(function(res) {
console.log(res);
});
},
testQuitApp() {
quitApp()
},
testMetaRead() {
let ret = getMetaConfig();
uni.showToast({
icon: "none",
title: '读取成功,注意查看控制台输出'
});
console.log(ret);
}
}
}
</script> </script>
<style> <style>
@import '@/common/uni-uvue.css';
</style>
.uni-container {
min-height: 100%;
}
</style>
\ No newline at end of file
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
<view> <view>
<page-head title="asset 音频播放示例" accordion></page-head> <page-head title="asset 音频播放示例" accordion></page-head>
<uni-list> <button @click="testStart">播放asset音频</button>
<uni-list-item title="播放asset音频" :clickable="true" @tap="testStart"></uni-list-item> <button @click="testStop">停止播放asset音频</button>
<uni-list-item title="停止播放asset音频" :clickable="true" @tap="testStop"></uni-list-item>
</uni-list>
</view> </view>
</template> </template>
......
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
<view> <view>
<page-head title="asset 音频播放示例" accordion></page-head> <page-head title="asset 音频播放示例" accordion></page-head>
<uni-list> <button @click="testStart">播放asset音频</button>
<uni-list-item title="播放asset音频" :clickable="true" @tap="testStart"></uni-list-item> <button @click="testStop">停止播放asset音频</button>
<uni-list-item title="停止播放asset音频" :clickable="true" @tap="testStop"></uni-list-item>
</uni-list>
</view> </view>
</template> </template>
......
<template> <template>
<view> <view>
<page-head title="DecorView示例" accordion></page-head> <page-head title="DecorView示例" accordion></page-head>
<uni-list> <button @click="testAddToDecorView">添加TextView至视图顶层</button>
<uni-list-item title="添加TextView至视图顶层" :clickable="true" @tap="testAddToDecorView"></uni-list-item> <button @click="testRemoveToDecorView">移除视图顶层的TextView</button>
<uni-list-item title="移除视图顶层的TextView" :clickable="true" @tap="testRemoveToDecorView"></uni-list-item>
</uni-list>
</view> </view>
</template> </template>
......
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
<view> <view>
<page-head title="DecorView示例" accordion></page-head> <page-head title="DecorView示例" accordion></page-head>
<uni-list> <button @click="testAddToDecorView">添加TextView至视图顶层</button>
<uni-list-item title="添加TextView至视图顶层" :clickable="true" @tap="testAddToDecorView"></uni-list-item> <button @click="testRemoveToDecorView">移除视图顶层的TextView</button>
<uni-list-item title="移除视图顶层的TextView" :clickable="true" @tap="testRemoveToDecorView"></uni-list-item>
</uni-list>
</view> </view>
</template> </template>
......
...@@ -5,16 +5,16 @@ ...@@ -5,16 +5,16 @@
</view> </view>
</template> </template>
<script> <script>
import { getResourcePath } from '@/uni_modules/uts-advance' // import { getResourcePath } from '@/uni_modules/uts-advance'
import { removeExampleImageView } from '@/uni_modules/uts-advance' // import { removeExampleImageView } from '@/uni_modules/uts-advance'
export default { export default {
onUnload() { onUnload() {
removeExampleImageView() // removeExampleImageView()
}, },
methods:{ methods:{
getResourcePath(){ getResourcePath(){
getResourcePath("/static/logo.png") // getResourcePath("/static/logo.png")
} }
} }
} }
......
<template> <template>
<div> <view>
<uts-hello-view buttonText="点击按钮内容" style="width:375px;height: 375px;background-color: aqua;"></uts-hello-view> <uts-hello-view buttonText="点击按钮内容" style="width:375px;height: 375px;background-color: aqua;"></uts-hello-view>
<uts-hello-container> <uts-hello-container>
<text>文本组件</text> <text>文本组件</text>
<image src="../../static/logo.png" mode="aspectFit"></image> <image src="../../static/logo.png" mode="aspectFit"></image>
</uts-hello-container> </uts-hello-container>
</div> </view>
</template> </template>
......
<template> <template>
<view> <view>
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<input class="uni-input" v-model="stringParam" /> <input class="uni-input" v-model="stringParam" />
<view class="uni-btn-v uni-common-mt"> <view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="testDoSthWithCallback">uts异步方法(无参数)</button> <button type="primary" @tap="testDoSthWithCallback">uts异步方法(无参数)</button>
<button type="primary" @tap="testDoSthWithString">uts异步方法(字符串参数)</button> <button type="primary" @tap="testDoSthWithString">uts异步方法(字符串参数)</button>
<button type="primary" @tap="testDoSthWithJSON">uts异步方法(json参数)</button> <button type="primary" @tap="testDoSthWithJSON">uts异步方法(json参数)</button>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
import * as UTSHello from "../../uni_modules/uts-helloworld"; import { callWithJSONParam, callWithStringParam, callWithoutParam, JsonParamOptions, inputJSON } from "../../uni_modules/uts-helloworld";
export default { export default {
data() { data() {
return { return {
title: 'UTS入门示例', title: 'UTS入门示例',
stringParam:"hello world", stringParam: "hello world",
} }
}, },
methods: { methods: {
/** /**
* 测试无参数调用 * 测试无参数调用
*/ */
testDoSthWithCallback: function () { testDoSthWithCallback: function () {
UTSHello.callWithoutParam( callWithoutParam(
()=>{ () => {
uni.showToast({ uni.showToast({
title:'成功调用uts插件uts-helloworld的callWithoutParam', title: '成功调用uts插件uts-helloworld的callWithoutParam',
icon:'none' icon: 'none'
}); });
} }
); );
}, },
/** /**
* 测试字符串参数回调 * 测试字符串参数回调
*/ */
testDoSthWithString: function () { testDoSthWithString: function () {
UTSHello.callWithStringParam( callWithStringParam(
this.stringParam, this.stringParam,
function(response){ function (response) {
uni.showToast({ uni.showToast({
title:'uts插件uts-helloworld的callWithStringParam方法收到了你输入的字符串:'+response, title: 'uts插件uts-helloworld的callWithStringParam方法收到了你输入的字符串:' + response,
icon:'none' icon: 'none'
}); });
}, },
); );
}, },
/** /**
* 测试json参数回调 * 测试json参数回调
*/ */
testDoSthWithJSON: function () { testDoSthWithJSON: function () {
var inputObject = { const that = this
inputText:this.stringParam, var inputObject : inputJSON = {
errCode:0 inputText: that.stringParam,
} errCode: 0
}
UTSHello.callWithJSONParam({
input:inputObject, callWithJSONParam({
success:function(response){ input: inputObject,
uni.showToast({ success: function (response) {
title:'执行结果:' + JSON.stringify(response), uni.showToast({
icon:'none' title: '执行结果:' + JSON.stringify(response),
}); icon: 'none'
} });
}); }
}, } as JsonParamOptions);
},
}
} }
</script> }
</script>
<style>
<style>
</style> </style>
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
</view> </view>
</template> </template>
<script> <script>
import * as UTSHello from "../../uni_modules/uts-helloworld"; import { callWithJSONParam, callWithStringParam, callWithoutParam } from "../../uni_modules/uts-helloworld";
export default { export default {
data() { data() {
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
*/ */
testDoSthWithCallback: function () { testDoSthWithCallback: function () {
UTSHello.callWithoutParam( callWithoutParam(
()=>{ ()=>{
uni.showToast({ uni.showToast({
title:'成功调用uts插件uts-helloworld的callWithoutParam', title:'成功调用uts插件uts-helloworld的callWithoutParam',
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
*/ */
testDoSthWithString: function () { testDoSthWithString: function () {
UTSHello.callWithStringParam( callWithStringParam(
this.stringParam, this.stringParam,
function(response){ function(response){
uni.showToast({ uni.showToast({
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
errCode:0 errCode:0
} }
UTSHello.callWithJSONParam({ callWithJSONParam({
input:inputObject, input:inputObject,
success:function(response){ success:function(response){
uni.showToast({ uni.showToast({
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
let that = this; let that = this;
initAppLifecycle(function(eventLog){ initAppLifecycle(function(eventLog){
// 展示捕捉到的声明周期日志 // 展示捕捉到的声明周期日志
that.text = that.text += eventLog; that.text += eventLog;
that.text = that.text += '\n'; that.text += '\n';
}); });
}, },
methods:{ methods:{
......
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @tap="getImageBase64">读取图片base64</button>
<button type="primary" @tap="getFileText">读取文本内容</button>
</view>
</view>
</template>
<script>
import { readFile,writeFile, ReadFileOptions, WriteFileOptions } from '../../uni_modules/uts-file-manager'
export default {
data() {
return {
title: '文件读取示例',
logo:""
}
},
methods: {
getImageBase64:function(){
readFile({
type:'base64',
path:'static/logo.png',
success:function(res){
console.log("success")
console.log(res)
},
fail:function(res){
console.log('fail')
console.log(res)
},
complete:function(res){
console.log("complete")
console.log(res)
}
} as ReadFileOptions)
},
getFileText:function(){
writeFile({
path:'/test/1.txt',
content:'锄禾日当午,汗滴禾下土,谁知盘中餐,粒粒皆辛苦',
success:function(res){
readFile({
type:'text',
path:res.filePath,
success:function(res){
console.log("success")
console.log(res)
},
fail:function(res){
console.log('fail')
console.log(res)
},
complete:function(res){
console.log("complete")
console.log(res)
}
} as ReadFileOptions)
},
fail:function(res){
console.log('fail')
console.log(res)
},
complete:function(res){
console.log("complete")
console.log(res)
}
} as WriteFileOptions)
}
}
}
</script>
<style>
</style>
此差异已折叠。
此差异已折叠。
## Badge 数字角标
> **组件名:uni-badge**
> 代码块: `uBadge`
数字角标一般和其它控件(列表、9宫格等)配合使用,用于进行数量提示,默认为实心灰色背景,
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-badge)
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
## Icons 图标
> **组件名:uni-icons**
> 代码块: `uIcons`
用于展示 icons 图标 。
### [查看文档](https://uniapp.dcloud.io/component/uniui/uni-icons)
#### 如使用过程中有任何问题,或者您对uni-ui有一些好的建议,欢迎加入 uni-ui 交流群:871950839
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册