1 |
- "use strict";const t=require("../../common/vendor.js"),x=require("../../api/list.js"),g=require("../../api/live.js");require("../../api/order.js");const C=require("../../api/home.js"),d=require("../../common/assets.js");var I="wss://live.test.ylrztop.com/ws/live-api/app/webSocket",w=!1;const m={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,userinfo:"",talkdisabled:!1,autoplay:!1,showadd:!1,scrollIntoView:"",videoContext:"",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),a=new Date;if(isNaN(i.getTime())){console.warn(`iOS 时间解析失败,原始时间:${e.startTime},转换后:${s}`),e.totalTime="00小时00分钟00秒";return}const r=Math.max(0,a-i),n=Math.floor(r/1e3),h=this.padZero(Math.floor(n/3600)),o=this.padZero(Math.floor(n%3600/60)),u=this.padZero(n%60);this.$set(e,"totalTime",`${h}:${o}:${u}`)},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={},w=!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.getShowGoods(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(a=>a.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,a=this.currentSwiperIndex;if(i===a)return;if(s-this.lastSwiperChangeTime<this.swiperChangeThrottle){console.log("Swiper切换过快,已节流");return}this.lastSwiperChangeTime=s;const r=this.list[a];if(r&&(this.pauseVideo(r),this.clearTimeTimer(r),console.log("oldLive",r),this.socketInstances[r.liveId])){try{this.socketInstances[r.liveId].instance.close({code:1e3,reason:"切换直播间"}),console.log(`关闭旧直播间 ${r.liveId} WebSocket`)}catch(h){console.error("关闭旧连接失败:",h)}delete this.socketInstances[r.liveId]}this.currentSwiperIndex=i;const n=this.list[i];n&&(this.liveId=n.liveId,this.resetUserListParams(),await this.initCurrentLiveData(),this.getliveUser(!1),setTimeout(()=>{this.playVideo(n)},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 a of i){const r=this.list[a];if(!(!r||r.loaded||r.loading)){r.loading=!0;try{await Promise.all([this.getliving(r),this.getLiveMsg(r),this.getliveViewData(r),this.getShowGoods(r)]),r.loaded=!0}catch(n){console.error(`预加载直播间 ${a} 失败:`,n),r.loaded=!1}finally{r.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 g.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 g.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),g.liveRed(s).then(a=>{a.code==200?t.index.showToast({title:a.msg,icon:"none"}):t.index.showToast({title:a.msg,icon:"none"})},a=>{})},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 C.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(a=>a.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}`,a=t.index.createVideoContext(i,this);s.liveType===1?a.seek(s.nowDuration||0):a.play()},maskString(e,s="*"){return e?String(e).split("").map((a,r)=>r===0?a: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 g.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&&g.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 g.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 g.getLiveViewData(e.liveId);s.code==200&&this.$set(e,"liveViewData",s)}catch(s){console.error("获取直播间数据失败:",s),this.$set(e,"liveViewData",{like:0,watchCount:0})}},async getShowGoods(e){if(!(!e||!e.liveId))try{const s=await g.showGoods(e.liveId);s.code==200&&this.$set(e,"goodsCard",s)}catch(s){console.error("暂无商品卡片",s)}},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 g.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&&g.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)&&g.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()})},openCart(e){if(!e.storeId){t.index.showToast({title:"当前直播间暂未开通店铺",icon:"none"});return}e.shopping=!e.shopping},close(){this.showadd=!1},closeShop(){const e=this.list[this.currentSwiperIndex];e&&this.$set(e,"shopping",!e.shopping)},closeRed(){this.showRed=!this.showRed},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={};w=!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(a){console.error("心跳发送失败:",a),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(n=>n.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 a=setTimeout(()=>{var n;(n=this.socketInstances[i])!=null&&n.isOpen||(console.error(`WebSocket连接超时: ${i}`),this.scheduleReconnect(i))},1e4),r=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 n=t.index.connectSocket({url:`${I}?userId=${this.userinfo.userId}&liveId=${i}&userType=${this.userType}×tamp=${this.timestamp}&signature=${r}`,success:()=>{console.log("WebSocket API 调用成功,正在建立连接...")},fail:h=>{console.error("WebSocket 连接失败:",h),this.connectingLiveId=null,this.scheduleReconnect(i)}});n.onOpen(h=>{console.log("WebSocket 连接已成功建立",h),this.socketInstances[i].instance=n,this.socketInstances[i].isOpen=!0,clearTimeout(a),w=!0,this.connectingLiveId=null,this.reconnectCount=0,this.startHeartbeat(i)}),n.onMessage(h=>{const o=this.list.find(u=>u.liveId===i);o&&this.handleSocketMessage(h,o)}),n.onError(h=>{clearTimeout(a),console.error("WebSocket 连接错误:",h),this.connectingLiveId=null,this.scheduleReconnect(i)}),n.onClose(()=>{console.log(`WebSocket 连接已关闭: ${i}`),this.connectingLiveId=null})}catch(n){console.error("创建 WebSocket 异常:",n),this.connectingLiveId=null,this.scheduleReconnect(i)}},handleSocketMessage(e,s){let i=JSON.parse(e.data);const a=i.data;if(i.code==200){const r={...a,cmd:a.cmd||""};a.cmd=="sendMsg"?this.$nextTick(()=>{this.$set(s,"scrollIntoView",`list_${s.talklist.length-1}`)}):a.cmd=="red"?(this.$set(s,"redInfo",JSON.parse(a.data)),console.log("红包是liveItem.redInfo",s)):a.cmd=="sendRedPacketQuestion"?JSON.parse(e.data.data):a.cmd=="entry"||a.cmd=="out"?(this.$set(s,"talklist",[...s.talklist,r]),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)):a.cmd=="Integral"?t.index.showToast({title:a.msg,icon:"none",duration:2e3}):a.cmd=="blockUser"?t.index.removeStorage({key:"AppToken",success:()=>{t.index.reLaunch({url:"/pages/auth/login"}),console.log("Token 删除成功")},fail:n=>{console.error("Token 删除失败:",n)}}):a.cmd=="goods"?this.$set(s,"goodsCard",JSON.parse(a.data)):a.cmd=="out"?console.log("有人退出了:"):a.cmd=="live_start"||a.cmd=="live_end"||(a.data.cmd=="deleteId"?t.index.$emit("deleteId"):a.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(a=>a.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,a=this.socketInstances[i],r={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||[],r]),this.$set(e,"value",""),!a||!a.instance||!a.isOpen){this.initSocket(e),t.index.showToast({title:"连接未建立,正在重连",icon:"none"});return}const n={liveId:i,userId:this.userinfo.userId,userType:0,cmd:"sendMsg",msg:s,nickName:this.userinfo.nickName,avatar:this.userinfo.avatar};try{a.instance.send({data:JSON.stringify(n),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-input"),i=t.resolveComponent("u-popup");(e+s+i)()}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,a,r,n){var h;return{a:t.f(r.list,(o,u,p)=>{var T,v,S,k;return t.e({a:t.o((...c)=>n.goBack&&n.goBack(...c),o.liveId),b:"471975a0-0-"+p,c:t.p({src:o.liveImgUrl||e.$img.logo,size:"32"}),d:t.t(o.liveName?n.truncateString(o.liveName,5):"未命名"),e:t.f(n.filteredViewers,(c,l,f)=>({a:l,b:c.avatar||e.$img.logo})),f:t.o((...c)=>n.toggleViewerList&&n.toggleViewerList(...c),o.liveId),g:t.o(c=>n.onLike(o),o.liveId),h:t.t(((T=o.liveViewData)==null?void 0:T.like)||0),i:t.n(o.showType==1?"siderow-group":"side-group"),j:((v=o.redInfo)==null?void 0:v.redStatus)==1},((S=o.redInfo)==null?void 0:S.redStatus)==1?{k:t.o(c=>n.onRed(o),o.liveId),l:d._imports_1$3}:{},r.showPurchasePrompt&&((k=r.orderUser)!=null&&k.count)?{m:d._imports_5,n:t.t(r.orderUser.userName?n.maskString(r.orderUser.userName):""),o:t.t(r.orderUser.count||0)}:{},{p:r.currentSwiperIndex===u&&o.livingUrl},r.currentSwiperIndex===u&&o.livingUrl?{q:"myVideo_"+o.liveId,r:t.n(o.showType==1?"video_row":"videotop"),s:o.livingUrl,t:r.currentSwiperIndex===u,v:t.o((...c)=>n.videoError&&n.videoError(...c),o.liveId)}:{},{w:r.currentSwiperIndex===u&&o.videoUrl},r.currentSwiperIndex===u&&o.videoUrl?{x:t.n(o.showType==1?"video_row":"videotop"),y:o.videoUrl,z:r.currentSwiperIndex===u,A:t.o((...c)=>n.videoError&&n.videoError(...c),o.liveId)}:{},{B:o.videoUrl},o.videoUrl?{C:t.t(o.totalTime)}:{},{D:t.f(o.talklist,(c,l,f)=>({a:t.t(c.msg),b:l,c:c.cmd=="announcement"})),E:t.t(o.messageContent),F:t.f(o.talklist,(c,l,f)=>({a:t.t(c.nickName),b:t.t(c.msg),c:l,d:`list_${l}`,e:c.cmd!="red"&&c.cmd!="out"&&c.cmd!="entry"})),G:o.showWelcomeMessage},o.showWelcomeMessage?{H:t.f(o.talklist,(c,l,f)=>({a:t.t(c.nickName),b:t.t(c.msg),c:l,d:c.cmd=="entry"||c.cmd=="out"})),I:t.t(o.messageContent)}:{},{J:o.scrollIntoView,K:"471975a0-1-"+p,L:t.o(c=>o.value=c,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(c=>n.sendMsg(o),o.liveId),O:t.o(c=>n.openCart(o),o.liveId),P:t.o(c=>o.goodsCard.isShow=!1,o.liveId),Q:o.goodsCard.imgUrl,R:t.t(o.goodsCard.price),S:t.t(o.goodsCard.otPrice),T:t.t(o.goodsCard.productName),U:t.o(c=>n.goShop(o.goodsCard.productId,o.goodsCard.goodsId),o.liveId),V:t.o(c=>!o.goodsCard.isShow,o.liveId),W:"471975a0-2-"+p,X:t.p({show:o.goodsCard.isShow,round:"20rpx",mode:"center",bgColor:"#ffffff"}),Y:t.f(r.liveViewers,(c,l,f)=>({a:t.t(l+1),b:l===0?"#FF3B30":l===1?"#FF9500":l===2?"#FFCC00":"#8E8E93",c:l<3?"bold":"normal",d:"471975a0-4-"+p+"-"+f+","+("471975a0-3-"+p),e:t.p({src:c.avatar||e.$img.logo,size:"32"}),f:t.t(c.nickName||"未命名"),g:l}))},r.viewNoMoreData&&r.liveViewers.length>0?{}:{},{Z:t.o((...c)=>n.handleScrollToLower&&n.handleScrollToLower(...c),o.liveId),aa:t.o(n.close,o.liveId),ab:t.o(n.openViews,o.liveId),ac:"471975a0-3-"+p,ad:"471975a0-6-"+p+","+("471975a0-5-"+p),ae:t.o([c=>o.inputInfo=c.detail.value,(...c)=>n.handleSearchInput&&n.handleSearchInput(...c)],o.liveId),af:o.inputInfo},r.store.isFavorite?{ag:t.o(c=>n.onStoreCollect(o),o.liveId),ah:d._imports_11}:{ai:t.o(c=>n.onStoreCollect(o),o.liveId),aj:d._imports_12},{ak:t.o(c=>n.goOrderList(o),o.liveId),al:t.f(r.products,(c,l,f)=>t.e({a:c.imgUrl,b:t.t(l+1),c:t.t(c.productName),d:t.t(c.sales),e:t.t(Math.trunc(c.price)),f:t.t(n.getPureDecimal(c.price)?n.getPureDecimal(c.price):"00"),g:c.isFavorite},c.isFavorite?{h:t.o(y=>n.onGoodsCollect(c),l),i:d._imports_11}:{j:t.o(y=>n.onGoodsCollect(c),l),k:d._imports_12},{l:c.status==1},c.status==1?{m:t.o(y=>n.goShop(c.productId,c.goodsId),l)}:c.status==0?{}:{},{n:c.status==0,o:l})),am:t.o(n.closeShop,o.liveId),an:t.o(n.openShop,o.liveId),ao:"471975a0-5-"+p,ap:t.p({show:o.shopping,round:"20rpx",bgColor:"f3f5f9"}),aq:r.currentSwiperIndex===u?1:"",ar:o.liveId})}),b:d._imports_0$2,c:t.t(r.liveUserTotal||0),d:d._imports_2,e:d._imports_4,f:r.showPurchasePrompt&&((h=r.orderUser)==null?void 0:h.count),g:d._imports_6,h:d._imports_6$1,i:d._imports_7,j:r.viewNoMoreData&&r.liveViewers.length>0,k:r.scrollHeight+"px",l:t.p({show:r.showadd,round:"20rpx",bgColor:"#ffffff"}),m:t.p({src:r.store.logoUrl,size:"36"}),n:d._imports_1$2,o:r.store.isFavorite,p:d._imports_10,q:r.boxHeight+"px",r:r.currentSwiperIndex,s:t.o((...o)=>n.onSwiperChange&&n.onSwiperChange(...o)),t:r.swiperDuration}}const V=t._export_sfc(m,[["render",b],["__scopeId","data-v-471975a0"]]);m.__runtimeHooks=2;wx.createPage(V);
|