封装提示弹框

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

@ -83,7 +83,6 @@
<image src="/static/images/jg.png" class="setIMG"></image>
<view>
<view class="battery-v2">激光模式</view>
<!--<view class="mode-v3">{{currentSecondaryMode}}</view> -->
</view>
</view>
</view>
@ -103,7 +102,6 @@
<view class="form-section" v-if="hasPermission('4')">
<view class="mode-buttons">
<view class="section-title">人员信息登记</view>
<!-- <button class="send-btn">发送</button> -->
<view class="right-icons">
<uni-icons @click="toggleForm" :type="isFormExpanded ? 'arrowup' : 'down'" size="20"
color="rgba(255, 255, 255, 0.87" class="toggle-icon" />
@ -161,7 +159,7 @@
</view>
<!-- 弹框 -->
<view class="agreement-mask" v-if="lightModeA">
<!-- 协议弹窗 -->
<!-- 灯光模式弹窗 -->
<view class="agreement-popup" @click.stop>
<!-- 标题 -->
<view class="popup-title"> {{ popupTitle }}</view>
@ -218,6 +216,10 @@
</view>
</view>
</view>
<!-- 人员信息成功提示弹框 -->
<CustomPopup :show="showPopupFlag" :message="popupMessage"
icon="/static/images/sendSucc.png" :confirm-text="popupConfirmText" :show-cancel="false"
@confirm="onPopupConfirm" />
</view>
</view>
</template>
@ -245,7 +247,6 @@
sliderValue: 50,
lightModeA: false,
currentMainMode: '强光模式',
currentSecondaryMode: '泛光模式',
lightModeB: false,
lightModeC: false, //激光提示框
items: [],
@ -270,7 +271,12 @@
},
activePermissions: [], // 存储当前设备的权限数组
isSharedDevice: false, // 标记是否来自分享
isRightIconVisible: false
isRightIconVisible: false,
showPopupFlag: false, //是否显示弹框
popupMessage: '',
popupConfirmText: '确认',
showUploadPopup:false
}
},
computed: {
@ -321,16 +327,18 @@
onItemClick(index) {
const selectedItem = this.items[index];
if (selectedItem.text === '激光') {
this.lightModeC = true
this.selectedItemIndex = index; // 记录当前选择的索引
this.lightModeC = true;
} else {
// 更新选中状态
this.items = this.items.map((item, i) => ({
...item,
selected: i === index
}));
// 记录当前选中的 index但不发送
this.currentMainMode = selectedItem.text;
this.selectedItemIndex = index;
console.log(selectedItem.text, 'selectedItem.text');
// 强制更新视图(如果需要)
this.$forceUpdate();
}
},
// 灯光模式的确认
@ -338,6 +346,9 @@
if (this.selectedItemIndex === null) return;
const selectedItem = this.items[this.selectedItemIndex];
const instruction = this.modeInstructions[selectedItem.text];
console.log(selectedItem, 'selectedItemselectedItem');
this.selectedItemIndex = selectedItem.text;
if (instruction) {
const topic = `B/${this.itemInfo.deviceImei}`;
const message = JSON.stringify(instruction);
@ -456,10 +467,8 @@
registerPersonInfo(data).then((res) => {
if (res.code == 200) {
uni.hideLoading()
uni.showToast({
title: res.msg,
icon: 'none'
});
this.showPopupFlag = true
this.popupMessage = '人员信息发送成功'
} else {
uni.showToast({
title: res.msg,
@ -468,6 +477,10 @@
}
})
},
onPopupConfirm() {
this.showPopupFlag = false
console.log('用户点击了确定')
},
// 发送文本消息
sendTextMessage() {
if (!this.messageToSend) {
@ -488,10 +501,8 @@
deviceSendMessage(data).then((res) => {
if (res.code == 200) {
uni.hideLoading()
uni.showToast({
title: res.msg,
icon: 'none'
});
this.showPopupFlag = true
this.popupMessage = '发送信息成功'
} else {
uni.showToast({
title: res.msg,
@ -529,7 +540,7 @@
}
this.messageToSend = res.data.sendMsg || ''
// 关闭加载中
uni.hideLoading()
uni.hideLoading()
}
},
// 检查权限的方法
@ -627,6 +638,7 @@
align-items: center;
z-index: 9999;
}
/* 优化权限控制区域的显示 */
.mode-section,
.form-section {
@ -972,7 +984,7 @@
/* 弹窗主体 */
.agreement-popup {
width: 100%;
height: 50%;
height: 40%;
background-color: rgb(42, 42, 42);
border-radius: 60rpx 60rpx 0rpx 0rpx;
padding: 40rpx;