|
@@ -18,8 +18,26 @@
|
|
onLoad: async function() {
|
|
onLoad: async function() {
|
|
const that = this;
|
|
const that = this;
|
|
await that.searchConfig();
|
|
await that.searchConfig();
|
|
|
|
+ await that.watchlogin();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ watchlogin() {
|
|
|
|
+ const that = this;
|
|
|
|
+ if (that.$store.state.socketTask == null) {
|
|
|
|
+ uni.getStorage({
|
|
|
|
+ key: 'token',
|
|
|
|
+ success: function(res) {
|
|
|
|
+ let user = that.$jwt(res.data);
|
|
|
|
+ if (user._id) {
|
|
|
|
+ //当websocket收到后端发送的消息时,触发
|
|
|
|
+ let config = that.$config.wsUrl;
|
|
|
|
+ // 开启websocket
|
|
|
|
+ that.$store.dispatch('websocketInit', config + `/${user._id}`);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
// 查询基本设置
|
|
// 查询基本设置
|
|
async searchConfig() {
|
|
async searchConfig() {
|
|
const that = this;
|
|
const that = this;
|