|
|
@@ -143,7 +143,7 @@
|
|
|
|
|
|
<view class="chat-content-wrapper" :class="{ 'chat-content-focused': isFocus }">
|
|
|
<!-- 公告 -->
|
|
|
- <view class="notice-message" v-if="!isFocus&&isShowNotice">
|
|
|
+ <view class="notice-message" v-if="!isFocus&&isShowNotice" :class="liveItem.showType == 1 ? 'horizontal-notice' : ''">
|
|
|
公告消息: {{notice.msg}}
|
|
|
</view>
|
|
|
<scroll-view id="msgScroll" v-if="Array.isArray(talklist)" enable-flex scroll-y="true"
|
|
|
@@ -261,16 +261,7 @@
|
|
|
</view> -->
|
|
|
<view class="bold fs36 ml20">授权你的昵称信息</view>
|
|
|
<view class="mtb20 justify-between align-center plr20">
|
|
|
- <!-- <view class="justify-start align-center">
|
|
|
- <view class="boxweixin" :class="userData.nickname==''?'boxnosel':'boxsel'">
|
|
|
- <view v-if="userData.nickname">√</view>
|
|
|
- </view>
|
|
|
- <view class="ml20">
|
|
|
- <view class="base-color-3 bold">第一步</view>
|
|
|
- <view class="fs32 base-color-9">请点击授权微信昵称</view>
|
|
|
- </view>
|
|
|
- </view> -->
|
|
|
- <view class="button-container">
|
|
|
+ <view class="button-container">
|
|
|
<input type="nickname" class="hidden-input" @blur="onNickNameInput" placeholder="请点击授权微信昵称"
|
|
|
@input="onNickNameInput" />
|
|
|
<!-- <button class="custom-button"
|
|
|
@@ -433,7 +424,7 @@
|
|
|
<u-popup :show="isShowPopMsg" round="20rpx" mode="center" zIndex="10076">
|
|
|
<view class="message-popup">
|
|
|
<image class="message-close-icon"
|
|
|
- src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/del2.png" />
|
|
|
+ src="https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/del2.png" @click="isShowPopMsg = false" />
|
|
|
<view class="message-title">消息通知</view>
|
|
|
<view class="message-content">{{popMsg}}</view>
|
|
|
<view class="message-confirm-button" @click="isShowPopMsg = false">确认</view>
|
|
|
@@ -849,7 +840,7 @@
|
|
|
timestamp: '',
|
|
|
showadd: false,
|
|
|
liveId: null,
|
|
|
- userinfo: {}, //用户信息
|
|
|
+ userInfo: {}, //用户信息
|
|
|
userData: {},
|
|
|
diffTotalTime: '',
|
|
|
address: ''
|
|
|
@@ -872,14 +863,15 @@
|
|
|
this.liveId = params.a;
|
|
|
});
|
|
|
if (params.b && params.c) {
|
|
|
+ console.log("扫码参数",params)
|
|
|
this.qrFrom = `&companyId=${params.b}&companyUserId=${params.c}`;
|
|
|
}
|
|
|
}
|
|
|
if (options.companyId && options.companyUserId) {
|
|
|
this.qrFrom = `&companyId=${options.companyId}&companyUserId=${options.companyUserId}`;
|
|
|
}
|
|
|
- this.userinfo = uni.getStorageSync('userInfo');
|
|
|
- this.userData = uni.getStorageSync('userData');
|
|
|
+ this.userinfo = uni.getStorageSync('userinfo');
|
|
|
+ // this.userData = uni.getStorageSync('userData');
|
|
|
console.log('全部参数', options);
|
|
|
try {
|
|
|
const isLogin = await this.utils.checkLiveToken();
|
|
|
@@ -1013,7 +1005,7 @@
|
|
|
// 恢复播放和连接
|
|
|
await this.resumePageActivity();
|
|
|
// this.userinfo = JSON.parse(uni.getStorageSync('userInfo'));
|
|
|
- this.userinfo = uni.getStorageSync('userInfo');
|
|
|
+ this.userinfo = uni.getStorageSync('userinfo');
|
|
|
this.isAgreement = uni.getStorageSync('isAgreement');
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
@@ -1041,7 +1033,7 @@
|
|
|
onShareAppMessage() {
|
|
|
return {
|
|
|
title: '邀请你来观看直播:' + this.liveItem.liveName,
|
|
|
- path: '/pages_course/living?companyId=-2&companyUserId=' + this.userData.userId + '&liveId=' + this.liveId,
|
|
|
+ path: '/pages_course/living?companyId=-2&companyUserId=' + this.userInfo.userId + '&liveId=' + this.liveId,
|
|
|
imageUrl: '/static/logo.png',
|
|
|
success(res) {
|
|
|
console.log('分享成功', res);
|
|
|
@@ -1054,7 +1046,7 @@
|
|
|
onShareTimeline() {
|
|
|
return {
|
|
|
title: '邀请你来观看直播:' + this.liveItem.liveName,
|
|
|
- query: 'companyId=-2&companyUserId=' + this.userData.userId + '&liveId=' + this.liveId
|
|
|
+ query: 'companyId=-2&companyUserId=' + this.userInfo.userId + '&liveId=' + this.liveId
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
@@ -1076,39 +1068,54 @@
|
|
|
return safeLiveViewers.slice(0, 3);
|
|
|
},
|
|
|
isCurrentUserWon() {
|
|
|
- if (!Array.isArray(this.prizeInfo) || !this.userData?.userId) {
|
|
|
+ if (!Array.isArray(this.prizeInfo) || !this.userInfo?.userId) {
|
|
|
return false;
|
|
|
}
|
|
|
return this.prizeInfo.some((item) => {
|
|
|
- return String(item.userId) === String(this.userData.userId);
|
|
|
+ return String(item.userId) === String(this.userInfo.userId);
|
|
|
});
|
|
|
},
|
|
|
getCurrentUserPrizeProductId() {
|
|
|
- if (!Array.isArray(this.prizeInfo) || !this.userData?.userId) {
|
|
|
+ if (!Array.isArray(this.prizeInfo) || !this.userInfo?.userId) {
|
|
|
return null;
|
|
|
}
|
|
|
// 在 prizeInfo 中查找当前用户的中奖记录
|
|
|
const userPrize = this.prizeInfo.find(item => {
|
|
|
- return String(item.userId) == String(this.userData.userId);
|
|
|
+ return String(item.userId) == String(this.userInfo.userId);
|
|
|
});
|
|
|
|
|
|
// 返回商品ID,如果没有找到则返回null
|
|
|
return userPrize ? userPrize.productId : null;
|
|
|
},
|
|
|
getCurrentUserPrizeRecordId() {
|
|
|
- if (!Array.isArray(this.prizeInfo) || !this.userData?.userId) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- // 在 prizeInfo 中查找当前用户的中奖记录
|
|
|
- const userPrize = this.prizeInfo.find(item => {
|
|
|
- return String(item.userId) == String(this.userData.userId);
|
|
|
- });
|
|
|
-
|
|
|
- // 返回商品ID,如果没有找到则返回null
|
|
|
- return userPrize ? userPrize.recordId : null;
|
|
|
+ console.log('=== getCurrentUserPrizeRecordId 调试信息 ===');
|
|
|
+ console.log('this.prizeInfo:', this.prizeInfo);
|
|
|
+ console.log('this.userInfo:', this.userInfo);
|
|
|
+ console.log('this.userInfo.userId:', this.userInfo?.userId);
|
|
|
+
|
|
|
+ if (!Array.isArray(this.prizeInfo) || !this.userInfo?.userId) {
|
|
|
+ console.log('条件不满足,返回null');
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ const userPrize = this.prizeInfo.find(item => {
|
|
|
+ const match = String(item.userId) == String(this.userInfo.userId);
|
|
|
+ console.log('查找匹配:', {
|
|
|
+ itemUserId: item.userId,
|
|
|
+ currentUserId: this.userInfo.userId,
|
|
|
+ match: match,
|
|
|
+ itemRecordId: item.recordId
|
|
|
+ });
|
|
|
+ return match;
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log('找到的用户奖品:', userPrize);
|
|
|
+ console.log('最终返回的recordId:', userPrize ? userPrize.recordId : null);
|
|
|
+
|
|
|
+ return userPrize ? userPrize.recordId : null;
|
|
|
},
|
|
|
nameuser() {
|
|
|
- return this.userData.nickname
|
|
|
+ return this.userInfo.nickname
|
|
|
},
|
|
|
|
|
|
},
|
|
|
@@ -1215,7 +1222,7 @@
|
|
|
},
|
|
|
methods: {
|
|
|
shouquan() {
|
|
|
- if (this.userData.nickname == '') {
|
|
|
+ if (this.userinfo.nickname == '') {
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
title: "请先授权微信昵称",
|
|
|
@@ -1223,7 +1230,7 @@
|
|
|
}
|
|
|
},
|
|
|
confimrname() {
|
|
|
- if (this.userData.nickname == '') {
|
|
|
+ if (this.userInfo.nickname == '') {
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
title: "请授权微信昵称",
|
|
|
@@ -1231,36 +1238,18 @@
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- uni.setStorageSync('userData', this.userData)
|
|
|
+ uni.setStorageSync('userInfo', this.userInfo)
|
|
|
// this.editUserA()
|
|
|
this.userlogo = false
|
|
|
},
|
|
|
- // 授权头像
|
|
|
- // onChooseAvatar(e) {
|
|
|
- // this.userData.avatar = e.detail.avatarUrl
|
|
|
- // uni.uploadFile({
|
|
|
- // url: uni.getStorageSync('requestPath') + '/app/common/uploadOSS', //仅为示例,非真实的接口地址
|
|
|
- // filePath: e.detail.avatarUrl,
|
|
|
- // name: 'file',
|
|
|
- // formData: {
|
|
|
- // 'user': 'test' // 上传附带参数
|
|
|
- // },
|
|
|
- // success: (uploadFileRes) => {
|
|
|
- // console.log(uploadFileRes)
|
|
|
- // // 根据接口具体返回格式 赋值具体对应url
|
|
|
- // var data = JSON.parse(uploadFileRes.data)
|
|
|
- // this.headImg = uni.getStorageSync('requestPath') + data.fileName
|
|
|
- // this.userData.avatar = data.url
|
|
|
- // }
|
|
|
- // });
|
|
|
- // },
|
|
|
+
|
|
|
onNickNameInput(e) {
|
|
|
console.log(e)
|
|
|
- this.userData.nickname = e.detail.value
|
|
|
+ this.userInfo.nickname = e.detail.value
|
|
|
},
|
|
|
async haveLogin() {
|
|
|
- this.userinfo = uni.getStorageSync('userInfo');
|
|
|
- this.userData = uni.getStorageSync('userData');
|
|
|
+ this.userInfo = uni.getStorageSync('userInfo');
|
|
|
+ // this.userData = uni.getStorageSync('userData');
|
|
|
await this.getUserInfo();
|
|
|
// this.initTime();
|
|
|
if (this.liveId) {
|
|
|
@@ -1311,7 +1300,7 @@
|
|
|
uni.setStorageSync('AppToken', res.token);
|
|
|
uni.setStorageSync('userInfo', JSON.stringify(res
|
|
|
.user));
|
|
|
- this.userinfo = uni.getStorageSync('userInfo');
|
|
|
+ this.userInfo = uni.getStorageSync('userInfo');
|
|
|
// uni.setStorageSync('auto_userInfo', JSON.stringify(res.user));
|
|
|
// this.user = res.user
|
|
|
this.$store.commit('setCoureLogin', 1);
|
|
|
@@ -1985,7 +1974,7 @@
|
|
|
if (!this.liveId) return;
|
|
|
const currentTime = (this.stayTime / this.liveItem.duration) * 100;
|
|
|
const param = {
|
|
|
- userId: this.userData.userId || '',
|
|
|
+ userId: this.userInfo.userId || '',
|
|
|
liveId: this.liveId || '',
|
|
|
uuId: dayjs().format('YYYYMMDD') + this.uuId,
|
|
|
internetTraffic: this.totalTraffic
|
|
|
@@ -1994,12 +1983,12 @@
|
|
|
},
|
|
|
// 回放、预告缓冲
|
|
|
getInternetTraffic() {
|
|
|
- if (!this.liveId || !this.liveId || !this.userData.userId || !this.uuId) return;
|
|
|
+ if (!this.liveId || !this.liveId || !this.userInfo.userId || !this.uuId) return;
|
|
|
const currentTime = (this.stayTime / this.liveItem.duration) * 100;
|
|
|
const param = {
|
|
|
videoType: this.liveItem.videoType,
|
|
|
videoId: this.liveItem.videoId,
|
|
|
- userId: this.userData.userId,
|
|
|
+ userId: this.userInfo.userId,
|
|
|
liveId: this.liveId,
|
|
|
uuId: dayjs().format('YYYYMMDD') + this.uuId,
|
|
|
duration: this.liveItem.duration,
|
|
|
@@ -2157,7 +2146,7 @@
|
|
|
await getUserInfo().then(
|
|
|
(res) => {
|
|
|
if (res.code == 200) {
|
|
|
- this.userData = res.user;
|
|
|
+ this.userInfo = res.user;
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
icon: 'none',
|
|
|
@@ -2203,11 +2192,12 @@
|
|
|
});
|
|
|
},
|
|
|
async callSendMessageApi() {
|
|
|
- if (!this.userData.userId) return;
|
|
|
+ if (!this.userInfo.userId) return;
|
|
|
const templateData = {
|
|
|
liveId: this.liveId,
|
|
|
- userId: this.userData.userId,
|
|
|
+ userId: this.userInfo.userId,
|
|
|
templateId: this.templateId, // 模板ID
|
|
|
+ maOpenId:this.userInfo.maOpenId,
|
|
|
data: {
|
|
|
thing6: this.liveItem.liveName,
|
|
|
date7: this.liveItem.startTime
|
|
|
@@ -2241,7 +2231,7 @@
|
|
|
const heartBeatMsg = JSON.stringify({
|
|
|
cmd: 'heartbeat',
|
|
|
msg: 'ping',
|
|
|
- userId: this.userData.userId || '',
|
|
|
+ userId: this.userInfo.userId || '',
|
|
|
liveId: this.liveId,
|
|
|
timestamp: this.lastHeartBeatTime,
|
|
|
networkType: this.networkType
|
|
|
@@ -2667,7 +2657,7 @@
|
|
|
}
|
|
|
let data = {
|
|
|
liveId: this.liveId,
|
|
|
- userId: this.userData.userId,
|
|
|
+ userId: this.userInfo.userId,
|
|
|
redId: this.redInfo.redId
|
|
|
};
|
|
|
liveRed(data).then((res) => {
|
|
|
@@ -3525,7 +3515,7 @@
|
|
|
console.error('缺失直播间ID,无法初始化WebSocket');
|
|
|
return;
|
|
|
}
|
|
|
- if (!this.userData || !this.userData.userId) {
|
|
|
+ if (!this.userInfo || !this.userInfo.userId) {
|
|
|
console.error('用户信息缺失,无法初始化WebSocket');
|
|
|
return;
|
|
|
}
|
|
|
@@ -3542,12 +3532,12 @@
|
|
|
|
|
|
setTimeout(() => {
|
|
|
this.getliveUser(false);
|
|
|
- }, 200);
|
|
|
+ },1000);
|
|
|
|
|
|
const now = new Date();
|
|
|
this.timestamp = now.getTime(); // 生成签名
|
|
|
const signature = CryptoJS.HmacSHA256(
|
|
|
- `${this.liveId}${this.userData.userId}${this.userType}${this.timestamp}`, this.timestamp.toString()
|
|
|
+ `${this.liveId}${this.userInfo.userId}${this.userType}${this.timestamp}`, this.timestamp.toString()
|
|
|
).toString(CryptoJS.enc.Hex);
|
|
|
|
|
|
try {
|
|
|
@@ -3556,7 +3546,7 @@
|
|
|
// const baseWsUrl = 'ws://d6998672.natappfree.cc/ws/app/webSocket';
|
|
|
// const baseWsUrl = 'ws://nd967d83.natappfree.cc/ws/app/webSocket';
|
|
|
let wsUrl =
|
|
|
- `${baseWsUrl}?userId=${this.userData.userId}&liveId=${this.liveId}&userType=${this.userType}×tamp=${this.timestamp}&signature=${signature}`;
|
|
|
+ `${baseWsUrl}?userId=${this.userInfo.userId}&liveId=${this.liveId}&userType=${this.userType}×tamp=${this.timestamp}&signature=${signature}`;
|
|
|
|
|
|
// let wsUrl =
|
|
|
// 'ws://q96d9752.natappfree.cc/ws/app/webSocket?liveId=128&userId=9769&userType=1×tamp=1762501143712&signature=0498c66c3fca64ab009586200c04d51312ce44e36d5639e99b22e34f3bac8d13';
|
|
|
@@ -3759,7 +3749,7 @@
|
|
|
//console.log(`添加消息前: 当前消息数量=${this.talklist.length}, 是否达到限制=${wasAtLimit}`);
|
|
|
|
|
|
// 检查是否是自己发送的消息
|
|
|
- const isMyMessage = message.userId === this.userData.userId;
|
|
|
+ const isMyMessage = message.userId === this.userInfo.userId;
|
|
|
//console.log(`消息来源: ${isMyMessage ? '自己' : '他人'}, userId=${message.userId}`);
|
|
|
|
|
|
// 给消息添加唯一ID
|
|
|
@@ -3916,8 +3906,8 @@
|
|
|
}
|
|
|
|
|
|
// 解析用户ID(根据实际接口字段调整,此处假设data含userId)
|
|
|
- const userData = JSON.parse(socketMessage.data || '{}');
|
|
|
- const userId = userData.userId || socketMessage.userId; // 兼容不同字段
|
|
|
+ const userInfo = JSON.parse(socketMessage.data || '{}');
|
|
|
+ const userId = userInfo.userId || socketMessage.userId; // 兼容不同字段
|
|
|
if (!userId) return; // 无用户ID不处理
|
|
|
|
|
|
// 仅新用户(未显示过)才触发提示
|
|
|
@@ -4048,12 +4038,12 @@
|
|
|
// 构造发送给服务端的消息数据
|
|
|
const data = {
|
|
|
liveId,
|
|
|
- userId: this.userData.userId,
|
|
|
+ userId: this.userInfo.userId,
|
|
|
userType: 0,
|
|
|
cmd: 'sendMsg',
|
|
|
msg: text,
|
|
|
- nickName: this.userData.nickname || '未命名',
|
|
|
- avatar: this.userData.avatar ||
|
|
|
+ nickName: this.userInfo.nickname || '未命名',
|
|
|
+ avatar: this.userInfo.avatar ||
|
|
|
'https://bjzmky-1323137866.cos.ap-chongqing.myqcloud.com/userapp/images/avatar.png'
|
|
|
};
|
|
|
// 发送socket消息
|
|
|
@@ -4512,13 +4502,17 @@
|
|
|
|
|
|
.notice-message {
|
|
|
position: absolute;
|
|
|
- bottom: 30vh;
|
|
|
+ bottom: 388rpx;
|
|
|
max-width: 80%;
|
|
|
padding: 24rpx;
|
|
|
background-color: rgba(0, 0, 0, 0.3);
|
|
|
margin: 0 0 20rpx 20rpx;
|
|
|
border-radius: 20rpx;
|
|
|
color: #ffda73;
|
|
|
+ overflow: hidden;
|
|
|
+ &.horizontal-notice{
|
|
|
+ position: static;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
.message-scroll-view {
|
|
|
@@ -5234,6 +5228,7 @@
|
|
|
|
|
|
.message-close-icon {
|
|
|
position: absolute;
|
|
|
+ z-index: 9;
|
|
|
top: 14rpx;
|
|
|
right: 14rpx;
|
|
|
width: 50rpx;
|