文件
xionggeshop/xgsc.gynhc.com_wx/pages/user/live-copy.nvue
2026-09-14 17:24:53 +08:00

449 行
8.7 KiB
Plaintext

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<template>
<div>
<view :style="{width: width + 'px',height:height + 'px'}" v-if="markact" class="mark">
<text class="mark-text">直播启动中...</text>
</view>
<view>
<view @click="returns" class="arrow-box">
<text class="jiesu">结束直播</text>
</view>
<live-pusher :beauty="beauty" :style="{width: width + 'px',height:height + 'px'}" id="livePusher" :url="url"
mode="FHD"></live-pusher>
<!-- 这是聊天室 -->
<!-- <view class="chat">
<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltoupper="upper"
@scrolltolower="lower" @scroll="scroll">
<view class="chat-list" v-for="(it,i) in chatList" :key='i'>
<text class="chat-username">{{it.name}}:</text>
<text class="chat-usertext">{{it.text}}</text>
</view>
</scroll-view>
</view> -->
<!-- 这是功能按钮 -->
<view :style="{width: width + 'px'}" class="but">
<!-- <view @click="openMark(0)" class="meiyanbut">
<image class="but-img" src="../../static/zhiboshop.png"></image>
<text class="but-text">宝贝</text>
</view> -->
<view @click="openmeiyan" class="meiyanbut">
<image class="but-img" src="../../static/meiyan.png"></image>
<text v-if="beauty == 0" class="but-text">开启美颜</text>
<text v-if="beauty == 9" class="but-text">关闭美颜</text>
</view>
<view @click="switchCamera" class="meiyanbut">
<image class="but-img" src="../../static/qiehuan.png"></image>
<text class="but-text">切换摄像头</text>
</view>
</view>
<uni-popup ref="popup" type="bottom">
<!-- 这是商品弹窗 -->
<view class="shop-list-box" :style="{width: width + 'px'}" v-if="type == 0">
<text :style="{width: width + 'px'}" class="mark-title">直播商品</text>
<text @click="add()" class="add-shop">添加商品</text>
<scroll-view :style="{width: width + 'px'}" :scroll-top="scrollTop" scroll-y="true"
class="scroll-Ys" @scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll">
<view class="shop-list-list" v-for="(it,i) in shopArr" :key='i'>
<view>
<image class="shop-list-img" :src="it.img"></image>
</view>
<view>
<text class="shop-list-title">{{it.title}}</text>
<text class="shop-list-num">剩余{{it.num}}件</text>
<text class="shop-list-price">¥{{it.price}}</text>
</view>
<view class="shop-list-but-box">
<text class="shop-list-but">移除</text>
</view>
</view>
</scroll-view>
</view>
</uni-popup>
</view>
<!-- <u-modal :show="show" content='是否结束直播'></u-modal> -->
</div>
</template>
<script>
import uniPopup from "@/components/uni-popup/uni-popup.vue"
export default {
components: {
uniPopup
},
data() {
return {
show: false,
type: "",
width: '',
height: '',
url: '', //这是推流地址
enableCamera: false,
context: null,
markact: true,
arr: [],
shopArr: [{
img: '../../static/logo.png',
title: '测试商品',
price: '111',
num: '20',
},
{
img: '../../static/logo.png',
title: '测试商品',
price: '111',
num: '20',
},
{
img: '../../static/logo.png',
title: '测试商品',
price: '111',
num: '20',
},
{
img: '../../static/logo.png',
title: '测试商品',
price: '111',
num: '20',
},
{
img: '../../static/logo.png',
title: '测试商品',
price: '111',
num: '20',
}
],
chatList: [{
name: '用户01',
text: '哈哈哈哈哈'
},
{
name: '用户01',
text: '哈哈哈哈哈'
},
{
name: '用户01',
text: '哈哈哈哈哈'
},
{
name: '用户01',
text: '哈哈哈哈哈'
},
{
name: '用户01',
text: '哈哈哈哈哈'
},
{
name: '用户01',
text: '哈哈哈哈哈'
},
{
name: '用户01',
text: '哈哈哈哈哈'
},
{
name: '用户01',
text: '哈哈哈哈哈'
}
],
beauty: 0
};
},
onLoad() {
let info = uni.getSystemInfoSync()
this.width = info.windowWidth;
this.height = info.windowHeight;
uni.$http('common.getLiveAddr').then(res => {
this.url = res.data.liveUrl
})
},
onReady() {
this.context = uni.createLivePusherContext('livePusher', this);
setTimeout(() => {
this.startLive();
}, 1000)
},
methods: {
add() {
console.log('s')
},
// 0是宝贝弹窗,1是订单弹窗,2是工具弹窗,3是设置弹窗
openMark(type) {
this.type == type
this.$refs.popup.open()
},
openmeiyan() {
// this.$refs.popup.open()
if (this.beauty == 0) {
this.beauty = 9
} else {
this.beauty = 0
}
},
returns() {
let that = this
uni.showModal({
content: "是否结束直播",
cancelText: "取消",
confirmText: "结束",
success: (res) => {
if (res.confirm) {
that.stopLive()
}
}
})
// this.stopLive();
// uni.navigateBack({
// delta: 1
// })
},
EnableCamera() {
this.enableCamera = true;
},
startLive() {
let self = this;
this.context.start({
success: a => {
self.markact = false;
console.log('livePusher.start:' + JSON.stringify(a));
}
});
},
stopLive() {
uni.$http('common.endLive').then(res => {
uni.navigateBack()
})
// this.context.stop({
// success: a => {
// console.log(JSON.stringify(a));
// }
// });
},
switchCamera() {
this.context.switchCamera({
success: (a) => {
console.log("livePusher.switchCamera:" + JSON.stringify(a));
}
});
}
}
}
</script>
<style>
.add-shop {
font-size: 16px;
color: #333333;
position: absolute;
top: 20px;
left: 20px;
z-index: 10;
}
.shop-list-but-box {
position: absolute;
bottom: 10px;
right: 20px;
display: flex;
align-items: center;
justify-content: flex-end;
flex-direction: row;
}
.shop-list-but {
color: white;
border-radius: 2px;
font-size: 16px;
background-color: #D4237A;
padding: 10px 20px 10px 20px;
}
.mark-title {
padding-top: 20px;
padding-bottom: 20px;
text-align: center;
font-size: 20px;
}
.shop-list-img {
margin-right: 10px;
width: 100px;
height: 100px;
}
.shop-list-title {
font-size: 20px;
color: #333333;
}
.shop-list-num {
font-size: 16px;
color: #C0C0C0;
padding-top: 10px;
}
.shop-list-price {
font-size: 16px;
color: #D4237A;
padding-top: 10px;
}
.scroll-Ys {
background-color: white;
height: 300px;
width: 100%;
}
.shop-list-box {
position: relative;
background-color: white;
width: 100%;
height: 380px;
}
.shop-list-list {
position: relative;
padding-top: 5px;
padding-bottom: 5px;
display: flex;
align-items: flex-start;
flex-direction: row;
}
.chat-username {
font-size: 18px;
color: white;
}
.chat-usertext {
font-size: 16px;
color: white;
}
.chat-list {
margin-top: 5px;
display: flex;
align-items: center;
justify-content: flex-start;
flex-direction: row;
background-color: rgba(0, 0, 0, .5);
padding: 5px 10px 5px 10px;
border-radius: 3px;
}
.scroll-Y {
height: 150px;
width: 250px;
}
.chat {
position: fixed;
z-index: 10;
bottom: 80px;
}
.but-img {
width: 20px;
height: 20px;
}
.meiyanbut {
padding: 10px 20px 10px 20px;
margin-left: 20px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.but-text {
padding-top: 3px;
font-size: 13px;
color: white;
}
.id {
font-size: 14px;
color: white;
}
.text-box {
font-size: 12px;
color: white;
}
.user-img {
margin-right: 5px;
width: 30px;
height: 30px;
border-radius: 50%;
}
.mark-text {
color: white;
font-size: 20px;
}
.mark {
position: fixed;
top: 0px;
background-color: #000000;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.but {
background-color: rgba(0, 0, 0, .4);
position: fixed;
bottom: 0px;
display: flex;
align-items: center;
flex-direction: row;
padding-bottom: 20px;
}
.tui {
width: 200px;
height: 200px;
}
.arrow-box {
position: fixed;
top: 60px;
left: 20px;
z-index: 10;
border-radius: 20px;
background-color: rgba(0, 0, 0, .4);
}
.arrow-boxs {
padding: 10px 20px 10px 20px;
display: flex;
align-items: center;
flex-direction: row;
position: fixed;
top: 60px;
left: 140px;
z-index: 10;
border-radius: 30px;
background-color: rgba(0, 0, 0, .4);
}
.jiesu {
padding: 10px 20px 10px 20px;
color: white;
font-size: 16px;
}
.arrow {
width: 15px;
height: 15px;
}
</style>