| | |
| | |
|
| | | -->
|
| | | <cu-custom bgColor="bg-gradual-blue" :isBack="false">
|
| | | <block slot="content">智能中草药干燥设备配套系统</block>
|
| | | <block slot="content">智能中草药</block>
|
| | | </cu-custom>
|
| | | <mqtt-view ref="mqttView"></mqtt-view>
|
| | | <u-toast ref="uToast"></u-toast>
|
| | | <!-- <view class="card-box dynamic shadow cu-list menu">
|
| | | <view class="title-box">
|
| | |
| | | </view>
|
| | | </view>
|
| | | </view> -->
|
| | | |
| | | </view>
|
| | | </template>
|
| | |
|
| | | <script>
|
| | | |
| | |
|
| | | export default {
|
| | | |
| | | data() {
|
| | | return {
|
| | | list: [{
|
| | |
| | | },
|
| | | onShow() {
|
| | | console.info('onShow')
|
| | | uni.showTabBarRedDot({
|
| | | index: 2 // 显示第2个tabbar项(索引从0开始)的红点
|
| | | });
|
| | |
|
| | |
|
| | | },
|
| | | mounted() {
|
| | | |
| | |
|
| | |
|
| | | },
|
| | | onReady() {
|
| | | const userinfo = uni.getStorageSync('userinfo');
|
| | | const tenantid = userinfo.loginTenantId
|
| | | uni.getSystemInfo({
|
| | | success: (res) => {
|
| | | let deviceId = res.deviceId
|
| | | if (!deviceId) {
|
| | | deviceId = 'mobile-' + tenantid + '-' + Date.parse(new Date())
|
| | | }
|
| | | uni.setStorageSync(this.$constant.DEVICE_ID, 'mobile-' + tenantid + '-' + res.deviceId);
|
| | | }
|
| | | })
|
| | | this.startConnect();
|
| | | this.$refs.mqttView.initMqtt()
|
| | | |
| | | // uni.getSystemInfo({
|
| | | // success: (res) => {
|
| | | // let deviceId = res.deviceId
|
| | | // if (!deviceId) {
|
| | | // deviceId = 'mobile-' + this.tenantId + '-' + Date.parse(new Date())
|
| | | // }
|
| | | // uni.setStorageSync(this.$constant.DEVICE_ID, 'mobile-' + this.tenantId + '-' + res.deviceId);
|
| | | // }
|
| | | // })
|
| | | // this.startConnect();
|
| | |
|
| | |
|
| | |
|
| | |
| | |
|
| | |
|
| | | },
|
| | | onLoad() {
|
| | | |
| | | },
|
| | | methods: {
|
| | | |
| | | /* 连接MQTT */
|
| | | async startConnect() {
|
| | | var _this = this
|
| | |
| | | //订阅查询设备状态返回数据
|
| | | this.$mqttTool.subscribe({
|
| | | topic: this.$constant.SERVICE_DOWN + '/' + deviceid + '/#',
|
| | | qos: 0
|
| | | }).then(res => {
|
| | | console.error(res)
|
| | | })
|
| | | |
| | | //订阅设备故障广播(广播不在乎客户端id,发送给租户下所有在线的设备)
|
| | | this.$mqttTool.subscribe({
|
| | | topic: this.$constant.SERVICE_BROADCAST_TENANT_REAL_FAULT.replace('%s', this.tenantId),
|
| | | qos: 0
|
| | | }).then(res => {
|
| | | console.error(res)
|
| | |
| | |
|
| | |
|
| | |
|
| | | },
|
| | | computed:{
|
| | | tenantId(){
|
| | | const userinfo = uni.getStorageSync('userinfo');
|
| | | const tenantid = userinfo.loginTenantId
|
| | | return tenantid;
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | }
|