From d470e67ac1997882502b75cbfdaf359626cfaaa8 Mon Sep 17 00:00:00 2001
From: Liuyi <candymxq888@outlook.com>
Date: 星期五, 20 十二月 2024 17:27:07 +0800
Subject: [PATCH] 测试修复小程序问题,添加水控机设备

---
 pagesAdmin/adminPlatform/home.vue |   98 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 95 insertions(+), 3 deletions(-)

diff --git a/pagesAdmin/adminPlatform/home.vue b/pagesAdmin/adminPlatform/home.vue
index e7f4ef2..17d2200 100644
--- a/pagesAdmin/adminPlatform/home.vue
+++ b/pagesAdmin/adminPlatform/home.vue
@@ -1,5 +1,5 @@
 <script setup>
-	import { adminDetailApi,getRunStateApi,getTotalRevenueApi,getWaterConsumptionApi} from '../../api/index.js'
+	import { adminDetailApi,getRunStateApi,getTotalRevenueApi,getWaterConsumptionApi,changePasswordApi} from '../../api/index.js'
 	import { onMounted,ref } from 'vue'
 	import { onShow } from '@dcloudio/uni-app'
 	const echarts = require('../../static/echarts.min.js')
@@ -337,6 +337,46 @@
 			chart.setOption(flowOption)
 		})
 	}
+	//修改密码
+	const popup = ref()
+	const rules = ref({
+		newPassword: {
+			rules:[{required: true, errorMessage:'请输入', trigger: "blur"}],
+		},
+		oldPassword: {
+			rules:[{required: true, errorMessage:'请输入', trigger: "blur"}],
+		},
+	})
+	const pwdFormRef =ref()
+	const pwdForm = ref({
+		oldPassword:'',
+		newPassword:'',
+	})
+	function editPwd(){
+		popup.value.open()
+	}
+	function concel(){
+		pwdForm.value = {}
+		pwdFormRef.value.clearValidate()
+		popup.value.close()
+	}
+	async function confirmEdit(){
+		pwdFormRef.value.validate().then(async(validate)=>{
+			let res = await changePasswordApi(pwdForm.value)
+			if(res.code === 200){
+				uni.showToast({
+					title:'修改成功'
+				})
+				concel()
+			}else{
+				uni.showToast({
+					title:'修改失败'
+				})
+				concel()
+			}
+		}).catch((err)=>{})
+	}
+	//退登
 	function loginOut(){
 		wx.showModal({
 		  title: '提示',
@@ -383,7 +423,7 @@
 					</view>
 				</view>
 				<view class="edit">
-					<view class="edit-text1">修改密码</view>
+					<view class="edit-text1" @click="editPwd">修改密码</view>
 					<view class="edit-text2" @click="loginOut">退出登录</view>
 				</view>
 			</view>
@@ -436,8 +476,26 @@
 				<view class="charts3">
 					<l-echart ref="flowEcharts"></l-echart>
 				</view>
-			</view>
+			</view> 
 		</view>
+		<uni-popup ref="popup" :is-mask-click ='false' type="center" border-radius="20px">
+			<view class="dialog-box">
+				<view>
+					<uni-forms ref="pwdFormRef" :model="pwdForm" :rules="rules">
+						<uni-forms-item label="旧密码:" name='oldPassword'>
+							<uni-easyinput class="input" v-model="pwdForm.oldPassword" placeholder="请输入旧密码">></uni-easyinput> 
+						</uni-forms-item>
+						<uni-forms-item label="新密码:" name="newPassword">
+							<uni-easyinput class="input" v-model="pwdForm.newPassword" placeholder="请输入新密码">></uni-easyinput> 
+						</uni-forms-item>
+					</uni-forms>
+				</view>
+				<view class="button-box">
+					<button class="btn1" @click="concel">取消</button>
+					<button class="btn2" @click="confirmEdit">确认</button>
+				</view>
+			</view>
+		</uni-popup>
 	</view>
 </template>
 
@@ -618,5 +676,39 @@
 					}
 				}
 		}
+		.dialog-box{
+			width:600rpx;
+			height:500rpx;
+			background: #fafbfc;
+			padding:40rpx;
+			box-sizing: border-box;
+			display: flex;
+			justify-content:center;
+			flex-direction: column;
+			border-radius:20rpx;
+			.input{
+				align-items: center;
+			}
+			.button-box{
+				width:100%;
+				display: flex;
+				justify-content: center;
+				align-items: center;
+				.btn1{
+					line-height:60rpx;
+					width:180rpx;
+					height:60rpx;
+					background: #fcfcfc;
+					color: #505354;
+				}
+				.btn2{
+					line-height:60rpx;
+					width:180rpx;
+					height:60rpx;
+					background: #b7cafc;
+					color: #484b4c;
+				}
+			}
+		}
 	}       
 </style>

--
Gitblit v1.9.3