data () {
return {
userInfo: {},
mobile: '',
appId: '',
timer: null
}
},
watch: {
userInfo: {
handler (newValue, oldValue) {
console.log(newValue)
if (newValue !== {}) {
window.clearInterval(this.timer)
}
},
deep: true
},
},
mounted () {
this.onlineService()
},
methods: {
onlineService () {
this.timer = setInterval(() => {
// eslint-disable-next-line no-undef
MXCommon.getCurrentUser((result) => {
this.userInfo = result
// eslint-disable-next-line no-undef
const appId = 'MOA10001'
// eslint-disable-next-line no-undef
MPAES.onlineChatEncode(appId, (success2) => {
console.log(success2)
this.appId = encodeURIComponent(success2 + '\n')
// result.mobile
// eslint-disable-next-line no-undef
MPAES.onlineChatEncode('13559120687', (success1) => {
this.mobile = encodeURIComponent(success1 + '\n')
console.log(success1)
this.getUserToken()
})
})
})
// 这里可以处理获取到的当前用户数据,result是object类型
}, 1000)
}
}