deming/pages/zhibo/index.nvue

594 lines
15 KiB
Plaintext
Raw Normal View History

2020-07-28 12:47:52 +00:00
<template>
<view>
2020-09-03 03:57:40 +00:00
<video :src="url" class="vodio" :autoplay="true" id="myVideo" :show-fullscreen-btn="false" :show-play-btn="false" :enable-progress-gesture="false" :show-center-play-btn="false" :show-progress="false" :controls="false" :style="{'height':height}" @error="errors">
2020-07-28 12:47:52 +00:00
</video>
<view class="user" :style="{'top': top}">
<view class="back"></view>
2020-07-31 01:40:06 +00:00
<image class="head" :src="info.member_avatar"></image>
2020-07-28 12:47:52 +00:00
<view class="userinfo">
2020-07-31 01:40:06 +00:00
<text class="name">{{info.member_nickname}}</text>
<text class="info">{{info.live_desc}}</text>
2020-07-28 12:47:52 +00:00
</view>
2020-07-31 01:40:06 +00:00
<view class="guanzhu" @click="guanzhu"><text style="color:#fff;font-size:24rpx">{{info.is_attention == 1 ? '已关注' : '关注'}}</text></view>
2020-07-28 12:47:52 +00:00
</view>
<view class="userlist" :style="{'top': top + 10 * rpx}">
2020-08-04 03:43:33 +00:00
<image class="userlistitem" v-for="(i,j) in room.onlineUsers.users.slice(0,3)" :src="i.avatar" :style="{'right': (-j * 15 * rpx) + 'px'}" :key="j"></image>
2020-07-28 12:47:52 +00:00
</view>
2020-07-31 01:40:06 +00:00
<view class="hot" :style="{'top': top + 10 * rpx}">
2020-08-04 03:43:33 +00:00
<text class="hottext">{{room.onlineUsers.users.length}}</text>
2020-07-31 01:40:06 +00:00
</view>
2020-08-28 14:54:51 +00:00
<image v-if="list.length != 0" class="cart" src="../../static/cart.png" @click="show = true">
2020-07-31 01:40:06 +00:00
</image>
2020-08-10 09:30:41 +00:00
<view class="danmufasongbox" @click="danmu = $store.state.hasLogin">
2020-08-03 01:05:30 +00:00
<view class="danmufasongboxback"></view>
<image src="../../static/danmu.png" class="danmubianji"></image>
2020-08-10 11:19:29 +00:00
<text style="font-size:26rpx;color:#fff;margin-left:20rpx">{{ $store.state.hasLogin ? '想说点什么' : '请先登录'}}</text>
2020-08-03 01:05:30 +00:00
</view>
2020-08-13 02:04:50 +00:00
<!-- <image class="liketap" src="../../static/like.png" @click=""> -->
2020-08-03 01:05:30 +00:00
<view class="danmuinputbox" v-if="danmu">
2020-08-27 03:06:11 +00:00
<input type="text" focus="true" style="width:600rpx;margin-left:30rpx;font-size:26rpx" maxlength="100" @blur="danmu=false" :focus="danmu" v-model="danmutext">
2020-08-03 01:05:30 +00:00
<view class="danmufasong" @click="sendMessage(room.MessageType.CHAT,danmutext)">
<text style="font-size:24rpx;color:#fff">发送</text>
</view>
</view>
<div class="danmulist">
<text class="danmuitem" v-for="(i,j) in danmulist" :key="j">{{i.senderNickname}}:{{i.content}}</text>
</div>
2020-07-31 01:40:06 +00:00
<image class="closeimg" src="../../static/close.png" :style="{'top': top + 30 * rpx}" @click="back"></image>
</image>
<div class="bottom" :style="{'height':height + 'px'}" v-if="show" @click="show = false">
<div class="tanchuceng" @click="zuzhi">
<div class="heads">
<div style="flex-direction: row;align-items:center">
<text class="title">全部商品</text>
<text class="num">{{list.length}}件</text>
</div>
<!-- <div class="add">
<text style="font-size:28rpx;color: #fff;text-align:center">添加/管理商品</text>
</div> -->
</div>
<list class="list">
2020-08-01 03:16:53 +00:00
<cell class="item" v-for="(i,j) in list" :key="j" @click="xuanzhong(j)">
2020-07-31 01:40:06 +00:00
<image class="shopimg" :src="i.goods_image"></image>
<div class="infos">
<div>
<text style="font-size:26rpx;colro:#333;margin-top:12rpx;lines:1;text-overflow:ellipsis">{{i.goods_name}}</text>
<text style="font-size:24rpx;color:#333;margin-top:14rpx;lines:1;text-overflow:ellipsis">{{i.goods_advword}}</text>
</div>
<div style="flex-direction: row; align-items: flex-end;">
<text style="font-size:28rpx;color:#FF3131">¥{{i.goods_price}}</text>
<text style="font-size:26rpx;color:#999">¥{{i.goods_marketprice}}</text>
</div>
</div>
<!-- <image :src="'../../static/image/release/' + (i.putaway == 1 ? 'on' : 'off') + '.png'" style="width:55rpx;height:35rpx;margin-top:120rpx;margin-left:150rpx"></image> -->
</cell>
</list>
</div>
</div>
2020-07-28 12:47:52 +00:00
</view>
</template>
2020-08-03 02:34:06 +00:00
2020-07-28 12:47:52 +00:00
<style lang="scss" scoped>
2020-08-03 11:50:56 +00:00
.vodio{
width: 750rpx;
}
2020-07-31 01:40:06 +00:00
.infos{
height: 160rpx;
justify-content: space-between;
margin-left: 10rpx;
width: 404rpx;
}
.shopimg{
width: 160rpx;
height: 160rpx;
2020-08-13 02:04:50 +00:00
// background-color: #0f0;
2020-07-31 01:40:06 +00:00
}
.heads{
width: 750rpx;
height: 88rpx;
border-bottom-width: 2rpx;
border-style: solid;
border-color: #ECECEC;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.title{
font-size: 30rpx;
color:#333;
margin-left: 30rpx;
}
.tanchuceng{
width: 750rpx;
height: 782rpx;
position: fixed;
bottom: 0;
border-top-left-radius:20rpx;
border-top-left-radius:20rpx;
background-color: #fff;
transition: bottom 0.5s;
z-index: 20;
}
.item{
width: 690rpx;
height: 200rpx;
border-bottom-width: 2rpx;
border-style: solid;
border-color: #ECECEC;
display: flex;
flex-direction: row;
align-items: center;
}
.list{
width: 750rpx;
height: 694rpx;
padding-left: 30rpx;
padding-right: 30rpx;
}
.add{
width: 221rpx;
height: 40rpx;
background-color: #FF780F;
border-radius: 20rpx;
justify-content: center;
margin-right: 30rpx;
}
.num{
font-size: 26rpx;
color: #FF3131;
margin-left: 30rpx;
}
.bottom{
width: 750rpx;
position: fixed;
top:0;
z-index: 10;
}
.cart{
width: 50rpx;
height: 46rpx;
position: fixed;
bottom: 36rpx;
2020-08-13 02:04:50 +00:00
// right: 154rpx;
right: 54rpx;
2020-07-31 01:40:06 +00:00
}
.hottext{
font-size: 20rpx;
color: #fff;
}
.hot{
width: 60rpx;
height: 60rpx;
background-color: rgb(104, 104, 104);
position: fixed;
border-radius: 30rpx;
right: 86rpx;
align-items: center;
justify-content: center;
}
2020-07-28 12:47:52 +00:00
.userlistitem{
width: 60rpx;
height: 60rpx;
position: relative;
border-radius: 30rpx;
}
.userlist{
display: flex;
flex-direction: row-reverse;
width: 150rpx;
height: 60rpx;
position: fixed;
right: 156rpx;
}
.name {
font-size: 24rpx;
color: #fff;
lines: 1;
text-overflow: ellipsis;
}
.info {
font-size: 20rpx;
color: #fff;
margin-top: 6rpx;
lines: 1;
text-overflow: ellipsis;
}
.userinfo {
display: flex;
flex-direction: column;
width: 100rpx;
margin-left: 20rpx;
}
.guanzhu {
width: 100rpx;
height: 50rpx;
background-color: #ff780f;
border-radius: 25rpx;
margin-left: 10rpx;
align-items: center;
justify-content: center;
}
.head {
width: 70rpx;
height: 70rpx;
border-radius: 35rpx;
}
.back {
position: absolute;
top: 0;
left: 0;
background-color: #000;
opacity: 0.2;
width: 308rpx;
height: 70rpx;
border-radius: 35rpx;
}
.user {
position: fixed;
left: 30rpx;
width: 308rpx;
height: 70rpx;
display: flex;
align-items: center;
border-radius: 35rpx;
overflow: hidden;
flex-direction: row;
}
.video {
width: 750rpx;
}
2020-07-31 01:40:06 +00:00
.liketap{
width: 55rpx;
height: 57rpx;
position: fixed;
bottom: 30rpx;
right: 54rpx;
}
.closeimg{
width: 31rpx;
height: 31rpx;
position: fixed;
right: 31rpx;
}
2020-08-03 01:05:30 +00:00
.danmufasongbox{
width: 308rpx;
height: 58rpx;
position: fixed;
left: 30rpx;
bottom: 30rpx;
flex-direction: row;
align-items: center;
}
.danmufasongboxback{
position: absolute;
top: 0;
left: 0;
width: 308rpx;
height: 58rpx;
2020-08-13 02:04:50 +00:00
background-color: #000;
2020-08-03 01:05:30 +00:00
opacity: 0.4;
border-radius: 29rpx;
}
.danmubianji{
width: 27rpx;
height: 32rpx;
margin-left: 20rpx;
}
.danmuinputbox{
position: fixed;
bottom:0;
height: 100rpx;
width: 750rpx;
z-index: 9999;
background-color: #fff;
flex-direction: row;
align-items: center;
}
.danmufasong{
width: 85rpx;
height: 51rpx;
background-color: #FF780F;
align-items: center;
justify-content: center;
border-radius: 5rpx;
}
.danmulist{
position: fixed;
left: 30rpx;
bottom: 118rpx;
2020-09-01 08:53:41 +00:00
width: 690rpx;
2020-08-03 01:05:30 +00:00
}
.danmuitem{
font-size: 26rpx;
color: #fff;
flex-direction: column-reverse;
2020-09-01 08:53:41 +00:00
word-wrap:anywhere;
2020-08-03 01:05:30 +00:00
}
2020-07-28 12:47:52 +00:00
</style>
2020-08-03 02:34:06 +00:00
2020-07-28 12:47:52 +00:00
<script>
2020-08-03 01:05:30 +00:00
const ChatRoomService =require('../../static/chatservice');
2020-07-28 12:47:52 +00:00
export default {
name: "zhibo",
data() {
return {
url: "",
top: 0,
height: 0,
2020-07-31 01:40:06 +00:00
rpx:0,
show:false,
list:[],
id:0,
2020-08-03 01:05:30 +00:00
info:{},
danmutext:"",
danmu:false,
room:{},
chatRoomService:{},
2020-09-03 03:57:40 +00:00
danmulist:[],
videoContext:{}
2020-07-28 12:47:52 +00:00
};
},
2020-08-14 02:00:27 +00:00
onBackPress(options) {
uni.setKeepScreenOn({
keepScreenOn: false
});
return false;
},
2020-09-03 03:32:58 +00:00
onShow(){
2020-09-03 03:57:40 +00:00
this.videoContext.play()
2020-09-03 03:32:58 +00:00
},
2020-07-28 12:47:52 +00:00
onLoad(a) {
2020-09-03 03:57:40 +00:00
this.videoContext = uni.createVideoContext('myVideo')
2020-07-28 12:47:52 +00:00
this.url = a.url;
2020-07-31 01:40:06 +00:00
this.id = a.id
2020-07-28 12:47:52 +00:00
console.log(this.url);
let that = this;
2020-08-14 02:00:27 +00:00
uni.setKeepScreenOn({
keepScreenOn: true
});
2020-08-03 07:56:51 +00:00
2020-07-28 12:47:52 +00:00
uni.getSystemInfo({
success(a) {
console.log(a.windowHeight);
that.height = a.windowHeight;
// that.start()
that.top = a.statusBarHeight + 5;
that.rpx = (a.windowWidth / 750)
console.log(that.rpx)
},
});
2020-07-31 01:40:06 +00:00
// this.$u.api.goodsShelves({live_id:this.id}).then((res)=>{
// console.log(res)
// })
const token = uni.getStorageSync('token');
console.log(token,that.id)
uni.request({
2020-08-18 07:29:52 +00:00
url:"https://mall.dmygkeji.com/api/Specialci/goodsShelves",
2020-07-31 01:40:06 +00:00
data:{
live_id:that.id
},
method:"POST",
header:{
"Authorization" : 'Bearer' + " " + token
},
success(res){
console.log(res)
that.list= res.data.data
}
})
setInterval(function(){
uni.request({
2020-08-18 07:29:52 +00:00
url:"https://mall.dmygkeji.com/api/Specialci/goodsShelves",
2020-07-31 01:40:06 +00:00
data:{
live_id:that.id
},
method:"POST",
header:{
"Authorization" : 'Bearer' + " " + token
},
success(res){
console.log(res)
that.list= res.data.data
}
})
2020-08-08 08:14:25 +00:00
that.$forceUpdate();
console.log(that.room)
2020-08-12 02:43:47 +00:00
},10 * 1000)
2020-07-31 01:40:06 +00:00
uni.request({
2020-08-18 07:29:52 +00:00
url:"https://mall.dmygkeji.com/api/Specialci/livingUserInfo",
2020-07-31 01:40:06 +00:00
data:{
live_id:that.id
},
method:"POST",
header:{
"Authorization" : 'Bearer' + " " + token
},
success(res){
2020-09-15 08:44:03 +00:00
2020-07-31 01:40:06 +00:00
console.log(res)
that.info = res.data.data
// that.list= res.data.data
}
})
2020-08-15 07:37:16 +00:00
var room = {
id : a.rid + "",
name : a.rid + ""
};
that.chatRoomService = getApp().globalData.im
//构造chatRoomService
2020-08-18 07:08:42 +00:00
that.chatRoomService.subscribeRoomMessage(room)
2020-08-15 07:37:16 +00:00
//获取当前聊天室数据
that.room = that.chatRoomService.room;
that.chatRoomService.initialWhenOnlineUserChange(that.newpeople)
that.chatRoomService.initialWhenNewMessage(that.whenNewMessage);
2020-09-01 07:55:32 +00:00
that.chatRoomService.jieshuzhibo = this.jieshu;
2020-08-15 07:37:16 +00:00
this.$forceUpdate();
console.log(that.room)
2020-08-03 01:05:30 +00:00
2020-07-28 12:47:52 +00:00
},
2020-08-03 07:56:51 +00:00
onBackPress () {//返回取消订阅
//断开连接
this.chatRoomService.quitRoom();
},
beforeDestroy () {
this.chatRoomService.quitRoom();
},
2020-07-31 01:40:06 +00:00
methods:{
2020-09-01 07:55:32 +00:00
jieshu(text){
console.log(text)
uni.showModal({
title: '提示',
content: text.content,
showCancel:false,
success: function (res) {
uni.navigateBack({
delta: 1
});
}
});
},
2020-08-14 06:40:01 +00:00
errors(a){
2020-09-15 08:44:03 +00:00
console.log(a)
2020-08-14 06:40:01 +00:00
},
2020-08-14 03:07:17 +00:00
newpeople(list){
this.room.onlineUsers = list
2020-08-15 05:36:16 +00:00
console.log(list.users.length)
2020-08-14 06:40:01 +00:00
this.$forceUpdate();
2020-08-14 03:07:17 +00:00
},
2020-08-03 01:05:30 +00:00
sendMessage (messageType, content) {//发送消息
2020-08-13 08:05:43 +00:00
if(!this.chatRoomService.status){
uni.showToast({
title: '连接聊天室中,请稍等',
2020-08-14 01:26:59 +00:00
duration: 2000,
icon: "none"
2020-08-13 08:05:43 +00:00
});
return
}
2020-08-08 07:40:48 +00:00
console.log(this.room,this.room.id,messageType, content)
2020-08-03 01:05:30 +00:00
if(content == "" && messageType == 0) return;
var message = {
senderNickname : this.room.currentUser.nickname ,
type : messageType,
content : content
}
this.chatRoomService.sendMessages(this.room.id, message);
2020-08-13 02:04:50 +00:00
this.danmutext = ""
this.danmu = false
2020-08-14 01:19:11 +00:00
uni.hideKeyboard()
2020-08-03 01:05:30 +00:00
},
whenNewMessage (message) {//新消息监听
// if(message.type == this.room.MessageType.PROP){
// this.propAnimation(parseInt(message.content))
// }
// setTimeout(() => {
// this.contentPosition = 'message-box'+(this.room.messages.length-1);
// }, 300)
console.log(message)
2020-09-15 08:44:03 +00:00
if(message.type == 1){
this.videoContext.stop();
this.videoContext.play()
console.log('stop')
return ;
}
2020-08-03 01:05:30 +00:00
this.danmulist.push(message)
2020-08-03 07:56:51 +00:00
2020-08-03 01:05:30 +00:00
if(this.danmulist.length > 7){
this.danmulist = this.danmulist.slice(this.danmulist.length - 7)
}
},
2020-07-31 01:40:06 +00:00
back(){
uni.navigateBack({
delta: 1
});
},
guanzhu(){
2020-08-17 09:30:51 +00:00
if(!this.$store.state.hasLogin){
uni.showToast({
title: '请先登录',
duration: 2000,
icon:"none"
});
return ;
}
2020-07-31 01:40:06 +00:00
const token = uni.getStorageSync('token');
let that = this
console.log(token)
uni.request({
2020-08-18 07:29:52 +00:00
url:"https://mall.dmygkeji.com/api/member/attentionMember",
2020-07-31 01:40:06 +00:00
data:{
member_id:that.info.user_id
},
method:"POST",
header:{
"Authorization" : 'Bearer' + " " + token
},
success(res){
console.log(res)
uni.request({
2020-08-18 07:29:52 +00:00
url:"https://mall.dmygkeji.com/api/Specialci/livingUserInfo",
2020-07-31 01:40:06 +00:00
data:{
live_id:that.id
},
method:"POST",
header:{
"Authorization" : 'Bearer' + " " + token
},
2020-09-01 08:07:56 +00:00
success(a){
console.log(a)
that.info = a.data.data;
2020-08-12 14:00:01 +00:00
uni.showToast({
title: res.data.message,
icon: "none"
})
2020-07-31 01:40:06 +00:00
// that.list= res.data.data
}
})
// that.list= res.data.data
}
})
},
xuanzhong(i){
let that = this
2020-09-01 09:33:11 +00:00
const token = uni.getStorageSync('token');
if(this.$store.state.hasLogin){
uni.request({
url:"https://mall.dmygkeji.com/api/Specialci/viewingOPproducts",
data:{
good_id:that.list[i].goods_id,
exple_id:that.info.user_id
},
method:"POST",
header:{
"Authorization" : 'Bearer' + " " + token
},
success(a){
console.log(a)
}
})
}
2020-07-31 01:40:06 +00:00
uni.navigateTo({
url: `/pageB/sdetails/index?id=${that.list[i].goods_id}&type=1`
});
},
zuzhi(event){
event.stopPropagation();
},
}
2020-07-28 12:47:52 +00:00
};
2020-08-03 02:34:06 +00:00
</script>