|
|
<template> <div class="content"> <button class="btn" type="primary" @click="getDownloadFilePath()">[短视频getFilePath]</button> <button class="btn" type="primary" @click="getFileList">getFileList</button> <button class="btn" type="primary" @click="deleteAndroidFaceImage">deleteAndroidFaceImage</button> <button class="btn" type="primary" @click="gotoNativePage">跳转原生Activity</button> <button class="btn" type="primary" @click="initTcp">[开启TcpServer]</button> <button class="btn" type="primary" @click="closeTcp">[关闭TcpServer]</button> <button class="btn" type="primary" @click="getIP">[获取IP]</button> <text class="tips"> 点击后将开启TcpServer. 本机IP: 192.168.1.64 端口:16666 </text> <!-- <button type="primary" @click="testFun2">zmt-testFun2</button> --> <button class="btn" type="primary" @click="faceAsyncFunc">[百度人脸SDK授权]</button> <text class="tips"> 点击后将进行百度人脸SDK初始化及授权申请,该授权码写死在Android端zmt_module内faceClass,因已使用过,将返回已被占用提示. </text> <view class="console"> <text class="log" v-for="i in logs">{{i}}</text> </view> <button class="btn" type="primary" @click="testAsyncFunc2">uniplugin_module_ox testAsyncFunc2</button> <button class="btn" type="primary" @click="testSyncFunc2">uniplugin_module_ox testSyncFunc2</button> <button class="btn" type="primary" @click="testAsyncFunc">uniplugin_module testAsyncFunc</button> <button class="btn" type="primary" @click="testSyncFunc">uniplugin_module testSyncFunc</button> <button class="btn" type="primary" @click="liveInit">[短视频SDK测试]</button> <button class="btn" type="primary" @click="gotoLiveNativePage()">[短视频gotoLiveNativePage]</button> <button class="btn" type="primary" @click="getLicenceInfo()">[短视频getLicenceInfo]</button> <button class="btn" type="primary" @click="joinerVideo()">[短视频joinerVideo]</button> </div> </template>
<script> // #ifdef APP-PLUS
// 获取 module
var zmtModule = uni.requireNativePlugin("Zmt-Module") var testModule = uni.requireNativePlugin("TestModule") //uniplugin_module
var uniplugin_module_ox = uni.requireNativePlugin("uniplugin_module_ox") //uniplugin_module_ox
var faceModule = uni.requireNativePlugin("Face-Module") //百度人脸SDK, face_module
var TXLiveModule = uni.requireNativePlugin("TXLiveModule") //短视频SDK, TXLiveModule
const modal = uni.requireNativePlugin('modal'); // #endif
import {timeFormat} from "../../utils/timeFormat.js" import FileOperate from '../../utils/8inFileOperate.js'; export default { onLoad() { this.initAPPListener() }, onReady() { this.logs.push("当前时间:"+this.getTime()) console.log("当前时间:"+this.getTime()) }, data() { return { logs:["LOG VIEW"] } }, methods: { async getDownloadFilePath(){ console.log("getFilePath") let res = await FileOperate.getJoinSaveFilePath() this.log(res) return res }, async getFileList(){ let name = "33信息2" let res = await FileOperate.getFileChildrenList("Face-Sync") console.log(res,"000") res.map((item)=>{ if(item.split(".")[0]==name) { this.log("命中后删除") this.deleteAndroidFaceImage(item) } return item }) // res.map((item)=>{
// if(item.split(".")[0]==name) {
// this.log("命中后删除")
// this.deleteAndroidFaceImage(item)
// }
// })
}, async deleteAndroidFaceImage(name){ let res = await FileOperate.deleteAndroidFaceImage(name) this.log(res) console.log(77777,res) }, initAPPListener(){ // #ifdef APP-PLUS
let that = this // 原生平台事件监听,等待测试
plus.globalEvent.addEventListener('myEvent', function(e){ modal.toast({ message: "TestEvent收到:"+JSON.stringify(e), duration: 3.5 }); that.log("全局事件接收:"+JSON.stringify(e)) }); // #endif
}, liveInit() { this.log("执行TXLiveModule.liveInit"); // 调用异步方法
TXLiveModule.liveInit({ 'name': 'unimp', 'age': 1 }, (ret) => { modal.toast({ message: ret, duration: 1.5 }); this.log(JSON.stringify(ret)) }) }, getLicenceInfo() { // 调用异步方法
TXLiveModule.getLicenceInfo({ 'name': 'unimp', 'age': 1 }, (ret) => { modal.toast({ message: ret, duration: 1.5 }); this.log(JSON.stringify(ret)) }) }, joinerVideo() { // 调用异步方法
TXLiveModule.joinerVideo({ 'filePath': this.getDownloadFilePath(), 'joinList':['/test1.mp4','test2.mp4'] //传入需要拼接的视频文件列表
}, (ret) => { modal.toast({ message: ret, duration: 1.5 }); this.log(JSON.stringify(ret)) }) }, //百度人脸SDK,初始化,并申请授权(授权码写死在android端 faceClass)
faceAsyncFunc() { this.log("执行faceModule.faceAsyncFunc"); // 调用异步方法
faceModule.faceAsyncFunc({ 'name': 'unimp', 'age': 1 }, (ret) => { modal.toast({ message: ret, duration: 1.5 }); this.log(JSON.stringify(ret)) }) }, initTcp(){ // 调用异步方法
this.log("Click Tcp Server.") zmtModule.initTcp({ 'port':"16666", }, (ret) => { modal.toast({ message: ret, duration: 2 }); this.log("invoke:"+JSON.stringify(ret)) }) }, getIP(){ zmtModule.getIP({ }, (ret) => { modal.toast({ message: ret, duration: 2 }); this.log("invoke:"+JSON.stringify(ret)) }) }, closeTcp(){ // 调用异步方法
this.log("Click Tcp Server.") zmtModule.closeTcp({ }, (ret) => { modal.toast({ message: ret, duration: 2 }); this.log("invoke:"+JSON.stringify(ret)) }) }, testFun2(){ // 调用同步方法
var ret = zmtModule.testSyncFunc({ 'name': 'unimp', 'age': 1 }) modal.toast({ message: ret, duration: 1.5 }); }, testAsyncFunc() { // 调用异步方法
testModule.testAsyncFunc({ 'name': 'unimp', 'age': 1 }, (ret) => { modal.toast({ message: ret, duration: 1.5 }); }) }, testSyncFunc() { // 调用同步方法
var ret = testModule.testSyncFunc({ 'name': 'unimp', 'age': 1 }) modal.toast({ message: ret, duration: 1.5 }); }, testAsyncFunc2() { // 调用异步方法
uniplugin_module_ox.testAsyncFunc2({ 'name': 'unimp', 'age': 1 }, (ret) => { modal.toast({ message: ret, duration: 1.5 }); }) }, testSyncFunc2() { // 调用同步方法
var ret = uniplugin_module_ox.testSyncFunc2({ 'name': 'unimp', 'age': 1 }) modal.toast({ message: ret, duration: 1.5 }); }, //在Log View打印txt
log(txt){ this.logs.push(this.getTime()+` ${txt}`) }, //返回当前时间
getTime(){ return timeFormat(new Date(),'mm/dd hh:MM:ss') }, gotoNativePage() { testModule.gotoNativePage(); }, gotoLiveNativePage(){ TXLiveModule.gotoNativePage(); } } } </script> <style lang="scss"> .content{ // width: 750rpx;
// margin-top: 10rpx;
// display: flex;
// flex-wrap: nowrap;
// align-items: flex-start;
// flex-direction: column;
// justify-content: center;
font-size: 12px; } // button{
// margin-top: 3px;
// }
.btn{ margin: 3px; // width: 95%;
} .tips{ font-size: 11px; color: gray; font-weight: 800; } .console{ // margin-left: 25rpx;
// width: %;
// height: auto;
display: flex; flex-wrap: nowrap; flex-direction: column; align-items: flex-start; background-color: lightgray; padding: 20rpx; } .log{ color: darkred; font-size: 11px; font-weight: 800; } </style>
|