Commit 5a690f5e authored by 毛线's avatar 毛线

对接im

parent 217bc14b
...@@ -154,7 +154,6 @@ export default { ...@@ -154,7 +154,6 @@ export default {
params, params,
}).then(({ data }) => { }).then(({ data }) => {
console.log('退出游戏页面') console.log('退出游戏页面')
this.$router.replace('/device')
}) })
}, },
}, },
......
...@@ -15,6 +15,10 @@ export default { ...@@ -15,6 +15,10 @@ export default {
meta: [ meta: [
{ charset: 'utf-8' }, { charset: 'utf-8' },
// { name: 'viewport', content: 'width=device-width, initial-scale=1' }, // { name: 'viewport', content: 'width=device-width, initial-scale=1' },
{
'http-equiv': 'Content-Security-Policy',
content: 'upgrade-insecure-requests',
},
{ hid: 'description', name: 'description', content: process.env.project_description || '' } { hid: 'description', name: 'description', content: process.env.project_description || '' }
], ],
link: [ link: [
...@@ -100,10 +104,10 @@ export default { ...@@ -100,10 +104,10 @@ export default {
} }
}, },
server: { server: {
https: { // https: {
key: fs.readFileSync(path.resolve(__dirname, 'configs/certificate/localhost.key')), // key: fs.readFileSync(path.resolve(__dirname, 'configs/certificate/localhost.key')),
cert: fs.readFileSync(path.resolve(__dirname, 'configs/certificate/localhost.crt')) // cert: fs.readFileSync(path.resolve(__dirname, 'configs/certificate/localhost.crt'))
} // }
}, },
// axios: { // axios: {
// // baseURL, // // baseURL,
......
...@@ -22,13 +22,15 @@ export default { ...@@ -22,13 +22,15 @@ export default {
Footer, Footer,
}, },
data() { data() {
return {} return {
imLoginStatus: false,
}
}, },
computed: { computed: {
...mapState([ ...mapState([
'relist', 'relist',
'userInfo', 'userInfo',
'token', 'imToken',
]), ]),
}, },
watch: { watch: {
...@@ -36,7 +38,9 @@ export default { ...@@ -36,7 +38,9 @@ export default {
this.$router.replace(`/login`) this.$router.replace(`/login`)
}, },
userInfo() { userInfo() {
if (!this.imLoginStatus) {
this.init().im() this.init().im()
}
}, },
}, },
mounted() { mounted() {
...@@ -52,55 +56,62 @@ export default { ...@@ -52,55 +56,62 @@ export default {
init() { init() {
return { return {
im: () => { im: () => {
const { userInfo, token, } = this const { userInfo, imToken, } = this
const { id } = userInfo const { id } = userInfo
this.network().getOpenimInfo().then(({ data }) => { this.network().getOpenimInfo().then(({ data }) => {
console.log('data', data)
const config = { const config = {
userID: id, // 用户ID userID: id, // 用户ID
token: token, // 用户token token: imToken, // 用户token
url: data.imWsServer, // jssdk server ws地址 url: data.imWsServer, // jssdk server ws地址
platformID: 5, // 平台号 platformID: 5, // 平台号
} }
console.log('config', config)
openIM.login(config).then(res => { openIM.login(config).then(res => {
this.loginStatus = true this.imLoginStatus = true
console.log('login suc...', res) console.log('login suc...', res)
// me.startListenIM() this.init().startListenIM()
// if(me.initUserId) { // if(me.initUserId) {
// me.handleNewConversation(me.initUserId) // me.handleNewConversation(me.initUserId)
// } // }
}).catch(err => { }).catch(err => {
this.loginStatus = false this.imLoginStatus = false
this.$message.error('login to openIM failed') this.$message.error('login to openIM failed')
console.log('login failed...', err) console.log('login failed...', err)
}) })
}) })
// const config = { },
// userID: openIMConfig.openImId, // 用户ID startListenIM: () => {
// token: openIMConfig.openImToken, // 用户token openIM.on(CbEvents.ONRECVNEWMESSAGE, (data) => {
// url: openIMConfig.wsUrl, // jssdk server ws地址 const msg = JSON.parse(data.data)
// platformID: openIMConfig.platformID, // 平台号 const content = JSON.parse(msg.content)
// } // console.log('receive message', msg, content)
if (msg.sendID !== 'openIMAdmin') { // 非系统消息
// openIM.login(config).then(res => { return
// this.loginStatus = true }
// console.log('login suc...', res) this.handler().newMessageCome(msg)
})
// // me.startListenIM() openIM.on(CbEvents.ONCONNECTFAILED, (data) => {
console.log('connection failed', data)
// // if(me.initUserId) { // 连接失败...
// // me.handleNewConversation(me.initUserId) })
// // } openIM.on(CbEvents.ONCONNECTSUCCESS, (data) => {
// }).catch(err => { console.log('connection success', data)
// this.loginStatus = false // 连接成功...
// this.$message.error('login to openIM failed') })
// console.log('login failed...', err) openIM.on(CbEvents.ONCONNECTING, (data) => {
// }) console.log('connection establishing', data)
// 连接中...
})
openIM.on(CbEvents.ONKICKEDOFFLINE, (data) => {
console.log('connection kick offline', data)
// 被踢下线...
})
openIM.on(CbEvents.ONUSERTOKENEXPIRED, (data) => {
console.log('connection expired', data)
// token过期...
})
}, },
} }
}, },
...@@ -113,6 +124,7 @@ export default { ...@@ -113,6 +124,7 @@ export default {
method: 'get', method: 'get',
}).then(({ data }) => { }).then(({ data }) => {
if (!data) { if (!data) {
this.$router.replace('/device')
return return
} }
const { id } = data const { id } = data
...@@ -131,6 +143,65 @@ export default { ...@@ -131,6 +143,65 @@ export default {
method: 'get', method: 'get',
}) })
}, },
quitGame: () => {
const { id } = this.$route.params
const params = {
deviceId: id,
}
this.$request({
url: '/api/app/device/quitDevice',
method: 'get',
params,
}).then(({ data }) => {
})
},
}
},
handler() {
return {
newMessageCome: (msg) => {
const content = JSON.parse(msg.content)
const { eventCode, data: message, } = content
console.log('newMessageCome', content)
switch (eventCode) {
case 10008: // Credit-in success
case 10006: // Credit-out success
console.log('message', message)
Message({
type: 'success',
message,
})
break
case 10005: // 退出设备失败
Message({
type: 'error',
message,
})
break
case 10003: // 需要更细设备列表
this.GetDeviceList()
break
case 10000:
this.GetBaseInfo()
break
case 10022: // 返回设备列表
console.log('返回设备列表')
break
case 10004: // 退出设备成功
case 10015: // 后台提出游戏
this.$router.replace('/device')
break
case 10002: // 即将超出最大未操作时长,60秒后将踢出游戏
Message({
type: 'error',
message,
})
break
case 10001: // 超出最大未操作时长,踢出游戏
this.network().quitGame()
break
}
},
} }
}, },
}, },
......
...@@ -174,16 +174,13 @@ export default { ...@@ -174,16 +174,13 @@ export default {
} }
}, },
methods: { methods: {
...mapActions([
'GetBaseInfo',
]),
...mapMutations([ ...mapMutations([
'SetDevice', 'SetDevice',
]), ]),
init() { init() {
return { return {
play: () => { play: () => {
const url = this.device.videoMainNumber const url = this.device?.videoMainNumber
const webrtc = `webrtc://eslotstreaming.com${url}` const webrtc = `webrtc://eslotstreaming.com${url}`
console.log('device', { ...this.device }) console.log('device', { ...this.device })
this.$refs.webrtc.initVideo(webrtc) this.$refs.webrtc.initVideo(webrtc)
...@@ -282,10 +279,6 @@ export default { ...@@ -282,10 +279,6 @@ export default {
method: 'get', method: 'get',
params, params,
}).then(({ data }) => { }).then(({ data }) => {
this.GetBaseInfo()
setTimeout(() => {
this.GetBaseInfo()
}, 3000)
}) })
this.creditInShow = false this.creditInShow = false
}, },
...@@ -299,10 +292,6 @@ export default { ...@@ -299,10 +292,6 @@ export default {
method: 'get', method: 'get',
params, params,
}).then(({ data }) => { }).then(({ data }) => {
this.GetBaseInfo()
setTimeout(() => {
this.GetBaseInfo()
}, 3000)
}) })
}, },
jackpotList: () => { jackpotList: () => {
......
...@@ -20,7 +20,7 @@ import { ...@@ -20,7 +20,7 @@ import {
SET_CONFIG, SET_CONFIG,
} from '@/store/mutation-types' } from '@/store/mutation-types'
import { treeData } from '@/utils/tool' import { treeData } from '@/utils/tool'
import { getToken, removeToken, setUserData } from '@/utils/auth' // 验权 import { getToken, getImToken, removeToken, setUserData } from '@/utils/auth' // 验权
export const state = () => ({ export const state = () => ({
relist: false, // 重新登录 relist: false, // 重新登录
...@@ -33,6 +33,7 @@ export const state = () => ({ ...@@ -33,6 +33,7 @@ export const state = () => ({
deviceList: [], // 设备列表 deviceList: [], // 设备列表
device: {}, // 当前设备 device: {}, // 当前设备
token: getToken(), token: getToken(),
imToken: getImToken(),
zoom: 1, // 当前屏幕缩放比例 zoom: 1, // 当前屏幕缩放比例
innerWidth: window.innerWidth, innerWidth: window.innerWidth,
innerHeight: window.innerHeight, innerHeight: window.innerHeight,
......
...@@ -8,6 +8,10 @@ export function getToken() { ...@@ -8,6 +8,10 @@ export function getToken() {
return Cookies.get(TokenKey) return Cookies.get(TokenKey)
} }
export function getImToken() {
return Cookies.get(OpenImToken)
}
export function setToken(token) { export function setToken(token) {
return Cookies.set(TokenKey, token) return Cookies.set(TokenKey, token)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment