Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
h5-watch
Overview
Overview
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
苏文标
h5-watch
Commits
c939274d
Commit
c939274d
authored
Oct 24, 2022
by
suwenbiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
聊天
parent
7af70dc1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
155 additions
and
124 deletions
+155
-124
chat.vue
components/chat/chat.vue
+14
-99
footer.vue
components/footer/footer.vue
+22
-5
acount_login.vue
components/login/acount_login.vue
+1
-0
login.vue
components/login/login.vue
+22
-16
main.js
main.js
+2
-0
index.vue
pages/index/index.vue
+94
-4
index.js
store/index.js
+0
-0
face.js
until/face.js
+0
-0
No files found.
components/chat/chat.vue
View file @
c939274d
...
...
@@ -3,128 +3,41 @@
<!-- 特效礼物 -->
<special
:url=
"specialUrl"
></special>
<scroll-view
lower-threshold=
"20"
scroll-y=
"true"
class=
"chat"
show-scrollbar=
"false"
:scroll-top=
"scrollTop"
>
<view
class=
"cavasation my-1"
v-for=
"(item,index) in msgList"
:key=
"index"
>
<scroll-view
lower-threshold=
"20"
scroll-y=
"true"
class=
"chat"
show-scrollbar=
"true"
>
<view
class=
"cavasation my-2"
v-for=
"(item,index) in datalist"
:key=
"index"
>
<view
class=
"cavasation my-2"
v-for=
"(item,index) in msgList"
:key=
"index"
>
<view
class=
"person"
>
<u-avatar
:src=
"item.avatar"
size=
"60"
></u-avatar>
<span
class=
"ml-1"
>
{{
item
.
n
ame
}}
</span>
<span
class=
"ml-1"
>
{{
item
.
sendN
ame
}}
</span>
</view>
<view
class=
"content"
>
<span
class=
"text"
>
{{
item
.
conten
t
}}
</span>
<span
class=
"text"
>
{{
item
.
tex
t
}}
</span>
</view>
</view>
</scroll-view>
</view>
</scroll-view>
</view>
</
template
>
<
script
>
import
special
from
"@/components/footer/gift/special-effects/special.vue"
var
Live
export
default
{
name
:
"chat"
,
components
:
{
special
},
props
:
[
"specialUrl"
],
props
:
{
specialUrl
:
String
,
msgList
:
Array
,
// scrollTop: String,
},
data
()
{
return
{
scrollFalg
:
false
,
scrollTop
:
0
,
msgList
:
[]
}
},
created
()
{
this
.
getusertoken
()
},
methods
:
{
gsnickname
(
val
)
{
var
msgname
=
val
msgname
=
msgname
.
replace
(
/
\d{8,}
/g
,
"*"
)
msgname
=
msgname
.
length
>
8
?
msgname
.
substring
(
0
,
8
)
+
"..."
:
msgname
return
msgname
},
//获取房间token
getusertoken
()
{
this
.
$nextTick
(()
=>
{
if
(
uni
.
getStorageSync
(
"login_ok"
)
==
'success'
)
{
this
.
$api
.
getusertoken
().
then
(
res
=>
{
var
that
=
this
var
roomdid
=
res
.
data
.
data
if
(
uni
.
getStorageSync
(
'room_token'
))
{
roomdid
=
uni
.
getStorageSync
(
'room_token'
)
}
Live
=
new
Finezb
.
Live
(
roomdid
)
Live
.
login
(
function
()
{
console
.
log
(
'登录成功'
,
JSON
.
stringify
(
Live
.
getLoginUser
()))
uni
.
setStorageSync
(
"user_account"
,
Live
.
getLoginUser
().
account
)
})
})
}
})
},
//发送消息
send
(
val
)
{
if
(
!
val
.
sendText
)
{
return
;
}
let
data
=
{
text
:
val
.
sendText
,
type
:
val
.
type
,
nickName
:
uni
.
getStorageSync
(
"user_name"
),
};
if
(
uni
.
getStorageSync
(
"watch_type"
)
==
4
&&
uni
.
getStorageSync
(
"wxnick"
)
==
0
)
{
data
.
nickName
=
uni
.
getStorageSync
(
"user_name1"
)
}
data
.
extra
=
{
headUrl
:
getStorageSync
(
"user_headimg"
),
role
:
4
,
isDirty
:
0
};
// var sendlist = this.chatsetinfo.sensitiveWord
// if (this.chatsetinfo.sensitive && sendlist.length > 0) {
// for (var index in sendlist) {
// if (sendlist[index] != "" && sendlist[index].trim() != "" && this.sendText.includes(sendlist[
// index])) {
// data.extra.isDirty = 1
// break;
// }
// }
// }
data
.
extra
=
JSON
.
stringify
(
data
.
extra
);
let
msg
=
{
type
:
val
.
type
,
sendTime
:
new
Date
().
getTime
(),
extra
:
{
headUrl
:
getStorageSync
(
"user_headimg"
),
role
:
4
},
sendName
:
uni
.
getStorageSync
(
"user_name"
),
text
:
face
.
replaceEm
(
this
.
sendText
)
}
if
(
uni
.
getStorageSync
(
"watch_type"
)
==
4
&&
uni
.
getStorageSync
(
"wxnick"
)
==
0
)
{
msg
.
sendName
=
uni
.
getStorageSync
(
"user_name1"
)
}
msg
.
sendName
=
msg
.
sendName
.
replace
(
/
\d{8,}
/g
,
"*"
)
msg
.
sendName
=
msg
.
sendName
.
length
>
8
?
msg
.
sendName
.
substring
(
0
,
8
)
+
"..."
:
msg
.
sendName
this
.
msgList
.
push
(
msg
)
this
.
sendText
=
''
;
// let id = 'msg' + msg.sendTime;
// this.msgBoxToBottom(id);
this
.
showexpression
=
false
this
.
showgift
=
false
console
.
log
(
data
);
Live
.
sendMsg
(
data
,
function
(
ack
)
{
console
.
log
(
ack
);
if
(
ack
.
code
===
200
)
{
this
.
scrollTop
=
500
}
})
},
}
}
</
script
>
...
...
@@ -133,12 +46,14 @@
.ml-1
{
margin-left
:
10
rpx
;
}
.font-14
{
.font-14
{
font-size
:
14
rpx
;
}
.my-2
{
margin
:
20
rpx
0
;
padding-top
:
10
rpx
;
}
.box
{
...
...
@@ -149,9 +64,9 @@
.chat
{
box-sizing
:
border-box
;
height
:
calc
(
100vh
-
500
rpx
);
padding
:
4
0
rpx
;
padding
-bottom
:
10
0
rpx
;
letter-spacing
:
2
rpx
;
margin-left
:
30
rpx
;
.person
{
display
:
flex
;
align-items
:
center
;
...
...
components/footer/footer.vue
View file @
c939274d
...
...
@@ -6,11 +6,13 @@
<view
class=
"input"
>
<u--input
style=
"background-color: #d9d9d9;height: 64rpx;padding-left:20rpx;"
type=
"text"
border=
"none"
shape=
"circle"
placeholder=
"说点什么吧..."
v-model=
"value"
@
focus=
"inputFocus"
@
blur=
"inputblur"
confirmType=
"
发送"
confirm=
"send"
></u--input
>
confirmType=
"
send"
confirm=
"send"
>
</u--input>
</view>
<u-button
style=
"margin: 0 0 0 20rpx;width: 20%;height: 70%;"
text=
"发送"
type=
"success"
v-show=
"!inputFalg"
@
click=
"send"
>
</u-button>
<!--
<u-button
style=
"margin: 0 0 0 20rpx;width: 20%;height: 70%;"
text=
"发送"
type=
"success"
v-show=
"!inputFalg"
touchend
.
prevent=
"send"
>
</u-button>
-->
<button
class=
"btn_send"
text=
"发送"
v-show=
"!inputFalg"
@
touchend
.
prevent=
"send"
>
发送
</button>
<view
class=
"icon"
v-show=
"inputFalg"
>
<image
v-for=
"(item,index) in imageList"
:key=
"index+''"
:src=
"item.url"
style=
"width:68rpx"
mode=
"widthFix"
@
click=
"iconbtn(item.title)"
></image>
...
...
@@ -34,6 +36,9 @@
import
reward
from
"./reward/reward.vue"
;
import
shoplist
from
"./shopList/shoplist.vue"
import
msg
from
"@/components/chat/chat.vue"
export
default
{
name
:
"foot"
,
components
:
{
...
...
@@ -44,6 +49,9 @@
reward
,
shoplist
},
created
()
{
},
data
()
{
return
{
inputFalg
:
true
,
...
...
@@ -97,7 +105,7 @@
type
:
1
,
sendText
:
this
.
value
}
msg
.
methods
.
send
(
obj
)
this
.
$emit
(
"sendmsg"
,
obj
)
this
.
value
=
""
},
// 输入框聚焦事件
...
...
@@ -162,7 +170,16 @@
//
width
:
294
rpx
;
flex
:
1
;
}
.btn_send
{
margin
:
0
0
0
20
rpx
;
width
:
20%
;
height
:
70%
;
background-color
:
#19be6b
;
font-size
:
24
rpx
;
text-align
:
center
;
color
:
#fff
;
outline
:
none
;
}
.icon
{
flex
:
1
;
text-align
:
right
;
...
...
components/login/acount_login.vue
View file @
c939274d
...
...
@@ -49,6 +49,7 @@
console
.
log
(
res
);
if
(
res
.
data
.
code
==
200
)
{
this
.
nickname
=
res
.
data
.
data
uni
.
setStorageSync
(
'room_account'
,
this
.
acount_input
)
if
(
localStorage
.
getItem
(
'wxnick'
)
==
1
)
{
this
.
$api
.
getusertoken
(
''
,
this
.
acount_input
,
true
).
then
(
res
=>
{
uni
.
setStorageSync
(
'room_token'
,
res
.
data
.
data
)
...
...
components/login/login.vue
View file @
c939274d
...
...
@@ -142,15 +142,15 @@
this
.
is_show
=
false
if
(
res
.
data
.
data
)
{
uni
.
showToast
({
title
:
"登录成功"
title
:
"登录成功"
})
setTimeout
(()
=>
{
location
.
reload
();
},
1800
);
setTimeout
(()
=>
{
location
.
reload
();
},
1800
);
uni
.
setStorageSync
(
"user_name"
,
res
.
data
.
data
.
account
);
uni
.
setStorageSync
(
"user_headimg"
,
res
.
data
.
data
.
avatar
);
uni
.
setStorageSync
(
"user_token"
,
res
.
data
.
data
.
token
);
}
})
}
...
...
@@ -168,7 +168,8 @@
//获取观看方式
get_watchtype
()
{
this
.
$api
.
roomwatchytype
().
then
(
res
=>
{
uni
.
setStorageSync
(
"watch_type"
,
res
.
data
.
data
.
types
+
""
)
console
.
log
(
res
);
uni
.
setStorageSync
(
"watch_type"
,
res
.
data
.
data
.
types
+
""
)
this
.
watch_info
=
res
.
data
.
data
console
.
log
(
res
.
data
.
data
);
if
(
this
.
watch_info
.
types
==
1
)
{
...
...
@@ -182,20 +183,25 @@
//验证观看方式
check_watchtype
()
{
this
.
$api
.
roomwatchytypeverify
().
then
(
res
=>
{
console
.
log
(
res
);
if
(
res
.
data
.
code
===
200
)
{
if
(
this
.
watch_info
.
types
==
4
)
{
console
.
log
(
this
.
watch_info
)
if
(
!
uni
.
getStorageSync
(
"wxnick"
)
||
uni
.
getStorageSync
(
"wxnick"
)
!=
this
.
watch_info
.
wxNick
)
{
if
(
!
uni
.
getStorageSync
(
"wxnick"
)
||
uni
.
getStorageSync
(
"wxnick"
)
!=
this
.
watch_info
.
wxNick
)
{
this
.
is_show
=
true
this
.
$api
.
roomwatchytype
().
then
(
res
=>
{
var
wxis
=
"0"
String
()
if
(
res
.
data
.
data
.
wxNick
===
1
){
wxis
=
"1"
}
uni
.
setStorageSync
(
"wxnick"
,
wxis
)
})
uni
.
setStorageSync
(
"wxnick"
,
this
.
watch_info
.
wxNick
+
''
)
}
else
{
if
(
localStorage
.
getItem
(
'wxnick'
)
==
1
)
{
this
.
$api
.
getusertoken
(
''
,
uni
.
getStorageSync
(
"room_account"
),
true
).
then
(
res
=>
{
uni
.
setStorageSync
(
'room_token'
,
res
.
data
.
data
)
})
}
else
{
this
.
$api
.
getusertoken
(
uni
.
getStorageSync
(
"user_name1"
),
uni
.
getStorageSync
(
"room_account"
),
true
).
then
(
res
=>
{
uni
.
setStorageSync
(
'room_token'
,
res
.
data
.
data
)
})
}
}
}
else
{
uni
.
removeStorageSync
(
"room_token"
)
...
...
main.js
View file @
c939274d
import
App
from
'./App'
import
uView
from
'@/uni_modules/uview-ui'
import
api
from
"./api/index.js"
Vue
.
use
(
uView
)
// 如此配置即可
uni
.
$u
.
config
.
unit
=
'rpx'
Vue
.
prototype
.
$api
=
api
...
...
pages/index/index.vue
View file @
c939274d
...
...
@@ -7,10 +7,10 @@
</view>
<tabs
@
skipComponent=
"skip"
></tabs>
<!-- 聊天 -->
<component
:is=
"currentTabComponent"
:specialUrl=
"special"
></component>
<component
:is=
"currentTabComponent"
:specialUrl=
"special"
:msgList=
"msgList"
></component>
<!-- 底部 -->
<view
class=
"footer"
v-show=
"currentTabComponent == 'chat'"
>
<foot
@
specialShow=
"specialShow
"
></foot>
<foot
@
specialShow=
"specialShow"
@
sendmsg=
"sendmsg
"
></foot>
</view>
</view>
</
template
>
...
...
@@ -23,7 +23,9 @@
import
sinatv
from
"@/components/tabs/sinaTv/sinaTv.vue"
import
lives
from
"@/components/live/live.vue"
import
courseware
from
"@/components/tabs/courseware/courseware.vue"
import
face
from
"@/until/face.js"
var
Live
export
default
{
components
:
{
foot
,
...
...
@@ -40,15 +42,21 @@
value
:
''
,
currentTabComponent
:
'chat'
,
special
:
""
,
msgList
:
[],
scrollTop
:
0
}
},
created
()
{
this
.
getusertoken
()
},
onshow
()
{
},
methods
:
{
//触发消息
sendmsg
(
val
)
{
this
.
send
(
val
)
},
skip
(
value
)
{
this
.
currentTabComponent
=
value
},
...
...
@@ -59,6 +67,87 @@
_this
.
special
=
''
},
1000
)
},
gsnickname
(
val
)
{
var
msgname
=
val
msgname
=
msgname
.
replace
(
/
\d{8,}
/g
,
"*"
)
msgname
=
msgname
.
length
>
8
?
msgname
.
substring
(
0
,
8
)
+
"..."
:
msgname
return
msgname
},
//获取房间token
getusertoken
()
{
this
.
$nextTick
(()
=>
{
if
(
uni
.
getStorageSync
(
"login_ok"
)
==
'success'
)
{
this
.
$api
.
getusertoken
().
then
(
res
=>
{
var
that
=
this
var
roomdid
=
res
.
data
.
data
if
(
uni
.
getStorageSync
(
'room_token'
))
{
roomdid
=
uni
.
getStorageSync
(
'room_token'
)
}
Live
=
new
Finezb
.
Live
(
roomdid
)
Live
.
login
(
function
()
{
console
.
log
(
'登录成功'
,
JSON
.
stringify
(
Live
.
getLoginUser
()))
uni
.
setStorageSync
(
"user_account"
,
Live
.
getLoginUser
().
account
)
})
})
}
})
},
//发送消息
send
(
val
)
{
if
(
!
val
.
sendText
)
{
return
;
}
let
data
=
{
text
:
val
.
sendText
,
type
:
val
.
type
,
nickName
:
uni
.
getStorageSync
(
"user_name"
),
};
if
(
uni
.
getStorageSync
(
"watch_type"
)
==
4
&&
uni
.
getStorageSync
(
"wxnick"
)
==
0
)
{
data
.
nickName
=
uni
.
getStorageSync
(
"user_name1"
)
}
data
.
extra
=
{
headUrl
:
uni
.
getStorageSync
(
"user_headimg"
),
role
:
4
,
isDirty
:
0
};
// var sendlist = this.chatsetinfo.sensitiveWord
// if (this.chatsetinfo.sensitive && sendlist.length > 0) {
// for (var index in sendlist) {
// if (sendlist[index] != "" && sendlist[index].trim() != "" && this.sendText.includes(sendlist[
// index])) {
// data.extra.isDirty = 1
// break;
// }
// }
// }
data
.
extra
=
JSON
.
stringify
(
data
.
extra
);
let
msg
=
{
type
:
val
.
type
,
sendTime
:
new
Date
().
getTime
(),
extra
:
{
headUrl
:
uni
.
getStorageSync
(
"user_headimg"
),
role
:
4
},
sendName
:
uni
.
getStorageSync
(
"user_name"
),
text
:
face
.
replaceEm
(
val
.
sendText
)
}
if
(
uni
.
getStorageSync
(
"watch_type"
)
==
4
&&
uni
.
getStorageSync
(
"wxnick"
)
==
0
)
{
msg
.
sendName
=
uni
.
getStorageSync
(
"user_name1"
)
}
msg
.
sendName
=
msg
.
sendName
.
replace
(
/
\d{8,}
/g
,
"*"
)
msg
.
sendName
=
msg
.
sendName
.
length
>
8
?
msg
.
sendName
.
substring
(
0
,
8
)
+
"..."
:
msg
.
sendName
this
.
msgList
.
push
(
msg
)
this
.
scrollTop
=
9999999999
// console.log(that.datalist)
// let id = 'msg' + msg.sendTime;
// this.msgBoxToBottom(id);
Live
.
sendMsg
(
data
,
function
(
ack
)
{
console
.
log
(
ack
);
if
(
ack
.
code
===
200
)
{
this
.
scrollTop
=
500
}
})
},
}
}
</
script
>
...
...
@@ -97,7 +186,8 @@
box-shadow
:
0
-2
rpx
30
rpx
#dadada
;
;
}
#playerback
{
#playerback
{
width
:
100%
;
height
:
420
rpx
;
z-index
:
0
;
...
...
store/index.js
0 → 100644
View file @
c939274d
until/face.js
0 → 100644
View file @
c939274d
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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