Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
eslotsys-game-nuxt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
毛线
eslotsys-game-nuxt
Commits
5a690f5e
Commit
5a690f5e
authored
Jul 06, 2023
by
毛线
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接im
parent
217bc14b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
118 additions
and
50 deletions
+118
-50
index.vue
components/common/header/index.vue
+0
-1
nuxt.config.js
nuxt.config.js
+8
-4
index.vue
pages/index.vue
+103
-32
_id.vue
pages/index/game/_id.vue
+1
-12
index.js
store/index.js
+2
-1
auth.js
utils/auth.js
+4
-0
No files found.
components/common/header/index.vue
View file @
5a690f5e
...
...
@@ -154,7 +154,6 @@ export default {
params
,
}).
then
(({
data
})
=>
{
console
.
log
(
'退出游戏页面'
)
this
.
$router
.
replace
(
'/device'
)
})
},
},
...
...
nuxt.config.js
View file @
5a690f5e
...
...
@@ -15,6 +15,10 @@ export default {
meta
:
[
{
charset
:
'utf-8'
},
// { 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
||
''
}
],
link
:
[
...
...
@@ -100,10 +104,10 @@ export default {
}
},
server
:
{
https
:
{
key
:
fs
.
readFileSync
(
path
.
resolve
(
__dirname
,
'configs/certificate/localhost.key'
)),
cert
:
fs
.
readFileSync
(
path
.
resolve
(
__dirname
,
'configs/certificate/localhost.crt'
))
}
//
https: {
//
key: fs.readFileSync(path.resolve(__dirname, 'configs/certificate/localhost.key')),
//
cert: fs.readFileSync(path.resolve(__dirname, 'configs/certificate/localhost.crt'))
//
}
},
// axios: {
// // baseURL,
...
...
pages/index.vue
View file @
5a690f5e
...
...
@@ -22,13 +22,15 @@ export default {
Footer
,
},
data
()
{
return
{}
return
{
imLoginStatus
:
false
,
}
},
computed
:
{
...
mapState
([
'relist'
,
'userInfo'
,
'
t
oken'
,
'
imT
oken'
,
]),
},
watch
:
{
...
...
@@ -36,7 +38,9 @@ export default {
this
.
$router
.
replace
(
`/login`
)
},
userInfo
()
{
this
.
init
().
im
()
if
(
!
this
.
imLoginStatus
)
{
this
.
init
().
im
()
}
},
},
mounted
()
{
...
...
@@ -52,55 +56,62 @@ export default {
init
()
{
return
{
im
:
()
=>
{
const
{
userInfo
,
t
oken
,
}
=
this
const
{
userInfo
,
imT
oken
,
}
=
this
const
{
id
}
=
userInfo
this
.
network
().
getOpenimInfo
().
then
(({
data
})
=>
{
console
.
log
(
'data'
,
data
)
const
config
=
{
userID
:
id
,
// 用户ID
token
:
t
oken
,
// 用户token
token
:
imT
oken
,
// 用户token
url
:
data
.
imWsServer
,
// jssdk server ws地址
platformID
:
5
,
// 平台号
}
console
.
log
(
'config'
,
config
)
openIM
.
login
(
config
).
then
(
res
=>
{
this
.
l
oginStatus
=
true
this
.
imL
oginStatus
=
true
console
.
log
(
'login suc...'
,
res
)
// me
.startListenIM()
this
.
init
()
.
startListenIM
()
// if(me.initUserId) {
// me.handleNewConversation(me.initUserId)
// }
}).
catch
(
err
=>
{
this
.
l
oginStatus
=
false
this
.
imL
oginStatus
=
false
this
.
$message
.
error
(
'login to openIM failed'
)
console
.
log
(
'login failed...'
,
err
)
})
})
// const config = {
// userID: openIMConfig.openImId, // 用户ID
// token: openIMConfig.openImToken, // 用户token
// url: openIMConfig.wsUrl, // jssdk server ws地址
// platformID: openIMConfig.platformID, // 平台号
// }
// openIM.login(config).then(res => {
// this.loginStatus = true
// console.log('login suc...', res)
// // me.startListenIM()
// // if(me.initUserId) {
// // me.handleNewConversation(me.initUserId)
// // }
// }).catch(err => {
// this.loginStatus = false
// this.$message.error('login to openIM failed')
// console.log('login failed...', err)
// })
},
startListenIM
:
()
=>
{
openIM
.
on
(
CbEvents
.
ONRECVNEWMESSAGE
,
(
data
)
=>
{
const
msg
=
JSON
.
parse
(
data
.
data
)
const
content
=
JSON
.
parse
(
msg
.
content
)
// console.log('receive message', msg, content)
if
(
msg
.
sendID
!==
'openIMAdmin'
)
{
// 非系统消息
return
}
this
.
handler
().
newMessageCome
(
msg
)
})
openIM
.
on
(
CbEvents
.
ONCONNECTFAILED
,
(
data
)
=>
{
console
.
log
(
'connection failed'
,
data
)
// 连接失败...
})
openIM
.
on
(
CbEvents
.
ONCONNECTSUCCESS
,
(
data
)
=>
{
console
.
log
(
'connection success'
,
data
)
// 连接成功...
})
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 {
method
:
'get'
,
}).
then
(({
data
})
=>
{
if
(
!
data
)
{
this
.
$router
.
replace
(
'/device'
)
return
}
const
{
id
}
=
data
...
...
@@ -131,6 +143,65 @@ export default {
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
}
},
}
},
},
...
...
pages/index/game/_id.vue
View file @
5a690f5e
...
...
@@ -174,16 +174,13 @@ export default {
}
},
methods
:
{
...
mapActions
([
'GetBaseInfo'
,
]),
...
mapMutations
([
'SetDevice'
,
]),
init
()
{
return
{
play
:
()
=>
{
const
url
=
this
.
device
.
videoMainNumber
const
url
=
this
.
device
?
.
videoMainNumber
const
webrtc
=
`webrtc://eslotstreaming.com
${
url
}
`
console
.
log
(
'device'
,
{
...
this
.
device
})
this
.
$refs
.
webrtc
.
initVideo
(
webrtc
)
...
...
@@ -282,10 +279,6 @@ export default {
method
:
'get'
,
params
,
}).
then
(({
data
})
=>
{
this
.
GetBaseInfo
()
setTimeout
(()
=>
{
this
.
GetBaseInfo
()
},
3000
)
})
this
.
creditInShow
=
false
},
...
...
@@ -299,10 +292,6 @@ export default {
method
:
'get'
,
params
,
}).
then
(({
data
})
=>
{
this
.
GetBaseInfo
()
setTimeout
(()
=>
{
this
.
GetBaseInfo
()
},
3000
)
})
},
jackpotList
:
()
=>
{
...
...
store/index.js
View file @
5a690f5e
...
...
@@ -20,7 +20,7 @@ import {
SET_CONFIG
,
}
from
'@/store/mutation-types'
import
{
treeData
}
from
'@/utils/tool'
import
{
getToken
,
removeToken
,
setUserData
}
from
'@/utils/auth'
// 验权
import
{
getToken
,
getImToken
,
removeToken
,
setUserData
}
from
'@/utils/auth'
// 验权
export
const
state
=
()
=>
({
relist
:
false
,
// 重新登录
...
...
@@ -33,6 +33,7 @@ export const state = () => ({
deviceList
:
[],
// 设备列表
device
:
{},
// 当前设备
token
:
getToken
(),
imToken
:
getImToken
(),
zoom
:
1
,
// 当前屏幕缩放比例
innerWidth
:
window
.
innerWidth
,
innerHeight
:
window
.
innerHeight
,
...
...
utils/auth.js
View file @
5a690f5e
...
...
@@ -8,6 +8,10 @@ export function getToken() {
return
Cookies
.
get
(
TokenKey
)
}
export
function
getImToken
()
{
return
Cookies
.
get
(
OpenImToken
)
}
export
function
setToken
(
token
)
{
return
Cookies
.
set
(
TokenKey
,
token
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment