| | |
| | | <script>
|
| | | import Vue from 'vue' |
| | | import Vue from 'vue'
|
| | |
|
| | | export default {
|
| | | globalData: {
|
| | | token: "aaa"
|
| | | token: ""
|
| | | },
|
| | | onLaunch: function() {
|
| | | |
| | |
|
| | |
|
| | | //此处为unipush2.0的推送方法
|
| | | // uni-app客户端获取push客户端标记
|
| | | // uni.getPushClientId({
|
| | | // success: (res) => {
|
| | | // let push_clientid = res.cid
|
| | | // console.log('客户端推送标识:', push_clientid)
|
| | | // },
|
| | | // fail(err) {
|
| | | // console.log(err)
|
| | | // }
|
| | | // })
|
| | | // uni.onPushMessage((res) => {
|
| | | // console.log("收到推送消息:", res) //监听推送消息
|
| | | // })
|
| | |
|
| | |
|
| | | //推送仅支持Android ios原生平台
|
| | | // #ifdef APP-PLUS
|
| | | console.log('APP-PLUS:')
|
| | | // 此处为unipush1.0的推送方法
|
| | | plus.push.getClientInfoAsync((info) => {
|
| | | let cid = info["clientid"];
|
| | | console.log('客户端推送标识:', cid)
|
| | | this.$store.dispatch('setCid', cid); // 使用 action 更新 cid
|
| | | });
|
| | | // #endif
|
| | | uni.onPushMessage((res) => {
|
| | | console.log("收到推送消息:", res) //监听推送消息
|
| | | })
|
| | |
|
| | |
|
| | |
|
| | | uni.getSystemInfo({
|
| | | success: function(e) {
|
| | | // #ifndef MP
|
| | |
| | | },
|
| | | onShow: function() {
|
| | | console.log('App Show')
|
| | | // this.conn()
|
| | |
|
| | |
|
| | | },
|
| | | onHide: function() {
|
| | | console.log('App Hide')
|
| | | }, |
| | | methods:{ |
| | | |
| | | |
| | | // this.disconn()
|
| | | },
|
| | | methods: {
|
| | | //处理掉线重连
|
| | | conn() {
|
| | | console.log(this.$mqttTool.client)
|
| | | if (this.$mqttTool.client) {
|
| | | console.log(this.$mqttTool.client.connected)
|
| | | }
|
| | | if (this.$mqttTool.client && !this.$mqttTool.client.connected) {
|
| | | console.info("开始重连")
|
| | | this.$mqttTool.reconnect()
|
| | | } else {
|
| | |
|
| | | }
|
| | | },
|
| | | disconn() {
|
| | | console.log(this.$mqttTool.client)
|
| | | if (this.$mqttTool.client) {
|
| | | console.log(this.$mqttTool.client.connected)
|
| | | }
|
| | | // if(this.$mqttTool.client){
|
| | | // this.$mqttTool.end().then(res =>{
|
| | | // console.log('终止:')
|
| | | // })
|
| | |
|
| | | // }
|
| | | }
|
| | |
|
| | | },
|
| | | mounted() {
|
| | | var i = 0;
|
| | | // setInterval(function() {
|
| | | // i++
|
| | | // if (i % 2 == 0) {
|
| | | // uni.showTabBarRedDot({
|
| | | // index: 1
|
| | | // })
|
| | | // } else {
|
| | | // uni.hideTabBarRedDot({
|
| | | // index: 1
|
| | | // })
|
| | | // }
|
| | | // }, 3000)
|
| | |
|
| | |
|
| | |
|
| | | }
|
| | | }
|
| | |
| | | @import "colorui/main.css";
|
| | | @import "colorui/icon.css";
|
| | | @import "uview-ui/index.scss";
|
| | | </style> |
| | | </style> |