封装提示弹框

This commit is contained in:
fengerli
2025-07-24 10:05:17 +08:00
parent c0a9c0b3f2
commit 51ab4d0bfa
9 changed files with 307 additions and 144 deletions

View File

@ -31,7 +31,7 @@
</view>
</view>
</view>
<view style="padding:20rpx;">
<view class="editInfmation">
<view class="ql-editor">编辑信息</view>
<view class="ql-input">
<textarea placeholder-style="color:rgba(255, 255, 255, 0.4)" placeholder="请输入内容" class="textarea"
@ -39,28 +39,15 @@
</view>
<button class="login-btn" @click="sendTextMessage">发送</button>
</view>
</scroll-view>
<!-- 成功提示弹框 -->
<view class="agreement-mask" v-if="personalShow" @click="closePopup('delete')">
<view class="agreement-popup" @click.stop>
<view class="popup-content">
<image src="/static/images/sendSucc.png" mode="" class="svg"></image>
<uni-icon class="trash"></uni-icon>
<view>
<view class="popup-Title">信息发送成功</view>
</view>
</view>
<!-- 按钮组 -->
<view class="popup-buttons">
<button class="btn agreeBtn" @click="handleBtn">确定</button>
</view>
</view>
</view>
<CustomPopup :show="showPopupFlag" :title="popupTitle" :message="popupMessage" icon="/static/images/sendSucc.png"
:confirm-text="popupConfirmText" :show-cancel="false" @confirm="onPopupConfirm" />
</view>
</template>
<script>
import CustomPopup from '@/components/CustomPopup/CustomPopup.vue'
import {
deviceInfo,
} from '@/api/common/index.js'
@ -68,11 +55,17 @@
deviceSendMessage
} from '@/api/6170/deviceControl.js'
export default {
components: {
CustomPopup
},
data() {
return {
deviceList: [],
messageToSend: '', //发送信息
personalShow: false
showPopupFlag: false,
popupTitle: '',
popupMessage: '信息发送成功!',
popupConfirmText: '确认'
}
},
methods: {
@ -106,6 +99,13 @@
sendTextMessage() {
const selectedDevices = this.deviceList.filter(item => item.checked)
const deviceIds = selectedDevices.map(item => item.id);
if (selectedDevices.length === 0) {
uni.showToast({
title: '请选择一个设备',
icon: 'none'
});
return;
}
if (!this.messageToSend) {
uni.showToast({
title: '请输入要发送的内容',
@ -119,7 +119,7 @@
}
deviceSendMessage(data).then((res) => {
if (res.code == 200) {
this.personalShow = true
this.showPopupFlag = true
} else {
uni.showToast({
title: res.msg,
@ -128,10 +128,12 @@
}
})
},
handleBtn(){
this.personalShow = false
uni.navigateBack()
}
onPopupConfirm() {
this.showPopupFlag = false
uni.navigateBack()
console.log('用户点击了确定')
// 处理确认逻辑
},
},
onLoad(options) {
const eventChannel = this.getOpenerEventChannel();
@ -148,26 +150,17 @@
<style scoped>
.container {
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: rgb(18, 18, 18);
}
box-sizing: border-box;
overflow-x: hidden;
.header {
padding: 30rpx;
text-align: center;
}
.title {
font-size: 36rpx;
color: rgba(255, 255, 255, 0.87);
}
.device-list {
flex: 1;
padding: 0 20rpx;
margin-top: 20rpx;
}
.device-card {
@ -330,6 +323,19 @@
.textarea {
color: rgba(255, 255, 255, 0.8);
background: rgba(42, 42, 42, 1);
border-radius: 16rpx;
padding: 10rpx;
height: 150rpx;
}
.editInfmation {
padding: 20rpx;
border-radius: 40rpx 40rpx 0px 0px;
background: rgba(28, 28, 28, 1);
position: fixed;
bottom: 50rpx;
box-sizing: border-box;
}
.login-btn {
@ -338,65 +344,5 @@
color: rgb(35, 35, 35);
border-radius: 50rpx;
width: 90%;
margin-left: 10rpx;
}
/* 遮罩层 */
.agreement-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}
.popup-Title {
color: rgba(255, 255, 255, 0.86);
text-align: center;
padding: 30rpx 0rpx;
}
.popup-buttons {
display: flex;
text-align: center;
}
/* 弹窗主体 */
.agreement-popup {
width: 60%;
background-color: rgb(42, 42, 42);
border-radius: 40rpx;
padding: 30rpx;
text-align: center;
border: 1px solid rgba(255, 200, 78, 0.3);
}
.svg {
width: 58rpx;
height: 62rpx;
}
/* 通用按钮样式 */
.btn {
height: 60rpx;
line-height: 60rpx;
border-radius: 40rpx;
font-size: 24rpx;
margin: 10rpx auto;
text-align: center;
}
/* 同意按钮 */
.agreeBtn {
background: rgba(187, 230, 0, 1);
color: #232323;
border: none;
width: 170rpx !important;
}
</style>