living.js 24 KB

1
  1. "use strict";const t=require("../../common/vendor.js"),x=require("../../api/list.js"),u=require("../../api/live.js");require("../../api/order.js");const I=require("../../api/home.js"),d=require("../../common/assets.js");var C="ws://192.168.10.166:7114/app/webSocket",v=!1;const y={data(){return{lastSwiperChangeTime:0,swiperChangeThrottle:300,lastClickTime:0,clickDelay:300,connectingLiveId:null,swiperDuration:0,videoRetryCounts:{},socketInstances:{},currentSwiperIndex:0,list:[],preloading:!1,liveUserTotal:null,viewPageSize:10,viewPageNum:1,viewLoading:!1,viewNoMoreData:!1,scrollHeight:0,scrollTimer:null,socketInstance:null,reconnectCount:0,maxReconnectAttempts:3,isManualClose:!1,showRed:!0,searchTimer:null,reconnectTimer:null,isCollect:!1,showPurchasePrompt:!1,purchasePromptTimer:null,prevOrderCount:0,videoUrl:null,showType:1,boxHeight:300,liveViewers:[],likeName:0,hlsPlayer:null,livingUrl:"",products:{},store:{},orderUser:{},userType:0,timestamp:"",liveId:null,isZoom:!1,userinfo:"",talkdisabled:!1,autoplay:!1,showadd:!1,scrollIntoView:"",videoContext:"",thistime:t.index.$u.timeFormat(new Date,"yyyy-mm-dd hh:MM:ss"),isSubmit:!1,messageContent:"",showziliao:!1,isScreen:!0,scrollTop:0,old:{scrollTop:0},livedata:{}}},onLoad(e){this.initTime(),e.liveId&&(this.liveId=e.liveId),this.userinfo=JSON.parse(t.index.getStorageSync("userInfo")),this.initLiveList(e),this.getliveUser(!1);const s=t.index.getWindowInfo().platform;["mp-weixin","mp-alipay","mp-baidu","mp-toutiao"].includes(s)&&(t.index.showShareMenu?t.index.showShareMenu({withShareTicket:!0,success:()=>{console.log("分享菜单显示成功")},fail:i=>{console.error("分享菜单显示失败:",i)}}):console.warn("当前平台不支持 uni.showShareMenu"))},onReady(){},onShareAppMessage(){return{title:this.livedata.liveName,path:"/pages/home/living",imageUrl:this.products.image,success(e){console.log("分享成功",e)},fail(e){console.error("分享失败",e)}}},computed:{filteredViewers(){if(this.liveViewers)return this.liveViewers.slice(0,3)}},onHide(){const e=this.list[this.currentSwiperIndex];e&&(this.pauseVideo(e),this.clearTimeTimer(e)),this.closeAllWebSockets()},onUnload(){this.list.forEach(e=>{this.clearTimeTimer(e)}),this.closeAllWebSockets(),this.socketInstances={},this.removeAllEventListeners(),this.clearAllTimers(),this.hlsPlayer&&(this.hlsPlayer.destroy(),this.hlsPlayer=null),this.list.forEach(e=>{const s=`myVideo_${e.liveId}`,i=t.index.createVideoContext(s,this);i&&i.pause()})},watch:{"orderUser.count":{handler(e,s){e!==this.prevOrderCount&&(this.prevOrderCount=e,this.showPurchaseMessage())},immediate:!0}},methods:{calculateTimeDiff(e){if(!e.startTime){e.totalTime="00小时00分钟00秒";return}const s=e.startTime.replace(/-/g,"/").replace(" "," "),i=new Date(e.startTime),c=new Date;if(isNaN(i.getTime())){console.warn(`iOS 时间解析失败,原始时间:${e.startTime},转换后:${s}`),e.totalTime="00小时00分钟00秒";return}const a=Math.max(0,c-i),r=Math.floor(a/1e3),h=this.padZero(Math.floor(r/3600)),o=this.padZero(Math.floor(r%3600/60)),f=this.padZero(r%60);this.$set(e,"totalTime",`${h}:${o}:${f}`)},padZero(e){return e<10?`0${e}`:e},startTimeTimer(e){e.timeTimer&&clearInterval(e.timeTimer),this.calculateTimeDiff(e),e.timeTimer=setInterval(()=>{this.calculateTimeDiff(e)},1e3)},clearTimeTimer(e){e.timeTimer&&(clearInterval(e.timeTimer),e.timeTimer=null)},toggleViewerList(){const e=Date.now();e-this.lastClickTime>this.clickDelay&&(this.showadd=!this.showadd,this.lastClickTime=e)},resetUserListParams(){this.viewPageNum=1,this.viewNoMoreData=!1,this.liveViewers=[]},closeAllWebSockets(){this.isManualClose=!0,Object.keys(this.socketInstances).forEach(e=>{try{this.socketInstances[e]&&this.socketInstances[e].instance&&(this.socketInstances[e].instance.close({code:1e3,reason:"页面关闭"}),console.log(`直播间 ${e} WebSocket 已关闭`))}catch(s){console.error(`关闭直播间 ${e} WebSocket 时出错:`,s)}}),this.socketInstances={},v=!1},removeAllEventListeners(){t.index.$off("initSocket"),t.index.$off("sendMsg"),t.index.$off("closeWebSocket"),t.index.$off("refreshOrder")},clearAllTimers(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.pingpangTimes&&(clearInterval(this.pingpangTimes),this.pingpangTimes=null),this.reconnectTimer&&(clearInterval(this.reconnectTimer),this.reconnectTimer=null),this.scrollTimer&&(clearTimeout(this.scrollTimer),this.scrollTimer=null),this.searchTimer&&(clearTimeout(this.searchTimer),this.searchTimer=null),this.purchasePromptTimer&&(clearTimeout(this.purchasePromptTimer),this.purchasePromptTimer=null)},async initCurrentLiveData(){const e=this.list[this.currentSwiperIndex];if(e){e.loading=!0;try{await this.initSocket(e),await Promise.allSettled([this.getLiveMsg(e),this.getliveViewData(e),this.getliving(e)]),e.loaded=!0,this.startTimeTimer(e)}catch(s){console.error("初始化直播间数据失败:",s)}finally{e.loading=!1}}},async initLiveList(e){try{if(await this.getList(),this.list.length===0){console.error("直播间列表为空,无法初始化");return}if(e.liveId){const i=this.list.findIndex(c=>c.liveId==e.liveId);this.currentSwiperIndex=i!==-1?i:0}else this.currentSwiperIndex=0;setTimeout(()=>{this.swiperDuration=300},100);const s=this.list[this.currentSwiperIndex];s&&(this.liveId=s.liveId,this.resetUserListParams(),this.preloadNearbyLives(!1),await this.initCurrentLiveData(),this.getliveUser(!1),setTimeout(()=>{this.playVideo(s)},500))}catch(s){console.error("初始化失败:",s)}},async onSwiperChange(e){const s=Date.now(),i=e.detail.current,c=this.currentSwiperIndex;if(i===c)return;if(s-this.lastSwiperChangeTime<this.swiperChangeThrottle){console.log("Swiper切换过快,已节流");return}this.lastSwiperChangeTime=s;const a=this.list[c];if(a&&(this.pauseVideo(a),this.clearTimeTimer(a),this.socketInstances[a.liveId])){try{this.socketInstances[a.liveId].instance.close({code:1e3,reason:"切换直播间"}),console.log(`关闭旧直播间 ${a.liveId} WebSocket`)}catch(h){console.error("关闭旧连接失败:",h)}delete this.socketInstances[a.liveId]}this.currentSwiperIndex=i;const r=this.list[i];r&&(this.liveId=r.liveId,this.resetUserListParams(),await this.initCurrentLiveData(),this.getliveUser(!1),setTimeout(()=>{this.playVideo(r)},100))},async getList(){const e={page:1,page_size:20};try{const s=await x.liveList(e);s.code===200?(this.list=s.rows.map(i=>({...i,talklist:[],loading:!1,loaded:!1,shopping:!1,inputInfo:"",showWelcomeMessage:!1,redInfo:{},goodsCard:{},totalTime:"00小时00分钟00秒",timeTimer:null,startTime:i.startTime?i.startTime.replace(/-/g,"/"):""})),console.log("直播间列表加载成功,数量:",this.list.length)):(t.index.showToast({title:s.msg,icon:"none"}),this.list=[])}catch(s){console.error("获取直播间列表失败:",s),this.list=[]}},playVideo(e){if(e)try{const s=`myVideo_${e.liveId}`,i=t.index.createVideoContext(s,this);i&&i.pause(()=>{i.play()})}catch(s){console.error("播放视频失败:",s)}},pauseVideo(e){if(e)try{const s=`myVideo_${e.liveId}`,i=t.index.createVideoContext(s,this);i&&i.pause()}catch(s){console.error("暂停视频失败:",s)}},async preloadNearbyLives(e=!1){this.preloading=!0;const s=this.currentSwiperIndex,i=[];e=!1,s>0&&i.push(s-1),s<this.list.length-1&&i.push(s+1);for(const c of i){const a=this.list[c];if(!(!a||a.loaded||a.loading)){a.loading=!0;try{await Promise.all([this.getliving(a),this.getLiveMsg(a),this.getliveViewData(a)]),a.loaded=!0}catch(r){console.error(`预加载直播间 ${c} 失败:`,r),a.loaded=!1}finally{a.loading=!1}}}this.preloading=!1},openViews(){this.$nextTick(()=>{t.index.createSelectorQuery().in(this).select(".view-box").boundingClientRect(s=>{s&&(this.scrollHeight=s.height-80-120)}).exec()})},resetLiveData(){const e={userinfo:this.userinfo,list:this.list,currentSwiperIndex:this.currentSwiperIndex};this.liveUserTotal=null,this.liveViewers=[],this.livingUrl="",this.videoUrl=null,this.products={},this.store={},this.orderUser={},this.talklist=[],this.livedata={},this.shopping=!1,this.inputInfo="",Object.assign(this,e)},async getliveUser(e=!1){const s=this.liveId;if(s){this.viewLoading=!0;try{const i=await u.watchUserList(s,this.viewPageSize,this.viewPageNum,!1);if(i.code===200){if(this.liveId!==s)return;if(this.liveUserTotal=i.total,i.rows.length===0){this.viewNoMoreData=!0;return}this.liveViewers=e?[...this.liveViewers,...i.rows]:i.rows,this.viewPageNum++}}catch(i){console.error("获取观众列表失败:",i)}finally{this.viewLoading=!1}}},handleScrollToLower(){this.scrollTimer&&clearTimeout(this.scrollTimer),this.scrollTimer=setTimeout(()=>{this.getliveUser(!0)},1e3)},async getLiveMsg(e){if(!e||!e.liveId){console.error("getLiveMsg 错误:无效的 liveItem",{liveItem:e,currentIndex:this.currentSwiperIndex,listLength:this.list.length});return}try{const s=await u.liveMsg(e.liveId,30,1);s.code==200&&(this.$set(e,"talklist",[...s.rows]),this.$nextTick(()=>{this.$set(e,"scrollIntoView",`list_${e.talklist.length-1}`)}))}catch(s){console.error("获取聊天记录失败:",s)}},onRed(e){var i;if(!e.liveId||!((i=e.redInfo)!=null&&i.redId))return;let s={liveId:e.liveId,userId:this.userinfo.userId,redId:e.redInfo.redId};console.log("点了this.liveId",s),u.liveRed(s).then(c=>{c.code==200?t.index.showToast({title:c.msg,icon:"none"}):t.index.showToast({title:c.msg,icon:"none"})},c=>{})},handleSearchInput(){clearTimeout(this.searchTimer),this.searchTimer=setTimeout(()=>{this.queryCollect()},500)},showPurchaseMessage(){this.purchasePromptTimer&&clearTimeout(this.purchasePromptTimer),this.showPurchasePrompt=!0,this.purchasePromptTimer=setTimeout(()=>{this.showPurchasePrompt=!1},2e3)},truncateString(e,s){return e.length>s?e.slice(0,s)+"...":e},goStore(e){if(console.log("带过去storeId",e),!e.storeId){t.index.showToast({title:"当前直播间暂未开通店铺",icon:"none"});return}t.index.navigateTo({url:"/pages_shop/store?liveId="+e.liveId+"&storeId="+e.storeId})},goOrderList(){t.index.navigateTo({url:"/pages_shop/order"})},initHlsPlayer(){if(t.Hls.isSupported()&&this.livingUrl){const e=document.getElementById("myVideo");e&&(this.hlsPlayer=new t.Hls,this.hlsPlayer.loadSource(this.livingUrl),this.hlsPlayer.attachMedia(e),this.hlsPlayer.on(t.Hls.Events.MANIFEST_PARSED,()=>{e.play()}))}},videoError(e,s){if(!(!s||s.liveId!==this.liveId)){if(this.videoRetryCounts[s.liveId]===void 0&&(this.videoRetryCounts[s.liveId]=0),this.videoRetryCounts[s.liveId]>=3){console.error(`直播间 ${s.liveId} 视频加载失败,停止重试`),t.index.showToast({title:"视频加载失败,请检查网络",icon:"none",duration:2e3});return}this.videoRetryCounts[s.liveId]++,setTimeout(()=>{s.liveId===this.liveId&&(console.log(`第${this.videoRetryCounts[s.liveId]}次重试播放视频`),this.playVideo(s))},2e3)}},async getliving(e){if(!(!e||!e.liveId)){e.liveId;try{const s=await I.getlive({id:e.liveId});if(s.code!==200){t.index.showToast({title:s.msg,icon:"none"});return}s.data.liveType===2?(this.$set(e,"videoUrl",s.data.videoUrl),this.$set(e,"livingUrl",""),this.$set(e,"placeholderText","说点什么...")):s.data.liveType===1?(this.$set(e,"livingUrl",s.data.flvHlsUrl),this.$set(e,"videoUrl",""),this.$set(e,"placeholderText","说点什么...")):(this.$set(e,"livingUrl",""),this.$set(e,"videoUrl",""));const i=this.currentSwiperIndex===this.list.findIndex(c=>c.liveId===e.liveId);this.$set(e,"autoplay",i&&s.data.liveType!==0),this.$set(e,"showType",s.data.showType),this.$set(e,"storeId",s.storeId),this.queryCollect()}catch(s){console.error("获取直播信息失败:",s),t.index.showToast({title:"获取直播信息失败",icon:"none"})}}},setupVideoPlayback(e,s){if(!e.livingUrl)return;const i=`myVideo_${e.liveId}`,c=t.index.createVideoContext(i,this);s.liveType===1?c.seek(s.nowDuration||0):c.play()},maskString(e,s="*"){return e?String(e).split("").map((c,a)=>a===0?c:s).join(""):""},getPureDecimal(e,s=6){const i=Math.abs(e).toFixed(s).split(".")[1];return(i==null?void 0:i.replace(/0+$/,""))||""},goBack(){const e=this.list[this.currentSwiperIndex];e&&this.pauseVideo(e),this.closeWebSocket(),getCurrentPages().length>1?t.index.navigateBack():t.index.reLaunch({url:"/pages/list/index"})},async getliveOrder(){const e=this.liveId;if(e)try{const s=await u.liveOrderUser(e);if(s.code===200){const i=this.list[this.currentSwiperIndex];i&&(this.$set(i,"orderUser",s),this.orderUser=s)}}catch(s){console.error("获取正在购买用户失败:",s)}},getLiveinformation(){this.liveId&&u.getLiveInfo(this.liveId).then(e=>{e.code==200?(console.log("获取直播间信息接口>>>>",e),this.livingUrl=e.livingUrl):t.index.showToast({title:e.msg,icon:"none"})},e=>{})},async onLike(e){if(!(!e||!e.liveId))try{const s=await u.liveDataLike(e.liveId);s!=null&&s.like?e.liveViewData.like++:t.index.showToast({title:s.msg,icon:"none"})}catch(s){console.error("点赞失败:",s)}},async getliveViewData(e){if(!(!e||!e.liveId))try{const s=await u.getLiveViewData(e.liveId);s.code==200&&this.$set(e,"liveViewData",s)}catch(s){console.error("获取直播间数据失败:",s),this.$set(e,"liveViewData",{like:0,watchCount:0})}},goShop(e,s){const i=this.list[this.currentSwiperIndex];!i||!i.liveId||t.index.navigateTo({url:"/pages_shop/goods?productId="+e+"&liveId="+i.liveId+"&goodsId="+s+"&storeId="+i.storeId})},async queryCollect(){const e=this.list[this.currentSwiperIndex];if(!e||!e.liveId)return;const{storeId:s}=e;if(s)try{const i=await u.store(e.storeId,e.inputInfo,e.liveId);i.code===200&&(this.$set(e,"products",i.data.goodsList),this.$set(e,"store",i.data),this.products=i.data.goodsList,this.store=i.data)}catch(i){console.error("获取小黄车商品失败:",i)}},onStoreCollect(e){console.log("店铺收藏",e),e.storeId&&u.collectStore(e.storeId).then(s=>{s.code==200?(t.index.showToast({title:s.msg,icon:"none"}),e.store.isFavorite=!e.store.isFavorite):t.index.showToast({title:s.msg,icon:"none"})},s=>{})},onGoodsCollect(e){console.log("商品收藏",e),!(!e||e.length===0||!e.goodsId)&&u.collectGoods(e.goodsId).then(s=>{s.code==200?(t.index.showToast({title:s.msg,icon:"none"}),e.isFavorite=!e.isFavorite):t.index.showToast({title:s.msg,icon:"none"})},s=>{})},initTime(){const e=new Date;this.timestamp=e.getTime()},openShop(){},openViews(){this.$nextTick(()=>{t.index.createSelectorQuery().in(this).select(".view-box").boundingClientRect(s=>{s&&(this.scrollHeight=s.height-80-120)}).exec()})},close(){this.showadd=!1},closes(){this.showziliao=!this.showziliao},closeShop(){const e=this.list[this.currentSwiperIndex];e&&this.$set(e,"shopping",!e.shopping)},closeRed(){this.showRed=!this.showRed},handleTouchEnd(){this.isZoom=!1},getEWechatSdk(){},closeWebSocket(e=null){if(this.isManualClose=!0,clearInterval(this.pingpangTimes),clearInterval(this.reconnectTimer),e){if(this.socketInstances[e]&&this.socketInstances[e].instance)try{this.socketInstances[e].instance.close(),console.log(`直播间 ${e} WebSocket 已安全关闭`)}catch(s){console.error(`关闭直播间 ${e} WebSocket 时出错:`,s)}delete this.socketInstances[e]}else Object.keys(this.socketInstances).forEach(s=>{if(this.socketInstances[s]&&this.socketInstances[s].instance)try{this.socketInstances[s].instance.close(),console.log(`直播间 ${s} WebSocket 已安全关闭`)}catch(i){console.error(`关闭直播间 ${s} WebSocket 时出错:`,i)}}),this.socketInstances={};v=!1},reConnect(){var e=this;try{t.index.closeSocket()}catch{}setTimeout(function(){e.initSocket()},1e4)},startHeartbeat(e){clearInterval(this.pingpangTimes),this.pingpangTimes=setInterval(()=>{const s=this.socketInstances[e];if(!s||!s.isOpen||!s.instance)return;const i={cmd:"ping",timestamp:Date.now()};try{s.instance.send({data:JSON.stringify(i)})}catch(c){console.error("心跳发送失败:",c),this.scheduleReconnect(e)}},3e4)},async initSocket(e){const s=this.list[this.currentSwiperIndex];if(!s||s.liveId!==e.liveId){console.log(`拒绝为非活跃直播间 ${e.liveId} 建立WebSocket`);return}if(!e||!e.liveId)return;const i=e.liveId;if(this.connectingLiveId===i||this.socketInstances[i]&&this.socketInstances[i].isOpen){console.log(`直播间 ${i} 的WebSocket已经连接或正在连接,跳过初始化`);return}if(this.currentSwiperIndex!==this.list.findIndex(r=>r.liveId===i)){console.log(`不初始化非当前直播间 ${i} 的WebSocket`);return}if(this.socketInstances[i]&&this.closeWebSocket(i),this.connectingLiveId=i,this.reconnectCount>=this.maxReconnectAttempts){this.connectingLiveId=null;return}this.isManualClose=!1;const c=setTimeout(()=>{var r;(r=this.socketInstances[i])!=null&&r.isOpen||(console.error(`WebSocket连接超时: ${i}`),this.scheduleReconnect(i))},1e4),a=t.CryptoJS.HmacSHA256(`${i}${this.userinfo.userId}${this.userType}${this.timestamp}`,this.timestamp.toString()).toString(t.CryptoJS.enc.Hex);this.socketInstances[i]={instance:null,isOpen:!1};try{const r=t.index.connectSocket({url:`${C}?userId=${this.userinfo.userId}&liveId=${i}&userType=${this.userType}&timestamp=${this.timestamp}&signature=${a}`,success:()=>{console.log("WebSocket API 调用成功,正在建立连接...")},fail:h=>{console.error("WebSocket 连接失败:",h),this.connectingLiveId=null,this.scheduleReconnect(i)}});r.onOpen(h=>{console.log("WebSocket 连接已成功建立",h),this.socketInstances[i].instance=r,this.socketInstances[i].isOpen=!0,clearTimeout(c),v=!0,this.connectingLiveId=null,this.reconnectCount=0,this.startHeartbeat(i)}),r.onMessage(h=>{const o=this.list.find(f=>f.liveId===i);o&&this.handleSocketMessage(h,o)}),r.onError(h=>{clearTimeout(c),console.error("WebSocket 连接错误:",h),this.connectingLiveId=null,this.scheduleReconnect(i)}),r.onClose(()=>{console.log(`WebSocket 连接已关闭: ${i}`),this.connectingLiveId=null})}catch(r){console.error("创建 WebSocket 异常:",r),this.connectingLiveId=null,this.scheduleReconnect(i)}},handleSocketMessage(e,s){let i=JSON.parse(e.data);const c=i.data;if(i.code==200){const a={...c,cmd:c.cmd||""};c.cmd=="sendMsg"?this.$nextTick(()=>{this.$set(s,"scrollIntoView",`list_${s.talklist.length-1}`)}):c.cmd=="red"?(this.$set(s,"redInfo",JSON.parse(c.data)),console.log("红包是liveItem.redInfo",s)):c.cmd=="sendRedPacketQuestion"?JSON.parse(e.data.data):c.cmd=="entry"||c.cmd=="out"?(this.$set(s,"talklist",[...s.talklist,a]),this.$set(s,"showWelcomeMessage",!1),this.$set(s,"showWelcomeMessage",!0),this.getliveUser(!1),s.welcomeTimer&&clearTimeout(s.welcomeTimer),s.welcomeTimer=setTimeout(()=>{this.$set(s,"showWelcomeMessage",!1)},1e3)):c.cmd=="Integral"?t.index.showToast({title:c.msg,icon:"none",duration:2e3}):c.cmd=="blockUser"?t.index.removeStorage({key:"AppToken",success:()=>{t.index.reLaunch({url:"/pages/auth/login"}),console.log("Token 删除成功")},fail:r=>{console.error("Token 删除失败:",r)}}):c.cmd=="goods"?this.$set(s,"goodsCard",JSON.parse(c.data)):c.cmd=="out"?console.log("有人退出了:"):c.cmd=="live_start"||c.cmd=="live_end"||(c.data.cmd=="deleteId"?t.index.$emit("deleteId"):c.data.cmd=="sendRedPacketQuestion")}else t.index.showToast({title:i.msg,icon:"none"})},scheduleReconnect(e){if(this.isManualClose||this.reconnectCount>=this.maxReconnectAttempts)return;this.reconnectCount++;const s=Math.min(3e3*this.reconnectCount,3e4);clearInterval(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{const i=this.list.find(c=>c.liveId===e)||{liveId:e};this.initSocket(i)},s)},sendMsg(e){if(!e||!e.liveId||e.isSending)return;e.isSending=!0,setTimeout(()=>{e.isSending=!1},800);const s=(e.value||"").trim();if(!s){t.index.showToast({title:"不能发送空消息",icon:"none"});return}const i=e.liveId,c=this.socketInstances[i],a={cmd:"sendMsg",msg:s,nickName:this.userinfo.nickName,avatar:this.userinfo.avatar,userId:this.userinfo.userId,local:!0,ts:Date.now()};if(this.$set(e,"talklist",[...e.talklist||[],a]),this.$set(e,"value",""),!c||!c.instance||!c.isOpen){this.initSocket(e),t.index.showToast({title:"连接未建立,正在重连",icon:"none"});return}const r={liveId:i,userId:this.userinfo.userId,userType:0,cmd:"sendMsg",msg:s,nickName:this.userinfo.nickName,avatar:this.userinfo.avatar};try{c.instance.send({data:JSON.stringify(r),success:()=>{},fail:h=>{console.error("发送失败:",h),t.index.showToast({title:"发送失败,请重试",icon:"none"})}})}catch(h){console.error("socket send 异常",h)}}}};if(!Array){const e=t.resolveComponent("u-avatar"),s=t.resolveComponent("u-loading"),i=t.resolveComponent("u-input"),c=t.resolveComponent("u-popup");(e+s+i+c)()}const _=()=>"../../uni_modules/uview-plus/components/u-avatar/u-avatar.js",L=()=>"../../uni_modules/uview-plus/components/u-input/u-input.js",U=()=>"../../uni_modules/uview-plus/components/u-popup/u-popup.js";Math||(_+L+U)();function b(e,s,i,c,a,r){var h;return{a:t.f(a.list,(o,f,g)=>{var T,m,S,k;return t.e({a:t.o((...n)=>r.goBack&&r.goBack(...n),o.liveId),b:"471975a0-0-"+g,c:t.p({src:o.liveImgUrl||e.$img.logo,size:"32"}),d:t.t(o.liveName?r.truncateString(o.liveName,5):"未命名"),e:t.f(r.filteredViewers,(n,l,p)=>({a:l,b:n.avatar||e.$img.logo})),f:t.o((...n)=>r.toggleViewerList&&r.toggleViewerList(...n),o.liveId),g:((T=o.redInfo)==null?void 0:T.redStatus)==1},((m=o.redInfo)==null?void 0:m.redStatus)==1?{h:t.o(n=>r.onRed(o),o.liveId),i:d._imports_1$3}:{},a.showPurchasePrompt&&((S=a.orderUser)!=null&&S.count)?{j:d._imports_5$1,k:t.t(a.orderUser.userName?r.maskString(a.orderUser.userName):""),l:t.t(a.orderUser.count||0)}:{},{m:o.livingUrl},o.livingUrl?{n:"myVideo_"+o.liveId,o:t.n(o.showType==1?"video_row":"videotop"),p:o.livingUrl,q:a.currentSwiperIndex===f,r:t.o((...n)=>r.videoError&&r.videoError(...n),o.liveId)}:{},{s:o.videoUrl},o.videoUrl?{t:t.n(o.showType==1?"video_row":"videotop"),v:o.videoUrl,w:a.currentSwiperIndex===f,x:t.o((...n)=>r.videoError&&r.videoError(...n),o.liveId)}:{},{y:o.videoUrl},o.videoUrl?{z:t.t(o.totalTime)}:{},{A:o.loading},o.loading?{B:"471975a0-1-"+g,C:t.p({mode:"circle",color:"#ffffff",size:"36"})}:{},{D:t.f(o.talklist,(n,l,p)=>({a:t.t(n.msg),b:l,c:n.cmd=="announcement"})),E:t.t(o.messageContent),F:t.f(o.talklist,(n,l,p)=>({a:t.t(n.nickName),b:t.t(n.msg),c:l,d:`list_${l}`,e:n.cmd!="red"&&n.cmd!="out"&&n.cmd!="entry"})),G:o.showWelcomeMessage},o.showWelcomeMessage?{H:t.f(o.talklist,(n,l,p)=>({a:t.t(n.nickName),b:t.t(n.msg),c:l,d:n.cmd=="entry"||n.cmd=="out"})),I:t.t(o.messageContent)}:{},{J:o.scrollIntoView,K:"471975a0-2-"+g,L:t.o(n=>o.value=n,o.liveId),M:t.p({placeholder:o.placeholderText,border:"none",customStyle:"font-size:24rpx;",shape:"circle",color:"#fff",placeholderStyle:"color:#e7e7e7",modelValue:o.value}),N:t.o(n=>r.sendMsg(o),o.liveId),O:t.t(((k=o.liveViewData)==null?void 0:k.like)||0),P:t.o(n=>r.onLike(o),o.liveId),Q:t.o(n=>o.goodsCard.isShow=!1,o.liveId),R:o.goodsCard.imgUrl,S:t.t(o.goodsCard.price),T:t.t(o.goodsCard.otPrice),U:t.t(o.goodsCard.productName),V:t.f(a.liveViewers,(n,l,p)=>({a:t.t(l+1),b:l===0?"#FF3B30":l===1?"#FF9500":l===2?"#FFCC00":"#8E8E93",c:l<3?"bold":"normal",d:"471975a0-4-"+g+"-"+p+","+("471975a0-3-"+g),e:t.p({src:n.avatar||e.$img.logo,size:"32"}),f:t.t(n.nickName||"未命名"),g:l}))},a.viewNoMoreData&&a.liveViewers.length>0?{}:{},{W:t.o((...n)=>r.handleScrollToLower&&r.handleScrollToLower(...n),o.liveId),X:t.o(r.close,o.liveId),Y:t.o(r.openViews,o.liveId),Z:"471975a0-3-"+g,aa:"471975a0-6-"+g+","+("471975a0-5-"+g),ab:t.o([n=>o.inputInfo=n.detail.value,(...n)=>r.handleSearchInput&&r.handleSearchInput(...n)],o.liveId),ac:o.inputInfo},a.store.isFavorite?{ad:t.o(n=>r.onStoreCollect(o),o.liveId),ae:d._imports_11}:{af:t.o(n=>r.onStoreCollect(o),o.liveId),ag:d._imports_12},{ah:t.o(n=>r.goOrderList(o),o.liveId),ai:t.f(a.products,(n,l,p)=>t.e({a:n.imgUrl,b:t.t(l+1),c:t.t(n.productName),d:t.t(n.sales),e:t.t(Math.trunc(n.price)),f:t.t(r.getPureDecimal(n.price)?r.getPureDecimal(n.price):"00"),g:n.isFavorite},n.isFavorite?{h:t.o(w=>r.onGoodsCollect(n),l),i:d._imports_11}:{j:t.o(w=>r.onGoodsCollect(n),l),k:d._imports_12},{l:n.status==1},n.status==1?{m:t.o(w=>r.goShop(n.productId,n.goodsId),l)}:n.status==0?{o:t.o(w=>r.goShop(n.productId),l)}:{},{n:n.status==0,p:l})),aj:t.o(r.closeShop,o.liveId),ak:t.o(r.openShop,o.liveId),al:"471975a0-5-"+g,am:t.p({show:o.shopping,round:"20rpx",bgColor:"f3f5f9"}),an:a.currentSwiperIndex===f?1:"",ao:o.liveId})}),b:d._imports_0$2,c:t.t(a.liveUserTotal||0),d:a.showPurchasePrompt&&((h=a.orderUser)==null?void 0:h.count),e:d._imports_2,f:d._imports_4,g:d._imports_5,h:d._imports_6,i:a.viewNoMoreData&&a.liveViewers.length>0,j:a.scrollHeight+"px",k:t.p({show:a.showadd,round:"20rpx",bgColor:"#ffffff"}),l:t.p({src:a.store.logoUrl,size:"36"}),m:d._imports_1$2,n:a.store.isFavorite,o:d._imports_10,p:a.boxHeight+"px",q:a.currentSwiperIndex,r:t.o((...o)=>r.onSwiperChange&&r.onSwiperChange(...o)),s:a.swiperDuration}}const M=t._export_sfc(y,[["render",b],["__scopeId","data-v-471975a0"]]);y.__runtimeHooks=2;wx.createPage(M);