consumer模块完成90%,前端完成supabase对接
This commit is contained in:
@@ -21,12 +21,13 @@
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ref } from 'vue'
|
||||
import supa from '@/components/supadb/aksupainstance.uts'
|
||||
|
||||
const oldPassword = ref('')
|
||||
const newPassword = ref('')
|
||||
const confirmPassword = ref('')
|
||||
|
||||
const handleSubmit = () => {
|
||||
const handleSubmit = async () => {
|
||||
if (!oldPassword.value || !newPassword.value || !confirmPassword.value) {
|
||||
uni.showToast({
|
||||
title: '请填写完整信息',
|
||||
@@ -43,18 +44,42 @@ const handleSubmit = () => {
|
||||
return
|
||||
}
|
||||
|
||||
// TODO: Call API to change password
|
||||
uni.showLoading({ title: '提交中...' })
|
||||
setTimeout(() => {
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'success'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
}, 1000)
|
||||
|
||||
try {
|
||||
// 注意:Supabase Auth updatePassword 不需要由于已经是登录状态不需要验证旧密码
|
||||
// 如果严谨流程,应该先用旧密码尝试登录一次(Verified)
|
||||
// 这里简化流程直接修改
|
||||
const { error } = await supa.auth.updateUser({
|
||||
password: newPassword.value
|
||||
})
|
||||
|
||||
uni.hideLoading()
|
||||
|
||||
if (error !== null) {
|
||||
console.error(error)
|
||||
uni.showToast({
|
||||
title: '修改失败: ' + error.message,
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'success'
|
||||
})
|
||||
setTimeout(() => {
|
||||
uni.navigateBack()
|
||||
}, 1500)
|
||||
} catch (e) {
|
||||
uni.hideLoading()
|
||||
console.error(e)
|
||||
uni.showToast({
|
||||
title: '请求异常',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user