jiuyiUniapp/jiuyi2/pages/login/lock.vue

111 lines
1.9 KiB
Vue
Raw Normal View History

2024-12-29 19:06:34 +08:00
<script setup>
// 锁住app
// 工具库
import util from '@/common/js/util.js'
//
import {
computed,
reactive,
} from 'vue'
import {
useStore
} from 'vuex'
// api
import api from '@/api/index.js'
// 加密
import CryptoJS from 'crypto-js';
const store = useStore()
//
const form = reactive({})
// 用户信息
const userinfo = computed(() => {
let result = store.state.userinfo
return result
})
// 提交
function handleSubmit() {
const data = {
...form
}
//
if (!data.userPassword) {
util.alert('验证密码不能为空')
return
}
// 手机号
data.userPhone = userinfo.value.userPhone
// md5加密
data.userPassword = CryptoJS.MD5(data.userPassword).toString();
api.login.validateUserPassWord({
data,
}).then(rs => {
if (rs.code === 200) {
// 更新用户信息解除青少年模式
unLockTeenMode()
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
// 解除青少年模式
function unLockTeenMode() {
api.mine.updateUserInfo({
data: {
userId: userinfo.value.userId,
youth: '0',
}
}).then(rs => {
if (rs.code == 200) {
// uni.navigateBack()
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
</script>
<template>
<view class="container pr fmid fdc">
<view class="title f40 b">输入登录密码解锁未成年模式</view>
<view class="account mtb20 c666 f32">当前账号: {{userinfo.userPhone}}</view>
<view class="password mtb30 br20">
<input class="input" type="text" v-model="form.userPassword" placeholder="登录密码" />
</view>
<view class="button btn lg bar black mt60" @click="handleSubmit">解锁</view>
</view>
</template>
<style lang="scss" scoped>
//
.container {
width: 100vw;
height: 100vh;
// 密码
.password {
width: 80%;
background-color: #eee;
//
.input {
padding: 20rpx 20rpx;
}
}
.button {
width: 80%;
}
}
</style>