uni_android_plugin_project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

333 lines
8.0 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="content">
  3. <button class="btn" type="primary" @click="getDownloadFilePath()">[短视频getFilePath]</button>
  4. <button class="btn" type="primary" @click="getFileList">getFileList</button>
  5. <button class="btn" type="primary" @click="deleteAndroidFaceImage">deleteAndroidFaceImage</button>
  6. <button class="btn" type="primary" @click="gotoNativePage">跳转原生Activity</button>
  7. <button class="btn" type="primary" @click="initTcp">[开启TcpServer]</button>
  8. <button class="btn" type="primary" @click="closeTcp">[关闭TcpServer]</button>
  9. <button class="btn" type="primary" @click="getIP">[获取IP]</button>
  10. <text class="tips">
  11. 点击后将开启TcpServer. 本机IP: 192.168.1.64 端口16666
  12. </text>
  13. <!-- <button type="primary" @click="testFun2">zmt-testFun2</button> -->
  14. <button class="btn" type="primary" @click="faceAsyncFunc">[百度人脸SDK授权]</button>
  15. <text class="tips">
  16. 点击后将进行百度人脸SDK初始化及授权申请,该授权码写死在Android端zmt_module内faceClass,因已使用过,将返回已被占用提示.
  17. </text>
  18. <view class="console">
  19. <text class="log" v-for="i in logs">{{i}}</text>
  20. </view>
  21. <button class="btn" type="primary" @click="testAsyncFunc2">uniplugin_module_ox testAsyncFunc2</button>
  22. <button class="btn" type="primary" @click="testSyncFunc2">uniplugin_module_ox testSyncFunc2</button>
  23. <button class="btn" type="primary" @click="testAsyncFunc">uniplugin_module testAsyncFunc</button>
  24. <button class="btn" type="primary" @click="testSyncFunc">uniplugin_module testSyncFunc</button>
  25. <button class="btn" type="primary" @click="liveInit">[短视频SDK测试]</button>
  26. <button class="btn" type="primary" @click="gotoLiveNativePage()">[短视频gotoLiveNativePage]</button>
  27. <button class="btn" type="primary" @click="getLicenceInfo()">[短视频getLicenceInfo]</button>
  28. <button class="btn" type="primary" @click="joinerVideo()">[短视频joinerVideo]</button>
  29. </div>
  30. </template>
  31. <script>
  32. // #ifdef APP-PLUS
  33. // 获取 module
  34. var zmtModule = uni.requireNativePlugin("Zmt-Module")
  35. var testModule = uni.requireNativePlugin("TestModule") //uniplugin_module
  36. var uniplugin_module_ox = uni.requireNativePlugin("uniplugin_module_ox") //uniplugin_module_ox
  37. var faceModule = uni.requireNativePlugin("Face-Module") //百度人脸SDK, face_module
  38. var TXLiveModule = uni.requireNativePlugin("TXLiveModule") //短视频SDK, TXLiveModule
  39. const modal = uni.requireNativePlugin('modal');
  40. // #endif
  41. import {timeFormat} from "../../utils/timeFormat.js"
  42. import FileOperate from '../../utils/8inFileOperate.js';
  43. export default {
  44. onLoad() {
  45. this.initAPPListener()
  46. },
  47. onReady() {
  48. this.logs.push("当前时间:"+this.getTime())
  49. console.log("当前时间:"+this.getTime())
  50. },
  51. data() {
  52. return {
  53. logs:["LOG VIEW"]
  54. }
  55. },
  56. methods: {
  57. async getDownloadFilePath(){
  58. console.log("getFilePath")
  59. let res = await FileOperate.getJoinSaveFilePath()
  60. this.log(res)
  61. return res
  62. },
  63. async getFileList(){
  64. let name = "33信息2"
  65. let res = await FileOperate.getFileChildrenList("Face-Sync")
  66. console.log(res,"000")
  67. res.map((item)=>{
  68. if(item.split(".")[0]==name) {
  69. this.log("命中后删除")
  70. this.deleteAndroidFaceImage(item)
  71. }
  72. return item
  73. })
  74. // res.map((item)=>{
  75. // if(item.split(".")[0]==name) {
  76. // this.log("命中后删除")
  77. // this.deleteAndroidFaceImage(item)
  78. // }
  79. // })
  80. },
  81. async deleteAndroidFaceImage(name){
  82. let res = await FileOperate.deleteAndroidFaceImage(name)
  83. this.log(res)
  84. console.log(77777,res)
  85. },
  86. initAPPListener(){
  87. // #ifdef APP-PLUS
  88. let that = this
  89. // 原生平台事件监听,等待测试
  90. plus.globalEvent.addEventListener('myEvent', function(e){
  91. modal.toast({
  92. message: "TestEvent收到:"+JSON.stringify(e),
  93. duration: 3.5
  94. });
  95. that.log("全局事件接收:"+JSON.stringify(e))
  96. });
  97. // #endif
  98. },
  99. liveInit() {
  100. this.log("执行TXLiveModule.liveInit");
  101. // 调用异步方法
  102. TXLiveModule.liveInit({
  103. 'name': 'unimp',
  104. 'age': 1
  105. },
  106. (ret) => {
  107. modal.toast({
  108. message: ret,
  109. duration: 1.5
  110. });
  111. this.log(JSON.stringify(ret))
  112. })
  113. },
  114. getLicenceInfo() {
  115. // 调用异步方法
  116. TXLiveModule.getLicenceInfo({
  117. 'name': 'unimp',
  118. 'age': 1
  119. },
  120. (ret) => {
  121. modal.toast({
  122. message: ret,
  123. duration: 1.5
  124. });
  125. this.log(JSON.stringify(ret))
  126. })
  127. },
  128. joinerVideo() {
  129. // 调用异步方法
  130. TXLiveModule.joinerVideo({
  131. 'filePath': this.getDownloadFilePath(),
  132. 'joinList':['/test1.mp4','test2.mp4'] //传入需要拼接的视频文件列表
  133. },
  134. (ret) => {
  135. modal.toast({
  136. message: ret,
  137. duration: 1.5
  138. });
  139. this.log(JSON.stringify(ret))
  140. })
  141. },
  142. //百度人脸SDK,初始化,并申请授权(授权码写死在android端 faceClass)
  143. faceAsyncFunc() {
  144. this.log("执行faceModule.faceAsyncFunc");
  145. // 调用异步方法
  146. faceModule.faceAsyncFunc({
  147. 'name': 'unimp',
  148. 'age': 1
  149. },
  150. (ret) => {
  151. modal.toast({
  152. message: ret,
  153. duration: 1.5
  154. });
  155. this.log(JSON.stringify(ret))
  156. })
  157. },
  158. initTcp(){
  159. // 调用异步方法
  160. this.log("Click Tcp Server.")
  161. zmtModule.initTcp({
  162. 'port':"16666",
  163. },
  164. (ret) => {
  165. modal.toast({
  166. message: ret,
  167. duration: 2
  168. });
  169. this.log("invoke:"+JSON.stringify(ret))
  170. })
  171. },
  172. getIP(){
  173. zmtModule.getIP({
  174. },
  175. (ret) => {
  176. modal.toast({
  177. message: ret,
  178. duration: 2
  179. });
  180. this.log("invoke:"+JSON.stringify(ret))
  181. })
  182. },
  183. closeTcp(){
  184. // 调用异步方法
  185. this.log("Click Tcp Server.")
  186. zmtModule.closeTcp({
  187. },
  188. (ret) => {
  189. modal.toast({
  190. message: ret,
  191. duration: 2
  192. });
  193. this.log("invoke:"+JSON.stringify(ret))
  194. })
  195. },
  196. testFun2(){
  197. // 调用同步方法
  198. var ret = zmtModule.testSyncFunc({
  199. 'name': 'unimp',
  200. 'age': 1
  201. })
  202. modal.toast({
  203. message: ret,
  204. duration: 1.5
  205. });
  206. },
  207. testAsyncFunc() {
  208. // 调用异步方法
  209. testModule.testAsyncFunc({
  210. 'name': 'unimp',
  211. 'age': 1
  212. },
  213. (ret) => {
  214. modal.toast({
  215. message: ret,
  216. duration: 1.5
  217. });
  218. })
  219. },
  220. testSyncFunc() {
  221. // 调用同步方法
  222. var ret = testModule.testSyncFunc({
  223. 'name': 'unimp',
  224. 'age': 1
  225. })
  226. modal.toast({
  227. message: ret,
  228. duration: 1.5
  229. });
  230. },
  231. testAsyncFunc2() {
  232. // 调用异步方法
  233. uniplugin_module_ox.testAsyncFunc2({
  234. 'name': 'unimp',
  235. 'age': 1
  236. },
  237. (ret) => {
  238. modal.toast({
  239. message: ret,
  240. duration: 1.5
  241. });
  242. })
  243. },
  244. testSyncFunc2() {
  245. // 调用同步方法
  246. var ret = uniplugin_module_ox.testSyncFunc2({
  247. 'name': 'unimp',
  248. 'age': 1
  249. })
  250. modal.toast({
  251. message: ret,
  252. duration: 1.5
  253. });
  254. },
  255. //在Log View打印txt
  256. log(txt){
  257. this.logs.push(this.getTime()+` ${txt}`)
  258. },
  259. //返回当前时间
  260. getTime(){
  261. return timeFormat(new Date(),'mm/dd hh:MM:ss')
  262. },
  263. gotoNativePage() {
  264. testModule.gotoNativePage();
  265. },
  266. gotoLiveNativePage(){
  267. TXLiveModule.gotoNativePage();
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="scss">
  273. .content{
  274. // width: 750rpx;
  275. // margin-top: 10rpx;
  276. // display: flex;
  277. // flex-wrap: nowrap;
  278. // align-items: flex-start;
  279. // flex-direction: column;
  280. // justify-content: center;
  281. font-size: 12px;
  282. }
  283. // button{
  284. // margin-top: 3px;
  285. // }
  286. .btn{
  287. margin: 3px;
  288. // width: 95%;
  289. }
  290. .tips{
  291. font-size: 11px;
  292. color: gray;
  293. font-weight: 800;
  294. }
  295. .console{
  296. // margin-left: 25rpx;
  297. // width: %;
  298. // height: auto;
  299. display: flex;
  300. flex-wrap: nowrap;
  301. flex-direction: column;
  302. align-items: flex-start;
  303. background-color: lightgray;
  304. padding: 20rpx;
  305. }
  306. .log{
  307. color: darkred;
  308. font-size: 11px;
  309. font-weight: 800;
  310. }
  311. </style>