112 lines
2.3 KiB
Vue
112 lines
2.3 KiB
Vue
<template>
|
|
<view class="content">
|
|
<button class="typebutton" type="primary" @click="init">初始化sdk</button>
|
|
<button class="typebutton" type="primary" @click="login">登陆</button>
|
|
<button class="typebutton" type="primary" @click="logout">退出登陆</button>
|
|
<button class="typebutton" type="primary" @click="jumptonve">跳到nvue</button>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
export default {
|
|
|
|
data() {
|
|
return {
|
|
title: 'Hello'
|
|
}
|
|
},
|
|
onLoad() {
|
|
var globalEvent = uni.requireNativePlugin('globalEvent');
|
|
globalEvent.addEventListener('myEvent', function(e) {
|
|
console.log('myEvent' + JSON.stringify(e));
|
|
uni.showToast({
|
|
title: 'myEvent' + JSON.stringify(e),
|
|
duration: 2000
|
|
});
|
|
});
|
|
|
|
},
|
|
methods: {
|
|
testAsyncFunc() {
|
|
// 获取 module
|
|
var testModule = uni.requireNativePlugin("MonitorModule")
|
|
|
|
var json = {
|
|
deviceId: '4',
|
|
deviceName: 'sdfsfsdf'
|
|
}
|
|
// 调用异步方法
|
|
testModule.gotoNativePage(json)
|
|
},
|
|
jumptonve() {
|
|
uni.navigateTo({
|
|
url: '/pages/ceshianzhuo'
|
|
})
|
|
},
|
|
init(event) {
|
|
var monitorModule = uni.requireNativePlugin("MonitorModule")
|
|
monitorModule.initSMBCloudSDK()
|
|
},
|
|
login(event) {
|
|
var monitorModule = uni.requireNativePlugin("MonitorModule")
|
|
var loginfo = {
|
|
userName: "admin",
|
|
password: "Bl20230518",
|
|
serverAddress: "121.36.88.64",
|
|
port: 8888,
|
|
}
|
|
monitorModule.cloudLoginIn(loginfo, (r) => {
|
|
console.log("loginResult", r.code)
|
|
uni.showToast({
|
|
title: '操作成功',
|
|
duration: 2000
|
|
});
|
|
})
|
|
},
|
|
logout(event) {
|
|
var monitorModule = uni.requireNativePlugin("MonitorModule")
|
|
monitorModule.cloudLoginOut((r) => {
|
|
console.log("loginResult", r.code)
|
|
})
|
|
},
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.content {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 100%;
|
|
height: 100vh;
|
|
}
|
|
|
|
.logo {
|
|
height: 200rpx;
|
|
width: 200rpx;
|
|
margin-top: 200rpx;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
margin-bottom: 50rpx;
|
|
}
|
|
|
|
.text-area {
|
|
display: flex;
|
|
justify-content: center;
|
|
}
|
|
|
|
.title {
|
|
font-size: 36rpx;
|
|
color: #8f8f94;
|
|
}
|
|
.typebutton{
|
|
width: 300rpx;
|
|
height: 150rpx;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
margin-top: 30rpx;
|
|
color: #fff;
|
|
}
|
|
</style> |