jiuyiUniapp/jiuyi2/pages/login/lostAccount.vue

116 lines
2.0 KiB
Vue

<script setup>
/**
* 账号挂失
*/
import {
ref,
reactive,
computed,
} from 'vue'
// api
import api from '@/api/index'
// 工具库
import util from '@/common/js/util.js'
import {
useStore
} from 'vuex'
// vuex
const store = useStore()
// 表单
const form = reactive({
// 手机号
phoneNumber: '',
// 真实姓名
userRealName: '',
})
// 用户信息
const userinfo = computed(() => store.state.user.userinfo)
// 登录
function handleLogin() {
const data = {
...form
}
// 校验
if (!data.phoneNumber) {
util.alert('请输入手机号')
return
}
if (!data.userRealName) {
util.alert('请输入真实姓名')
return
}
//
api.mine.lostAccount({
data,
}).then(rs => {
if (rs.code == 200) {
if (data.phoneNumber == userinfo.value.phoneNumber) {
api.login.logout({
query: {
phoneNumber: userinfo.phoneNumber,
}
}).then(rs => {})
// 退出登录
util.logout(() => {
// checkLink('pages/login/loginPhone', 'reLaunch')
// #ifdef APP
plus.runtime.restart()
// #endif
})
}
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
</script>
<template>
<view class="appbw">
<view class="container">
<view class="logo mauto">
<image class="logo br10" src="/static/logo.png" mode="aspectFit" />
</view>
<view class="form mt60 mlr60 mb30">
<view class="title mtb30">账号挂失</view>
<view class="inputBox mtb20 ptb10 plr30">
<input type="text" v-model="form.phoneNumber" placeholder="请输入手机号" />
</view>
<view class="inputBox rows mtb20 ptb10 plr30">
<input v-model="form.userRealName" placeholder="请输入真实姓名" />
</view>
<view class="btn lg bar black mtb60" @click="handleLogin">挂失</view>
</view>
</view>
</view>
</template>
<style lang="scss">
.image {
width: 100%;
height: 100%;
}
//
.container {
margin-top: 15vh;
// 标志
.logo {
width: 200rpx;
height: 200rpx;
}
}
</style>