Files
tk-mini-program/pages/pkDetail/pkDetail.vue
pengxiaolong 8ec7365e7c 优化页面
2025-06-16 22:09:12 +08:00

615 lines
15 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="container">
<view class="background">
<image
style="width: 100%; height: 100%"
src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/HomeBackground.png"
mode="scaleToFill"
/>
</view>
<view class="Navigation">
<view class="Return" @click="Returnfunc">
<image
class="Return"
src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Return.png"
mode="scaleToFill"
/>
</view>
</view>
<view class="Content">
<view class="sender">
<view class="sengderIcon">
<image class="Icon" :src="item.anchorIcon" mode="scaleToFill" />
</view>
<view class="Individual">
<view class="name">{{ item.disPlayId }}</view>
<view class="GenderAndAge">
<view class="male" v-if="item.sex === '1'">
<view>
<image
style="width: 20rpx; height: 20rpx"
src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/male.png"
mode="scaleToFill"
/>
</view>
<view class="age"></view>
</view>
<view class="female" v-else>
<view>
<image
style="width: 20rpx; height: 20rpx"
src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/female.png"
mode="scaleToFill"
/>
</view>
<view class="age"></view>
</view>
</view>
<view class="nation">{{ item.country }}</view>
</view>
<view class="Time">PK时间:{{ formatDate(item.pkTime) }}</view>
<view class="SessionAndGoldCoin">
<view class="goldCoin">
<image
style="width: 72rpx; height: 72rpx; margin-left: 36rpx; margin-right: 32rpx"
src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/gold.png"
mode="scaleToFill"
/>
<view class="goldcard">
<view class="goldnumber">{{ item.coin }}K</view>
<view class="goldtext">金币</view>
</view>
</view>
<view class="Session">
<image
style="width: 72rpx; height: 72rpx; margin-left: 36rpx; margin-right: 32rpx"
src="https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/session.png"
mode="scaleToFill"
/>
<view class="goldcard">
<view class="goldnumber">{{ item.pkNumber }}</view>
<view class="goldtext">PK场数</view>
</view>
</view>
</view>
</view>
<view class="remark">
<uni-easyinput
type="textarea"
v-model="item.remark"
placeholder="备注"
maxlength="-1"
disabled="true"
:style="style"
></uni-easyinput>
</view>
<view class="button" v-if="item.senderId !== id">
<button class="accept" @click="openChat()">聊了个天</button>
<button class="reject" @click="open()">立即邀请</button>
</view>
</view>
</view>
<!-- 弹窗 -->
<uni-popup ref="popup" type="center" border-radius="10px 10px 0 0">
<view class="popup-content">
<view class="popup-title">
<view class="popup-text">请选择您要参与的主播</view>
<view v-if="list.length !== 0">
<scroll-view show-scrollbar="false" scroll-y="true" class="scroll">
<view class="card" v-for="(item, index) in list" :key="index">
<view
class="card-content"
@click="Select(item.id, index)"
:style="{
background: selectedId === item.id ? '#f6f6f6' : '#ffffff',
}"
>
<view class="Avatarimg">
<image class="avatar" :src="item.anchorIcon" mode="scaleToFill" />
</view>
<view class="NameMoney">
<view class="TimeMoney">
<view class="NameMoney_Name">{{ item.anchorId }}</view>
</view>
<view class="TimeMoney_Time">
<view class="pkTimeimg"></view
><view>{{ TimeFormatting(item.pkTime) }}</view>
<viewm class="goldnb"
><view class="goldimg"></view>{{ item.coin }}K</viewm
>
</view>
</view>
</view>
</view>
</scroll-view>
</view>
<view class="noData" v-if="list.length === 0">您还没有可参与的主播PK快去新建一个吧</view>
</view>
<view class="popup-btn">
<button class="invite" type="primary" @click="invite()">邀请</button>
<button class="cancel" type="default" @click="close()">取消</button>
</view>
</view>
</uni-popup>
<NewAddedPk class="createModule" ref="createModule"></NewAddedPk>
<!-- <Recompose ref="createModule" class="createModule" :message="parentMessage"></Recompose> -->
</template>
<script>
import formatDate from "../../components/formatDate.js";
import TimeFormatting from "../../components/TimeFormatting.js";
import NewAddedPk from "../../pages/NewAddedPk/NewAddedPk.vue";
import request from "../../components/request.js";
// import Recompose from "../Mine/minecomponents/recompose/recompose.vue";
import TUIChatEngine, {
TUIStore,
StoreName,
TUIChatService,
} from "@tencentcloud/chat-uikit-engine";
export default {
data() {
return {
item: {},
id: 0,
InvitingPartyEventID: null,
list: [],
selectedId: null,
InvitingPartyEventindex: null,
chatInfo: {},
currentConversation: null,
// parentMessage: null,
style: {
backgroundColor: "#ffffff",
},
};
},
onLoad(options) {
// 获取源页面的eventChannel对象
const eventChannel = this.getOpenerEventChannel();
// 监听itemDetail事件
eventChannel.on("itemDetail", (data) => {
this.item = data.item; // 将接收到的数据赋值给item
console.log("接收到的数据:", this.item);
});
uni.getStorage({
key: "userinfo",
success: (res) => {
this.id = res.data.id;
},
});
uni.getStorage({
key: "chatInfo",
success: (res) => {
this.chatInfo = res.data;
},
});
},
methods: {
//修改信息
// onRecompose(item) {
// this.parentMessage = item;
// this.createModule.open();
// },
formatDate: formatDate,
TimeFormatting: TimeFormatting,
Select(id, index) {
if (this.selectedId === id) {
this.selectedId = null;
this.InvitingPartyEventID = null;
this.InvitingPartyEventindex = null;
} else {
this.selectedId = this.selectedId === id ? null : id;
this.InvitingPartyEventID = id;
this.InvitingPartyEventindex = index;
}
},
Returnfunc() {
uni.navigateBack({
delta: 1,
});
},
open() {
this.$refs.popup.open("center");
this.userlist();
},
invite() {
if (this.item.pkTime !== this.list[this.InvitingPartyEventindex].pkTime) {
uni.showToast({
icon: "none",
title: "请保持时间一致",
});
return;
}
// 发送邀请消息
const conversationID = `C2C${this.item.senderId}`;
const myitem = JSON.stringify(this.list[this.InvitingPartyEventindex]);
const youritem = JSON.stringify(this.item);
uni.redirectTo({
url: `/TUIKit/components/TUIChat/index?conversationID=${conversationID}&myitem=${myitem}&youritem=${youritem}`,
});
/////////
},
close() {
this.$refs.popup.close();
},
openChat() {
// 打开聊天页面
const conversationID = `C2C${this.item.senderId}`;
uni.redirectTo({
url: `/TUIKit/components/TUIChat/index?conversationID=${conversationID}`,
});
},
async userlist() {
uni.showLoading({
title: "加载中...",
mask: true,
});
const res = await request({
url: "pk/queryMyCanUsePkData",
method: "POST",
data: {
userId: this.id,
},
userInfo: true,
});
if (res.code === 200) {
if (res.data.length !== 0) {
uni.hideLoading();
console.log("res.data", res.data);
this.list = res.data;
} else {
uni.hideLoading();
setTimeout(() => {
this.openPopupQuantity();
this.$refs.popup.close();
}, 2000);
}
} else {
uni.hideLoading();
uni.showToast({
title: "加载失败",
icon: "none",
duration: 2000,
});
}
},
openPopupQuantity() {
this.$refs.createModule.open();
},
},
components: {
NewAddedPk,
},
};
</script>
<style scoped>
.popup-content {
width: 600rpx;
height: 700rpx;
background-repeat: no-repeat;
border-radius: 10px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
background-image: url(https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/chard1.png);
background-position: center;
}
.popup-title {
font-size: 30rpx;
margin-top: 50rpx;
text-align: center;
}
.popup-btn {
display: flex;
justify-content: space-around;
margin-top: 50rpx;
}
.invite {
width: 225.19rpx;
height: 78.24rpx;
font-size: 28.63rpx;
line-height: 80rpx;
border-top-left-radius: 50rpx;
border-bottom-left-radius: 50rpx;
border-bottom-right-radius: 50rpx;
background-image: linear-gradient(135deg, #4fcacd, #5fdbde);
}
.cancel {
width: 225.19rpx;
height: 78.24rpx;
font-size: 28.63rpx;
line-height: 80rpx;
margin-left: 30rpx;
color: #03aba8;
border-top-left-radius: 50rpx;
border-bottom-left-radius: 50rpx;
border-bottom-right-radius: 50rpx;
border: 1rpx solid #03aba8;
}
.scroll {
width: 500rpx;
height: 400rpx;
border-radius: 10px;
/* background-color: #fff; */
}
.popup-text {
color: #161616;
font-size: 36.26rpx;
font-weight: bold;
margin-bottom: 30rpx;
}
.card-content {
/* width: 445rpx; */
width: 100%;
height: 100rpx;
background-color: #ffffff;
/* border: 2px solid #afafaf; */
border-radius: 10rpx;
display: flex;
align-items: center;
font-size: 28rpx;
color: rgb(127, 127, 127);
}
.createModule {
position: fixed;
bottom: 0;
right: 0;
z-index: 998;
width: 100vw;
}
.Avatarimg {
width: 90rpx;
height: 90rpx;
border-radius: 50%;
background-color: #dddddd;
margin-right: 20rpx;
margin-left: 20rpx;
}
.avatar {
width: 100%;
height: 100%;
border-radius: 50%;
}
.TimeMoney {
width: 300rpx;
display: flex;
font-weight: bold;
font-size: 27rpx;
color: #161616;
}
.goldnb {
display: flex;
margin-left: 40rpx;
}
.TimeMoney_Time {
display: flex;
margin-top: 13rpx;
}
.pkTimeimg {
background-image: url(https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/time.png);
background-size: 100% 100%;
width: 31.49rpx;
height: 31.49rpx;
margin-right: 20rpx;
}
.goldimg {
background-image: url(https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/species.png);
background-size: 100% 100%;
width: 31.49rpx;
height: 35rpx;
}
.NameMoney {
display: flex;
flex-direction: column;
}
.NameMoney_Name {
width: 400rpx;
text-align: left;
font-weight: bold;
font-size: 27rpx;
color: #161616;
white-space: nowrap; /* 防止换行 */
overflow: hidden; /* 隐藏溢出内容 */
text-overflow: ellipsis; /* 显示省略号 */
}
.background {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: -1;
}
.Navigation {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 200rpx;
display: flex;
align-items: center;
padding: 0 60rpx;
z-index: 1;
}
.Return {
width: 60rpx;
height: 60rpx;
margin-top: 20rpx;
}
.Content {
position: absolute;
top: 200rpx;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
align-items: center;
}
.sender {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
margin-top: 80rpx;
}
.sengderIcon {
width: 150rpx;
height: 150rpx;
border-radius: 50%;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
}
.Icon {
width: 100%;
height: 100%;
border-radius: 50%;
}
.Individual {
display: flex;
justify-content: center;
align-items: center;
margin-top: 34.35rpx;
}
.name {
font-size: 30.53rpx;
color: #161616;
margin-right: 16.22rpx;
}
.nation {
/* width: 56.3rpx; */
height: 29.58rpx;
white-space: nowrap; /* 防止换行 */
overflow: hidden; /* 隐藏溢出内容 */
text-overflow: ellipsis; /* 显示省略号 */
font-size: 17.18rpx;
color: #666666;
text-align: center;
line-height: 29.58rpx;
background-color: #fff;
border-radius: 50rpx;
padding: 6rpx 12rpx;
display: flex;
justify-content: center;
align-items: center;
}
.male {
width: 56.3rpx;
height: 29.58rpx;
background-color: #5bced1;
border-radius: 50rpx;
display: flex;
justify-content: center;
align-items: center;
padding: 6rpx 12rpx;
margin-right: 12rpx;
}
.female {
width: 56.3rpx;
height: 29.58rpx;
background-color: #f3876f;
border-radius: 50rpx;
display: flex;
justify-content: center;
align-items: center;
padding: 6rpx 12rpx;
margin-right: 12rpx;
}
.age {
font-size: 17.18rpx;
color: #fff;
margin-left: 4rpx;
}
.Time {
color: #666666;
font-size: 26.72rpx;
margin-top: 48.7rpx;
}
.goldCoin {
background-image: url("https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Backgroundofgoldcoins.png");
width: 334.83rpx;
height: 124.05rpx;
margin-right: 21rpx;
display: flex;
align-items: center;
}
.Session {
background-image: url("https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Fieldnumberbackground.png");
width: 334.83rpx;
height: 124.05rpx;
display: flex;
align-items: center;
}
.SessionAndGoldCoin {
display: flex;
justify-content: center;
align-items: center;
margin-top: 60rpx;
display: flex;
justify-content: center;
}
.goldtext {
font-size: 28.63rpx;
color: #929292;
}
.goldnumber {
font-size: 34.35rpx;
color: #161616;
font-weight: bold;
}
.goldcard {
display: flex;
flex-direction: column;
align-items: center;
}
.remark {
margin-top: 60rpx;
width: 90%;
}
.button {
display: flex;
justify-content: center;
align-items: center;
margin-top: 500rpx;
}
.accept {
width: 325.38rpx;
height: 77.29rpx;
margin-right: 35.5rpx;
border-radius: 50rpx;
background-color: #fff;
border: 1rpx solid #03aba8;
color: #03aba8;
font-size: 28.63rpx;
line-height: 77.29rpx;
}
.reject {
width: 325.38rpx;
height: 77.29rpx;
border-radius: 50rpx;
background-color: #03aba8;
border: 1rpx solid #03aba8;
color: #fff;
font-size: 28.63rpx;
line-height: 77.29rpx;
}
.noData{
width: 500rpx;
height: 400rpx;
border-radius: 10px;
font-size: 30rpx;
color: #999;
}
</style>