Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
b30110e8
Commit
b30110e8
authored
Mar 20, 2020
by
李嘉林
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
直播结束
parent
74719c90
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
131 additions
and
102 deletions
+131
-102
src/api/live.js
+7
-2
src/components/livedModel/livedGoodsDia.vue
+2
-2
src/components/livedModel/livedIsEnded.vue
+39
-45
src/components/livedModel/livedSelectionSpe.vue
+1
-1
src/pages/lived/index.vue
+82
-52
No files found.
src/api/live.js
View file @
b30110e8
...
@@ -39,10 +39,14 @@ export default {
...
@@ -39,10 +39,14 @@ export default {
},
},
// 直播间点赞接口
// 直播间点赞接口
addLiveLikeByUser
(
options
)
{
addLiveLikeByUser
(
options
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
liveBroadcastInfo/addLiveLikeByUser`
,
options
);
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/
liveBroadcastInfo/addLiveLikeByUser`
,
options
);
},
},
// 直播中商品列表
// 直播中商品列表
getListByLiveBroadcastId
(
options
)
{
getListByLiveBroadcastId
(
options
)
{
return
requestGET
(
`
${
process
.
env
.
OLSHOP_URL
}
liveBroadcastGoods/getListByLiveBroadcastId?id=
${
Number
(
options
)}
`
);
return
requestGET
(
`
${
process
.
env
.
OLSHOP_URL
}
/liveBroadcastGoods/getListByLiveBroadcastId?id=
${
Number
(
options
)}
`
);
},
// 单次直播数据统计接口
getLiveStatisticsById
(
options
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/liveBroadcastInfo/getLiveStatisticsById`
,
options
);
},
},
};
};
\ No newline at end of file
src/components/livedModel/livedGoodsDia.vue
View file @
b30110e8
...
@@ -183,10 +183,10 @@ export default {
...
@@ -183,10 +183,10 @@ export default {
fromLived
:
1
,
fromLived
:
1
,
liveId
:
this
.
liveId
liveId
:
this
.
liveId
};
};
this
.
backPath
=
`/goods/
${
val
.
productId
}
`
;
let
backPath
=
`/goods/
${
val
.
productId
}
`
;
wx
.
reLaunch
({
wx
.
reLaunch
({
url
:
`../index/main?from=livedToGoodsInfo&backpath=
${
url
:
`../index/main?from=livedToGoodsInfo&backpath=
${
this
.
backPath
backPath
}
¶ms=
${
JSON
.
stringify
(
query
)}
`
}
¶ms=
${
JSON
.
stringify
(
query
)}
`
});
});
}
}
...
...
src/components/livedModel/livedIsEnded.vue
View file @
b30110e8
...
@@ -9,15 +9,15 @@
...
@@ -9,15 +9,15 @@
</p>
</p>
<div
class=
"data"
>
<div
class=
"data"
>
<div>
<div>
<p>
333
</p>
<p>
{{
endInfo
.
watchNum
}}
</p>
<p>
观看
</p>
<p>
观看
</p>
</div>
</div>
<div>
<div>
<p>
333
</p>
<p>
{{
endInfo
.
guestBookNum
}}
</p>
<p>
评论
</p>
<p>
评论
</p>
</div>
</div>
<div>
<div>
<p>
333
</p>
<p>
{{
endInfo
.
likeNum
}}
</p>
<p>
赞
</p>
<p>
赞
</p>
</div>
</div>
</div>
</div>
...
@@ -29,15 +29,15 @@
...
@@ -29,15 +29,15 @@
</div>
</div>
<div
class=
"list"
>
<div
class=
"list"
>
<div
class=
"item"
v-for=
"(item,index) in list"
:key=
"index"
>
<div
class=
"item"
v-for=
"(item,index) in list"
:key=
"index"
>
<div
class=
"img"
>
<div
class=
"img"
@
click=
"toGoodsInfo(item)"
>
<img
:src=
"item.
img
"
alt
/>
<img
:src=
"item.
productImgUrl
"
alt
/>
</div>
</div>
<div
class=
"info"
>
<div
class=
"info"
>
<p
class=
"name line-clamp2"
>
{{
item
.
n
ame
}}
</p>
<p
class=
"name line-clamp2"
>
{{
item
.
productN
ame
}}
</p>
<div
class=
"price"
>
<div
class=
"price"
>
<p>
<p>
<span>
¥
</span>
<span>
¥
</span>
<span>
{{
item
.
p
rice
}}
</span>
<span>
{{
item
.
minP
rice
}}
</span>
</p>
</p>
<div
class=
"icon"
>
<div
class=
"icon"
>
<van-icon
name=
"shopping-cart"
/>
<van-icon
name=
"shopping-cart"
/>
...
@@ -53,48 +53,42 @@
...
@@ -53,48 +53,42 @@
<
script
type=
"text/ecmascript-6"
>
<
script
type=
"text/ecmascript-6"
>
export
default
{
export
default
{
props
:
[
"updateGoods"
,
"goodsList
"
],
props
:
[
"updateGoods"
,
"goodsList"
,
"endInfo
"
],
name
:
""
,
name
:
""
,
data
()
{
data
()
{
return
{
return
{
list
:
[
list
:
[],
{
liveId
:
0
name
:
"产品名称产品名称产品名称产品名称产品名称"
,
img
:
"//img3.imgtn.bdimg.com/it/u=3743111107,1940472030&fm=11&gp=0.jpg"
,
price
:
123
},
{
name
:
"产品名称产品名称产品名称产品名称产品名称"
,
img
:
"//img3.imgtn.bdimg.com/it/u=3743111107,1940472030&fm=11&gp=0.jpg"
,
price
:
123
},
{
name
:
"产品名称产品名称产品名称产品名称产品名称"
,
img
:
"//img3.imgtn.bdimg.com/it/u=3743111107,1940472030&fm=11&gp=0.jpg"
,
price
:
123
},
{
name
:
"产品名称产品名称产品名称产品名称产品名称"
,
img
:
"//img3.imgtn.bdimg.com/it/u=3743111107,1940472030&fm=11&gp=0.jpg"
,
price
:
123
}
]
};
};
},
},
watch
:{
watch
:
{
updateGoods
(){
updateGoods
()
{
this
.
list
=
this
.
goodsList
;
this
.
list
=
this
.
goodsList
;
}
}
},
},
components
:
{},
components
:
{},
computed
:
{},
computed
:
{},
onLoad
(
options
)
{
let
params
=
JSON
.
parse
(
options
.
params
);
this
.
liveId
=
params
.
liveId
;
},
created
()
{},
created
()
{},
mounted
()
{},
mounted
()
{},
methods
:
{}
methods
:
{
// 到商品详情
toGoodsInfo
(
val
)
{
let
query
=
{
fromLived
:
1
,
liveId
:
this
.
liveId
};
let
backPath
=
`/goods/
${
val
.
productId
}
`
;
wx
.
reLaunch
({
url
:
`../index/main?from=livedToGoodsInfo&backpath=
${
backPath
}
¶ms=
${
JSON
.
stringify
(
query
)}
`
});
}
}
};
};
</
script
>
</
script
>
...
@@ -159,7 +153,7 @@ export default {
...
@@ -159,7 +153,7 @@ export default {
}
}
.tit
{
.tit
{
font-size
:
16px
;
font-size
:
16px
;
padding
:
0
4px
;
padding
:
0
4px
6px
0
;
}
}
.list
{
.list
{
max-height
:
50vh
;
max-height
:
50vh
;
...
@@ -188,20 +182,20 @@ export default {
...
@@ -188,20 +182,20 @@ export default {
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
justify-content
:
space-between
;
justify-content
:
space-between
;
.name{
.name
{
text-align
:
left
;
text-align
:
left
;
}
}
.price
{
.price
{
display
:
flex
;
display
:
flex
;
justify-content
:
space-between
;
justify-content
:
space-between
;
align-items
:
center
;
align-items
:
center
;
font-size
:
18px
;
font-size
:
18px
;
span{
span
{
color
:
#
FF
0000
;
color
:
#
ff
0000
;
}
}
.icon
{
.icon
{
font-size
:
22px
;
font-size
:
22px
;
color
:
#
FF
8181
;
color
:
#
ff
8181
;
}
}
}
}
}
}
...
...
src/components/livedModel/livedSelectionSpe.vue
View file @
b30110e8
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
<div>
¥
{{
product_goods_info
.
discountPrice
}}
</div>
<div>
¥
{{
product_goods_info
.
discountPrice
}}
</div>
<div
v-if=
"product_goods_info.singleItemActivityId"
>
<div
v-if=
"product_goods_info.singleItemActivityId"
>
<p
class=
"delPrice"
>
¥
{{
product_goods_info
.
originalPrice
}}
</p>
<p
class=
"delPrice"
>
¥
{{
product_goods_info
.
originalPrice
}}
</p>
<!--
<del
style=
"color:#666;"
>
¥
{{
product_goods_info
.
originalPrice
}}
</
!
-->
-->
<!--
<del
style=
"color:#666;"
>
¥
{{
product_goods_info
.
originalPrice
}}
</
!
-->
</div>
</div>
<div
<div
v-else-if=
"product_goods_info.discountPrice-0
<product
_goods_info
.
goodsSuggestedRetailPrice-0
"
v-else-if=
"product_goods_info.discountPrice-0
<product
_goods_info
.
goodsSuggestedRetailPrice-0
"
...
...
src/pages/lived/index.vue
View file @
b30110e8
...
@@ -28,7 +28,12 @@
...
@@ -28,7 +28,12 @@
<!-- 未开始展示 -->
<!-- 未开始展示 -->
<notStarted
v-if=
"liveNoticeInfo.liveBroadcastState==0"
:info=
"liveNoticeInfo"
></notStarted>
<notStarted
v-if=
"liveNoticeInfo.liveBroadcastState==0"
:info=
"liveNoticeInfo"
></notStarted>
<!-- 结束展示 -->
<!-- 结束展示 -->
<livedIsEnded
v-if=
"liveNoticeInfo.liveBroadcastState==2"
:updateGoods=
"updateGoods"
:goodsList=
"goodsList"
></livedIsEnded>
<livedIsEnded
v-if=
"liveNoticeInfo.liveBroadcastState==2&&endInfo"
:updateGoods=
"updateGoods"
:endInfo=
"endInfo"
:goodsList=
"goodsList"
></livedIsEnded>
<!-- 控件层 -->
<!-- 控件层 -->
<livedControls
<livedControls
v-if=
"liveNoticeInfo&&liveNoticeInfo.liveBroadcastState
<2
"
v-if=
"liveNoticeInfo&&liveNoticeInfo.liveBroadcastState
<2
"
...
@@ -46,7 +51,7 @@
...
@@ -46,7 +51,7 @@
<live-player
<live-player
v-if=
"liveNoticeInfo.liveBroadcastState==1&&liveNoticeInfo.boStreamRTMP"
v-if=
"liveNoticeInfo.liveBroadcastState==1&&liveNoticeInfo.boStreamRTMP"
class=
"livePlayer"
class=
"livePlayer"
:src=
"
'rtmp://live.mayi888.com/xgy/127?auth_key=1584633600000-0-0-ac39474385b37a7adac070d15b0bb5de'
"
:src=
"
liveNoticeInfo.boStreamRTMP
"
mode=
"RTC"
mode=
"RTC"
autoplay
autoplay
@
error=
"error"
@
error=
"error"
...
@@ -76,14 +81,17 @@ export default {
...
@@ -76,14 +81,17 @@ export default {
liveNoticeInfo
:
{},
//详情
liveNoticeInfo
:
{},
//详情
entryNoticeText
:
""
,
//用户通知
entryNoticeText
:
""
,
//用户通知
guestBookList
:
[],
// 定时查评论
guestBookList
:
[],
// 定时查评论
goodsList
:
[],
//商品列表
goodsList
:
[],
//商品列表
updateVal
:
0
,
//子组件监听此数据进行数据赋值
updateVal
:
0
,
//子组件监听此数据进行数据赋值
updateGoods
:
0
,
//商品相关组件监听
updateGoods
:
0
,
//商品相关组件监听
likeInfo
:
{},
//点赞
likeInfo
:
{},
//点赞
isVideo
:
false
,
//是否有直播或回放链接
isVideo
:
false
,
//是否有直播或回放链接
liveTime
:
null
,
//定时器
liveTime
:
null
,
//定时器
isWifi
:
true
,
//提示网络环境
isWifi
:
true
,
//提示网络环境
infoTiming
:
null
//定时器
infoTiming
:
null
,
//全局定时器
goodTiming
:
null
,
//商品定时器
endInfo
:
{},
//直播结束详情
firstComing
:
true
// 首次进入
};
};
},
},
components
:
{
components
:
{
...
@@ -115,21 +123,22 @@ export default {
...
@@ -115,21 +123,22 @@ export default {
this
.
shopName
=
params
.
shopName
;
this
.
shopName
=
params
.
shopName
;
this
.
shopLogo
=
DFSImg
(
params
.
shopLogo
,
40
,
40
);
this
.
shopLogo
=
DFSImg
(
params
.
shopLogo
,
40
,
40
);
this
.
init
();
this
.
init
();
setTimeout
(()
=>
{
this
.
infoTiming
=
setInterval
(()
=>
{
this
.
infoTiming
=
setInterval
(()
=>
{
this
.
timingGetInfo
();
this
.
timingGetInfo
();
},
5000
);
this
.
getGoodsList
();
},
5000
);
},
2000
);
this
.
userEntry
(
"IN"
);
this
.
userEntry
(
"IN"
);
},
},
onUnload
()
{
onUnload
()
{
this
.
userEntry
(
"OUT"
);
this
.
userEntry
(
"OUT"
);
this
.
liveNoticeInfo
.
liveBroadcastState
=
-
1
;
this
.
liveNoticeInfo
.
liveBroadcastState
=
-
1
;
this
.
liveNoticeInfo
=
{};
this
.
liveNoticeInfo
=
{};
this
.
firstComing
=
true
;
if
(
this
.
infoTiming
)
{
if
(
this
.
infoTiming
)
{
clearInterval
(
this
.
infoTiming
);
clearInterval
(
this
.
infoTiming
);
}
}
if
(
this
.
goodTiming
)
{
clearInterval
(
this
.
goodTiming
);
}
},
},
mounted
()
{},
mounted
()
{},
methods
:
{
methods
:
{
...
@@ -143,16 +152,22 @@ export default {
...
@@ -143,16 +152,22 @@ export default {
this
.
liveNoticeInfo
.
coverUrl
=
this
.
liveNoticeInfo
.
coverUrl
this
.
liveNoticeInfo
.
coverUrl
=
this
.
liveNoticeInfo
.
coverUrl
?
DFSImg
(
this
.
liveNoticeInfo
.
coverUrl
)
?
DFSImg
(
this
.
liveNoticeInfo
.
coverUrl
)
:
""
;
:
""
;
if
(
this
.
liveNoticeInfo
.
liveBroadcastState
>
1
&&
this
.
infoTiming
)
{
clearInterval
(
this
.
infoTiming
);
}
else
{
// 调用定时接口
this
.
timingGetInfo
();
}
this
.
getGoodsList
();
this
.
getGoodsList
();
if
(
this
.
liveNoticeInfo
.
liveBroadcastState
>=
2
)
{
if
(
this
.
liveNoticeInfo
.
liveBroadcastState
==
2
)
{
// 调直播结束
// 调直播结束
this
.
endLived
();
this
.
endLived
();
}
else
{
this
.
timingGetInfo
();
}
if
(
this
.
liveNoticeInfo
.
liveBroadcastState
!=
2
&&
!
this
.
goodTiming
)
{
this
.
goodTiming
=
setInterval
(()
=>
{
this
.
getGoodsList
();
},
5000
);
}
else
if
(
this
.
liveNoticeInfo
.
liveBroadcastState
==
2
&&
this
.
goodTiming
)
{
clearInterval
(
this
.
goodTiming
);
}
}
}
}
});
});
...
@@ -187,38 +202,45 @@ export default {
...
@@ -187,38 +202,45 @@ export default {
)
{
)
{
// 未开始且接口也未开始不作操作
// 未开始且接口也未开始不作操作
}
else
if
(
}
else
if
(
this
.
liveNoticeInfo
.
liveBroadcastState
==
0
&&
resData
.
liveState
==
"IN_LIVE"
)
{
// 未开始且接口直播中
this
.
init
();
}
else
if
(
this
.
liveNoticeInfo
.
liveBroadcastState
==
1
&&
this
.
liveNoticeInfo
.
liveBroadcastState
==
1
&&
resData
.
liveState
==
"IN_LIVE"
resData
.
liveState
==
"IN_LIVE"
)
{
)
{
// 直播中且接口直播中---主要操作
// 直播中且接口直播中---主要操作
// 数据初始化
// 数据初始化
this
.
entryNoticeText
=
""
;
this
.
entryNoticeText
=
""
;
this
.
liveNoticeInfo
.
watchNum
=
resData
.
watchNum
;
//观看人数
this
.
liveNoticeInfo
.
watchNum
=
resData
.
watchNum
;
//观看人数
if
(
resData
.
entryNoticeList
.
length
>
0
)
{
if
(
resData
.
entryNoticeList
.
length
>
0
)
{
if
(
resData
.
entryNoticeList
.
length
==
1
)
{
if
(
resData
.
entryNoticeList
.
length
==
1
)
{
this
.
entryNoticeText
=
`
${
resData
.
entryNoticeList
[
0
].
userName
}
`
;
//用户进入
this
.
entryNoticeText
=
`
${
resData
.
entryNoticeList
[
0
].
userName
}
`
;
//用户进入
}
else
{
}
else
{
this
.
entryNoticeText
=
`
${
this
.
entryNoticeText
=
`
${
resData
.
entryNoticeList
[
0
].
userName
resData
.
entryNoticeList
[
0
].
userName
}
等
${
resData
.
entryNoticeList
.
length
}
人`
;
//用户进入
}
等
${
resData
.
entryNoticeList
.
length
}
人`
;
//用户进入
}
}
}
}
}
else
if
(
}
else
if
(
this
.
liveNoticeInfo
.
liveBroadcastState
==
1
&&
this
.
liveNoticeInfo
.
liveBroadcastState
==
0
&&
resData
.
liveState
==
"
END
_LIVE"
resData
.
liveState
==
"
IN
_LIVE"
)
{
)
{
// 直播中且接口已结束
console
.
log
(
"未开始----直播中"
)
// 未开始且接口直播中/直播中且接口已结束
this
.
init
();
this
.
init
();
}
else
if
(
(
this
.
liveNoticeInfo
.
liveBroadcastState
==
2
&&
resData
.
liveState
==
"END_LIVE"
)
||
(
this
.
liveNoticeInfo
.
liveBroadcastState
==
1
&&
resData
.
liveState
==
"END_LIVE"
)
)
{
console
.
log
(
this
.
liveNoticeInfo
.
liveBroadcastState
,
resData
.
liveState
,
this
.
firstComing
,
"直播中----结束"
,
"结束----结束"
)
//直播结束且接口已结束
if
(
this
.
firstComing
)
{
this
.
firstComing
=
false
;
this
.
init
();
}
}
}
this
.
guestBookList
=
resData
.
guestBookList
;
//评论列表
this
.
guestBookList
=
resData
.
guestBookList
;
//评论列表
this
.
likeInfo
=
resData
.
likeInfo
;
//点赞信息
this
.
likeInfo
=
resData
.
likeInfo
;
//点赞信息
this
.
updateVal
=
Math
.
random
();
//监听使用数据
this
.
updateVal
=
Math
.
random
();
//监听使用数据
}
else
{
}
else
{
if
(
this
.
infoTiming
)
{
if
(
this
.
infoTiming
)
{
clearInterval
(
this
.
infoTiming
);
clearInterval
(
this
.
infoTiming
);
...
@@ -227,28 +249,36 @@ export default {
...
@@ -227,28 +249,36 @@ export default {
});
});
},
},
// 获取商品列表
// 获取商品列表
getGoodsList
(){
getGoodsList
()
{
let
id
=
this
.
liveId
;
let
id
=
this
.
liveId
;
live
.
getListByLiveBroadcastId
(
id
).
then
(
res
=>
{
live
.
getListByLiveBroadcastId
(
id
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
){
if
(
res
.
data
.
code
==
200
)
{
this
.
goodsList
=
[];
this
.
goodsList
=
[];
let
arr
=
[];
let
arr
=
[];
if
(
res
.
data
.
data
.
length
>
0
){
if
(
res
.
data
.
data
.
length
>
0
)
{
this
.
goodsList
=
res
.
data
.
data
.
forEach
((
item
,
index
)
=>
{
this
.
goodsList
=
res
.
data
.
data
.
forEach
((
item
,
index
)
=>
{
if
(
item
.
productImgUrl
){
if
(
item
.
productImgUrl
)
{
item
.
productImgUrl
=
DFSImg
(
item
.
productImgUrl
);
item
.
productImgUrl
=
DFSImg
(
item
.
productImgUrl
);
item
.
minPrice
=
Number
(
item
.
minPrice
);
}
}
arr
.
push
(
item
);
arr
.
push
(
item
);
})
})
;
this
.
goodsList
=
arr
;
this
.
goodsList
=
arr
;
this
.
updateGoods
=
Math
.
random
();
this
.
updateGoods
=
Math
.
random
();
}
}
}
}
})
})
;
},
},
// 直播结束数据
// 直播结束数据
endLived
(){
endLived
()
{
let
query
=
{
id
:
Number
(
this
.
liveId
)
};
live
.
getLiveStatisticsById
(
query
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
)
{
this
.
endInfo
=
res
.
data
.
data
;
}
});
},
},
userEntry
(
type
)
{
userEntry
(
type
)
{
let
query
=
{
let
query
=
{
...
@@ -268,11 +298,11 @@ export default {
...
@@ -268,11 +298,11 @@ export default {
}
}
});
});
},
},
error
(
res
){
error
(
res
)
{
console
.
log
(
res
,
'------------------237'
)
console
.
log
(
res
,
"------------------237"
);
},
},
changes
(
res
){
changes
(
res
)
{
console
.
log
(
res
,
'---------------241'
)
console
.
log
(
res
,
"---------------241"
);
}
}
}
}
};
};
...
...
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