123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- <template>
- <view class="container" :style="'height: '+windowHeight+'px;'">
- <jhlive
- ref="jhlive" class="jhlive"
- :sdkAppID="sdkAppID" :secretKey="secretKey" :userId="userId" :roomId="roomId"
- :isAuthor="isAuthor" :linkMic="linkMic"
- :showSwitch="true"
- :avatar="avatar" :subtitle="num?'已连接':'等待用户进入'" :title="title"
- :btns="btns" @onBtnClick="onBtnClick"
- @onRemoteUser="handleRemoteUser" />
- <uni-popup ref="popup" animation type="bottom">
- <view class="popup-box">
- <view class="popup-close">
- <text class="popup-close-text" @click="$refs.popup.close()">收起</text>
- </view>
- <scroll-view scroll-y="true" class="good-box">
- <view class="goods-row" v-for="(item, index) in goodsList" :key="index">
- <view class="goods-img-box">
- <image class="goods-img" :src="item.imgPath" mode="aspectFill"></image>
- </view>
- <view class="goods-info">
- <view>
- <text class="goods-name">{{item.productName}}</text>
- </view>
- <text class="goods-sales">{{item.sellCount ? item.sellCount : 0}}人付款</text>
- <text class="price">原价:{{item.originalPrice}}</text>
- <view class="goods-number-bottom">
- <view class="goods-number">
- <!-- <text class="goods-number-left">惊爆价:</text> -->
- <text class="goods-icon">¥</text>
- <text class="goods-spec">{{item.bizPrice}}</text>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- import jhlive from "@/jhlive/jhlive";
- import permision from "@/utils/permission.js"
- const NET = require('@/utils/request')
- const API = require('@/config/api')
- export default {
- components: { jhlive },
- data() {
- return {
- windowWidth: 0,
- windowHeight: 0,
- userData: {},
- orderId: '',
- tenantCode: '',
- goodsList: [],
- liveId: '',
- isAuthor: true,
- linkMic: false,
- sdkAppID:API.sdkAppID,
- secretKey:API.secretKey,
- btns: [{picture:"../static/images/live-good.png",title:''}],
- userId: '',
- roomId: '',
- title: "暂无",
- num: 0,
- avatar: "../static/images/loginLogo.png",
- }
- },
- onLoad(options) {
- this.orderId = options.orderId
- this.userData = uni.getStorageSync("userData");
- this.userId = this.userData.userId;
- let info = uni.getSystemInfoSync();
- this.windowWidth = info.windowWidth;
- this.windowHeight = info.windowHeight;
- },
- onReady() {
- this.init();
- },
- methods: {
- init() {
- NET.request(API.creatPickVideo, {orderId: this.orderId}, 'GET').then(res => {
- this.liveId = res.data.liveId
- this.roomId = res.data.roomId;
- this.goodsList = res.data.liveProducResVO
- this.$nextTick(() => {
- permision.checkAndRequestPermissions(['scope.camera', 'scope.record']).then(()=>{
- this.enterRoom();
- }, ()=>{
- uni.showToast({
- title: '获取权限失败',
- duration: 2000,
- })
- })
- });
- }).catch(error => {
- uni.showToast({
- title: error.data.msg,
- duration: 2000
- });
- })
- },
- enterRoom() {
- this.$refs.jhlive&&this.$refs.jhlive.enterRoom();
- },
- exitRoom() {
- this.$refs.jhlive&&this.$refs.jhlive.exitRoom();
- },
- handleRemoteUser(users) {
- console.log('获取自助采摘观看人数', users)
- this.num = users.length;
- this.subtitle = users.length;
- users.length&&NET.request(API.getMainInfo +"?userId="+ users[0], {}, 'GET').then(res => {
- console.log('获取用户信息', res)
- this.avatar = res.data.headimg;
- this.title = res.data.nickname;
- }).catch(error => {
- uni.showToast({
- title: error.data.msg,
- duration: 2000
- });
- })
- },
- onBtnClick(index, item) {
- if(index === 0) {
- this.$refs.popup.open()
- }
- },
- }
- }
- </script>
- <style lang="less" scoped>
- .container {
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: stretch;
- width: 750rpx;
- }
- .jhlive {
- width: 750rpx;
- flex: 1;
- }
- .popup-open {
- width: 50px;
- height: 50px;
- position: fixed;
- bottom: 15px;
- right: 15px;
- background-color: #52A63A;
- border-radius: 50%;
- text-align: center;
- line-height: 50px;
- }
- .iconzhibo-shangpin {
- color: #FFFFFF;
- font-size: 34px;
- text-align: center;
- line-height: 50px;
- }
- .popup-box {
- background-color: #FFFFFF;
- width: 750rpx;
- height: 750rpx;
- border-top-left-radius: 10px;
- border-top-right-radius: 10px;
- }
- .popup-close {
- padding: 10px;
- line-height: 16px;
- }
- .popup-close-text {
- color: #52A63A;
- font-size: 15px;
- font-family: PingFang SC;
- text-align: left;
- }
- .good-box {
- width: 750rpx;
- height: 750rpx;
- padding: 0 0 10px 0;
- overflow: visible;
- }
- .goods-row:first-child {
- margin-top: 12px;
- }
- .goods-row {
- width: 700rpx;
- height: 104px;
- display: flex;
- flex-direction: row;
- flex-wrap: nowrap;
- background-color: #FFFFFF;
- box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.1);
- border-radius: 5px;
- margin: 0 15px 10px 15px;
- }
- .goods-img-box {
- margin-right: 15px;
- }
- .goods-img {
- width: 104px;
- height: 104px;
- object-fit: cover;
- }
- .goods-info {
- flex: 1;
- padding-top: 10px;
- }
- .goods-name {
- line-height: 15px;
- overflow: hidden;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- word-wrap: break-word;
- text-overflow: ellipsis;
- font-size: 15px;
- font-family: PingFang SC;
- color: #333333;
- }
- .goods-sales {
- font-size: 12px;
- font-family: PingFang SC;
- color: #666666;
- line-height: 15px;
- margin: 8px 0 8px 0;
- }
- .price {
- font-size: 12px;
- text-decoration: line-through;
- color: #A67954;
- }
- .goods-number-bottom {
- display: flex;
- flex-direction: row;
- }
- .goods-number {
- display: flex;
- flex-direction: row;
- white-space: nowrap;
- line-height: 24px;
- }
- .goods-number-left {
- font-size: 12px;
- color: #666666;
- }
- .goods-icon {
- font-size: 14px;
- font-family: PingFang SC;
- color: #52A63A;
- }
- .goods-spec {
- font-size: 24px;
- font-family: PingFang SC;
- color: #52A63A;
- }
- </style>
|