|
@@ -303,16 +303,17 @@
|
|
<u-popup :show="shopping" @close="closeshop" @open="open" round='20rpx' bgColor='#f3f5f9'>
|
|
<u-popup :show="shopping" @close="closeshop" @open="open" round='20rpx' bgColor='#f3f5f9'>
|
|
<view class="shoppop">
|
|
<view class="shoppop">
|
|
<view class="shoppop-top">
|
|
<view class="shoppop-top">
|
|
- <u-avatar :src="livedata.liveImgUrl" size="36" class="ml16"></u-avatar>
|
|
|
|
|
|
+ <u-avatar :src="store.logoUrl" size="36" class="ml16"></u-avatar>
|
|
<view class="search-input u-flex-y-center">
|
|
<view class="search-input u-flex-y-center">
|
|
<image style="width: 24rpx;height: 24rpx;margin-right: 16rpx;" src="@/static/images/search.png">
|
|
<image style="width: 24rpx;height: 24rpx;margin-right: 16rpx;" src="@/static/images/search.png">
|
|
</image>
|
|
</image>
|
|
<input placeholder="搜索商品或序号" />
|
|
<input placeholder="搜索商品或序号" />
|
|
</view>
|
|
</view>
|
|
- <view class="t-c search-top" style="margin-right: 48rpx;" @click="onCollect">
|
|
|
|
- <image v-if="isCollect" style="width: 32rpx;height: 32rpx;"
|
|
|
|
|
|
+ <view class="t-c search-top" style="margin-right: 48rpx;" @click="onStoreCollect">
|
|
|
|
+ <image v-if="store.isFavorite" style="width: 32rpx;height: 32rpx;"
|
|
src="@/static/images/collect_select.png"></image>
|
|
src="@/static/images/collect_select.png"></image>
|
|
- <image v-else style="width: 32rpx;height: 32rpx;" src="@/static/images/collect.png"></image>
|
|
|
|
|
|
+ <image v-else @click="onStoreCollect" style="width: 32rpx;height: 32rpx;"
|
|
|
|
+ src="@/static/images/collect.png"></image>
|
|
<view>收藏</view>
|
|
<view>收藏</view>
|
|
</view>
|
|
</view>
|
|
<view class="t-c search-top" @click="goOrderList">
|
|
<view class="t-c search-top" @click="goOrderList">
|
|
@@ -329,22 +330,22 @@
|
|
</view>
|
|
</view>
|
|
<view class="goods-right">
|
|
<view class="goods-right">
|
|
<view class="goods-title">{{item.productName}}</view>
|
|
<view class="goods-title">{{item.productName}}</view>
|
|
- <view class="goods-details">{{item.productIntroduce}}</view>
|
|
|
|
|
|
+ <!-- <view class="goods-details">{{item.productIntroduce}}</view> -->
|
|
<view class="goods-people">{{item.sales}} 人已购</view>
|
|
<view class="goods-people">{{item.sales}} 人已购</view>
|
|
<view class="goods-shop">
|
|
<view class="goods-shop">
|
|
<text class="nummber"><text style="font-size: 20rpx;font-weight: 600;">¥</text><text
|
|
<text class="nummber"><text style="font-size: 20rpx;font-weight: 600;">¥</text><text
|
|
style="font-size: 36rpx;font-weight: bold;">{{Math.trunc(item.price)}}</text>.{{getPureDecimal(item.price)?getPureDecimal(item.price):'00'}}/日</text>
|
|
style="font-size: 36rpx;font-weight: bold;">{{Math.trunc(item.price)}}</text>.{{getPureDecimal(item.price)?getPureDecimal(item.price):'00'}}/日</text>
|
|
<view class="btn-group u-flex-y-center">
|
|
<view class="btn-group u-flex-y-center">
|
|
<view class="collect-btn">
|
|
<view class="collect-btn">
|
|
- <image v-if="isCollect" @click="onCollect(item)"
|
|
|
|
|
|
+ <image v-if="item.isFavorite" @click="onGoodsCollect(item)"
|
|
style="width: 32rpx;height: 32rpx;" src="/static/images/collect_select.png">
|
|
style="width: 32rpx;height: 32rpx;" src="/static/images/collect_select.png">
|
|
</image>
|
|
</image>
|
|
- <image v-else @click="onCollect(item)" style="width: 32rpx;height: 32rpx;"
|
|
|
|
|
|
+ <image v-else @click="onGoodsCollect(item)" style="width: 32rpx;height: 32rpx;"
|
|
src="/static/images/collect.png">
|
|
src="/static/images/collect.png">
|
|
</image>
|
|
</image>
|
|
</view>
|
|
</view>
|
|
<view v-if="item.status==1" class="shop-btn"
|
|
<view v-if="item.status==1" class="shop-btn"
|
|
- @click="goShop(item.productId,item.goodsId,item.storeId)">去购买
|
|
|
|
|
|
+ @click="goShop(item.productId,item.goodsId)">去购买
|
|
</view>
|
|
</view>
|
|
<view v-else-if="item.status==0" @click="goShop(item.productId)" class="shop-btn">
|
|
<view v-else-if="item.status==0" @click="goShop(item.productId)" class="shop-btn">
|
|
已下架</view>
|
|
已下架</view>
|
|
@@ -363,7 +364,9 @@
|
|
import CryptoJS from 'crypto-js'
|
|
import CryptoJS from 'crypto-js'
|
|
import {
|
|
import {
|
|
liveDataLike, // 点赞
|
|
liveDataLike, // 点赞
|
|
- collectStore, // 收藏/取消收藏
|
|
|
|
|
|
+ collectStore, // 店铺收藏/取消收藏
|
|
|
|
+ collectGoods, // 商品收藏/取消收藏
|
|
|
|
+ store, // 查询店铺
|
|
follow, // 关注/取消关注
|
|
follow, // 关注/取消关注
|
|
getRecentLiveViewers, //获取直播间用户(展示在线用户)
|
|
getRecentLiveViewers, //获取直播间用户(展示在线用户)
|
|
// 小黄车
|
|
// 小黄车
|
|
@@ -403,6 +406,7 @@
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ storeId: null,
|
|
reconnectCount: 0,
|
|
reconnectCount: 0,
|
|
maxReconnectAttempts: 3,
|
|
maxReconnectAttempts: 3,
|
|
reconnectTimer: null,
|
|
reconnectTimer: null,
|
|
@@ -507,7 +511,6 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
-
|
|
|
|
// this.onLike()
|
|
// this.onLike()
|
|
this.getliveViewData() ////直播间点赞、关注、在线人数数据
|
|
this.getliveViewData() ////直播间点赞、关注、在线人数数据
|
|
this.intervalId = setInterval(() => {
|
|
this.intervalId = setInterval(() => {
|
|
@@ -515,7 +518,7 @@
|
|
}, 60 * 1000);
|
|
}, 60 * 1000);
|
|
// this.getLiveinformation() // 获取直播间信息接口
|
|
// this.getLiveinformation() // 获取直播间信息接口
|
|
this.getliveOrder() //正在购买
|
|
this.getliveOrder() //正在购买
|
|
- this.getliveStore() // 获取小黄车 店铺展示
|
|
|
|
|
|
+ // this.getliveStore() // 获取小黄车 店铺展示
|
|
// this.getliveGoods() // 获取小黄车 商品详情
|
|
// this.getliveGoods() // 获取小黄车 商品详情
|
|
this.getliveUser() // 获取直播间用户
|
|
this.getliveUser() // 获取直播间用户
|
|
this.initTime()
|
|
this.initTime()
|
|
@@ -537,7 +540,7 @@
|
|
this.gettalklist()
|
|
this.gettalklist()
|
|
// this.getAnswerlists()
|
|
// this.getAnswerlists()
|
|
this.userinfo = JSON.parse(uni.getStorageSync("userInfo"))
|
|
this.userinfo = JSON.parse(uni.getStorageSync("userInfo"))
|
|
-
|
|
|
|
|
|
+
|
|
},
|
|
},
|
|
onReady: function(res) {
|
|
onReady: function(res) {
|
|
this.videoContext = uni.createVideoContext('myVideo')
|
|
this.videoContext = uni.createVideoContext('myVideo')
|
|
@@ -551,6 +554,7 @@
|
|
if (this.pingpangTimes) {
|
|
if (this.pingpangTimes) {
|
|
clearInterval(this.pingpangTimes); // 清除心跳定时器
|
|
clearInterval(this.pingpangTimes); // 清除心跳定时器
|
|
}
|
|
}
|
|
|
|
+ uni.$off('refreshOrder'); // 移除全局事件监听
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
// 监听orderUser.count的变化
|
|
// 监听orderUser.count的变化
|
|
@@ -584,9 +588,9 @@
|
|
return str.length > maxLength ? str.slice(0, maxLength) + '...' : str;
|
|
return str.length > maxLength ? str.slice(0, maxLength) + '...' : str;
|
|
},
|
|
},
|
|
goStore() {
|
|
goStore() {
|
|
- console.log("带过去storeId", this.products[0].storeId)
|
|
|
|
|
|
+ console.log("带过去storeId", this.storeId)
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
- url: '/pages_shop/store?liveId=' + this.liveId + "&storeId=" + this.products[0].storeId
|
|
|
|
|
|
+ url: '/pages_shop/store?liveId=' + this.liveId + "&storeId=" + this.storeId
|
|
})
|
|
})
|
|
},
|
|
},
|
|
// 去订单列表
|
|
// 去订单列表
|
|
@@ -623,6 +627,7 @@
|
|
},
|
|
},
|
|
|
|
|
|
getliving() {
|
|
getliving() {
|
|
|
|
+ if (!this.liveId) return;
|
|
console.log("获取直播信息");
|
|
console.log("获取直播信息");
|
|
const param = {
|
|
const param = {
|
|
id: this.liveId
|
|
id: this.liveId
|
|
@@ -640,6 +645,8 @@
|
|
|
|
|
|
this.livedata = res.data;
|
|
this.livedata = res.data;
|
|
this.showType = res.data.showType;
|
|
this.showType = res.data.showType;
|
|
|
|
+ this.storeId = res.storeId
|
|
|
|
+ this.queryCollect()//查询店铺
|
|
console.log("横屏1或竖屏2", this.showType)
|
|
console.log("横屏1或竖屏2", this.showType)
|
|
// 1. 根据直播类型设置播放地址
|
|
// 1. 根据直播类型设置播放地址
|
|
if (res.data.liveType === 2) {
|
|
if (res.data.liveType === 2) {
|
|
@@ -723,13 +730,12 @@
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
|
|
//直播间点赞、关注、在线人数数据
|
|
//直播间点赞、关注、在线人数数据
|
|
getliveViewData() {
|
|
getliveViewData() {
|
|
if (!this.liveId) return;
|
|
if (!this.liveId) return;
|
|
-
|
|
|
|
getLiveViewData(this.liveId).then(res => {
|
|
getLiveViewData(this.liveId).then(res => {
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
// console.log("直播间点赞、关注、在线人数数据>>>>", res)
|
|
// console.log("直播间点赞、关注、在线人数数据>>>>", res)
|
|
@@ -763,32 +769,34 @@
|
|
);
|
|
);
|
|
},
|
|
},
|
|
//小黄车 店铺展示
|
|
//小黄车 店铺展示
|
|
- getliveStore() {
|
|
|
|
- let data = {
|
|
|
|
- pageSize: 10,
|
|
|
|
- page: 1
|
|
|
|
- }
|
|
|
|
- liveStore(this.liveId, data).then(res => {
|
|
|
|
- if (res.code == 200) {
|
|
|
|
- console.log("小黄车 店铺展示>>>>", res)
|
|
|
|
- this.products = res.data
|
|
|
|
- } else {
|
|
|
|
- uni.showToast({
|
|
|
|
- title: res.msg,
|
|
|
|
- icon: 'none'
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- rej => {}
|
|
|
|
- );
|
|
|
|
- },
|
|
|
|
|
|
+ // getliveStore() {
|
|
|
|
+ // if (!this.liveId) return;
|
|
|
|
+ // let data = {
|
|
|
|
+ // pageSize: 10,
|
|
|
|
+ // page: 1
|
|
|
|
+ // }
|
|
|
|
+ // liveStore(this.liveId, data).then(res => {
|
|
|
|
+ // if (res.code == 200) {
|
|
|
|
+ // console.log("小黄车 店铺展示>>>>", res)
|
|
|
|
+ // this.products = res.data
|
|
|
|
+ // this.queryCollect()
|
|
|
|
+ // } else {
|
|
|
|
+ // uni.showToast({
|
|
|
|
+ // title: res.msg,
|
|
|
|
+ // icon: 'none'
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+ // },
|
|
|
|
+ // rej => {}
|
|
|
|
+ // );
|
|
|
|
+ // },
|
|
// 获取直播间信息接口
|
|
// 获取直播间信息接口
|
|
getLiveinformation() {
|
|
getLiveinformation() {
|
|
|
|
+ if (!this.liveId) return;
|
|
getLiveInfo(this.liveId).then(res => {
|
|
getLiveInfo(this.liveId).then(res => {
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
console.log("获取直播间信息接口>>>>", res)
|
|
console.log("获取直播间信息接口>>>>", res)
|
|
this.livingUrl = res.livingUrl
|
|
this.livingUrl = res.livingUrl
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title: res.msg,
|
|
title: res.msg,
|
|
@@ -802,6 +810,7 @@
|
|
|
|
|
|
// 获取直播间用户
|
|
// 获取直播间用户
|
|
getliveUser() {
|
|
getliveUser() {
|
|
|
|
+ if (!this.liveId) return;
|
|
getRecentLiveViewers(this.liveId).then(res => {
|
|
getRecentLiveViewers(this.liveId).then(res => {
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
console.log("获取直播间用户>>>>", res)
|
|
console.log("获取直播间用户>>>>", res)
|
|
@@ -819,6 +828,7 @@
|
|
|
|
|
|
// 点赞
|
|
// 点赞
|
|
onLike() {
|
|
onLike() {
|
|
|
|
+ if (!this.liveId) return;
|
|
liveDataLike(this.liveId).then(res => {
|
|
liveDataLike(this.liveId).then(res => {
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
if (res.like) {
|
|
if (res.like) {
|
|
@@ -842,33 +852,63 @@
|
|
|
|
|
|
},
|
|
},
|
|
// 去购买,跳商品详情
|
|
// 去购买,跳商品详情
|
|
- goShop(productId, goodsId, storeId) {
|
|
|
|
|
|
+ goShop(productId, goodsId) {
|
|
uni.navigateTo({
|
|
uni.navigateTo({
|
|
url: '/pages_shop/goods?productId=' + productId + '&liveId=' + this.liveId + '&goodsId=' +
|
|
url: '/pages_shop/goods?productId=' + productId + '&liveId=' + this.liveId + '&goodsId=' +
|
|
- goodsId + '&storeId=' + storeId
|
|
|
|
|
|
+ goodsId + '&storeId=' + this.storeId
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- // 收藏
|
|
|
|
- onCollect(item) {
|
|
|
|
- let storeId
|
|
|
|
- if (item) {
|
|
|
|
- storeId = this.products[0].storeId
|
|
|
|
- } else {
|
|
|
|
- storeId = item.storeId
|
|
|
|
- }
|
|
|
|
- let data = {
|
|
|
|
- liveId: this.liveId,
|
|
|
|
- productId: item.productId || '',
|
|
|
|
- storeId: storeId
|
|
|
|
|
|
+ // 查询店铺
|
|
|
|
+ queryCollect() {
|
|
|
|
+ if (!this.storeId) return;
|
|
|
|
+ store(this.storeId).then(res => {
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ console.log("查询店铺>>", res)
|
|
|
|
+ this.products = res.data.goodsList
|
|
|
|
+ this.store=res.data
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.msg,
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ rej => {}
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ // 店铺收藏
|
|
|
|
+ onStoreCollect() {
|
|
|
|
+ if (!this.storeId) return;
|
|
|
|
+ collectStore(this.products[0].storeId).then(res => {
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.msg,
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ this.store.isFavorite = !this.store.isFavorite
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.msg,
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ rej => {}
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ // 商品收藏
|
|
|
|
+ onGoodsCollect(item) {
|
|
|
|
+ if (!item || item.length === 0 || !item.goodsId) {
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- collectStore(data).then(res => {
|
|
|
|
|
|
+ collectGoods(item.goodsId).then(res => {
|
|
if (res.code == 200) {
|
|
if (res.code == 200) {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title: res.msg,
|
|
title: res.msg,
|
|
icon: 'none'
|
|
icon: 'none'
|
|
});
|
|
});
|
|
- // this.isCollect=this.isCollect
|
|
|
|
|
|
+ item.isFavorite = !item.isFavorite
|
|
} else {
|
|
} else {
|
|
uni.showToast({
|
|
uni.showToast({
|
|
title: res.msg,
|
|
title: res.msg,
|
|
@@ -881,6 +921,7 @@
|
|
},
|
|
},
|
|
// 关注
|
|
// 关注
|
|
onFollow() {
|
|
onFollow() {
|
|
|
|
+ if (!this.liveId) return;
|
|
follow(this.liveId).then(res => {
|
|
follow(this.liveId).then(res => {
|
|
this.isFollow = !this.isFollow
|
|
this.isFollow = !this.isFollow
|
|
uni.showToast({
|
|
uni.showToast({
|
|
@@ -891,6 +932,7 @@
|
|
rej => {}
|
|
rej => {}
|
|
);
|
|
);
|
|
},
|
|
},
|
|
|
|
+ // 时间戳
|
|
initTime() {
|
|
initTime() {
|
|
const now = new Date();
|
|
const now = new Date();
|
|
this.timestamp = now.getTime(); // 例如:'2023-04-01 12:00:00'
|
|
this.timestamp = now.getTime(); // 例如:'2023-04-01 12:00:00'
|
|
@@ -1008,6 +1050,7 @@
|
|
// },
|
|
// },
|
|
getAnswerlists() {
|
|
getAnswerlists() {
|
|
console.log(123)
|
|
console.log(123)
|
|
|
|
+ if (!this.liveId) return;
|
|
const data = {
|
|
const data = {
|
|
liveId: this.liveId
|
|
liveId: this.liveId
|
|
}
|
|
}
|
|
@@ -1029,6 +1072,7 @@
|
|
})
|
|
})
|
|
},
|
|
},
|
|
gettalklist() {
|
|
gettalklist() {
|
|
|
|
+ if (!this.liveId) return;
|
|
const param = {
|
|
const param = {
|
|
id: this.liveId
|
|
id: this.liveId
|
|
}
|
|
}
|
|
@@ -1161,25 +1205,29 @@
|
|
}, 30000);
|
|
}, 30000);
|
|
},
|
|
},
|
|
initSocket() {
|
|
initSocket() {
|
|
- if (!this.liveId) {
|
|
|
|
- console.warn('liveId为空,不尝试WebSocket连接');
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (this.reconnectCount >= this.maxReconnectAttempts) {
|
|
|
|
- console.log('已达到最大重连次数,不再尝试连接');
|
|
|
|
- uni.showToast({
|
|
|
|
- title: '连接失败,请刷新页面重试',
|
|
|
|
- icon: 'none'
|
|
|
|
- });
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.userinfo = JSON.parse(uni.getStorageSync("userInfo") || '{}');
|
|
|
|
- if (!this.userinfo.userId) {
|
|
|
|
- console.warn('用户信息不存在,不尝试WebSocket连接');
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
-// 先清除之前的连接和心跳
|
|
|
|
|
|
+ if (isSocketOpen) {
|
|
|
|
+ console.log('WebSocket 已连接,无需重复初始化');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (!this.liveId) {
|
|
|
|
+ console.warn('liveId为空,不尝试WebSocket连接');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (this.reconnectCount >= this.maxReconnectAttempts) {
|
|
|
|
+ console.log('已达到最大重连次数,不再尝试连接');
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: '连接失败,请刷新页面重试',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ });
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.userinfo = JSON.parse(uni.getStorageSync("userInfo") || '{}');
|
|
|
|
+ if (!this.userinfo.userId) {
|
|
|
|
+ console.warn('用户信息不存在,不尝试WebSocket连接');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 先清除之前的连接和心跳
|
|
this.closeWebSocket();
|
|
this.closeWebSocket();
|
|
|
|
|
|
let signature = CryptoJS.HmacSHA256(
|
|
let signature = CryptoJS.HmacSHA256(
|
|
@@ -1188,7 +1236,7 @@
|
|
CryptoJS.enc.Utf8.parse(this.timestamp)).toString(CryptoJS.enc.Hex);
|
|
CryptoJS.enc.Utf8.parse(this.timestamp)).toString(CryptoJS.enc.Hex);
|
|
|
|
|
|
const that = this;
|
|
const that = this;
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
// 创建一个新的socket连接
|
|
// 创建一个新的socket连接
|
|
socket = uni.connectSocket({
|
|
socket = uni.connectSocket({
|