|
@@ -0,0 +1,69 @@
|
|
|
|
|
+
|
|
|
|
|
+<template>
|
|
|
|
|
+ <app-view class="g-form">
|
|
|
|
|
+ <template #header>
|
|
|
|
|
+ <app-navbar title="邮箱" />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <Form ref="formRef" class="g-form__container" @submit="onSubmit">
|
|
|
|
|
+ <CellGroup inset>
|
|
|
|
|
+ <Field v-model="formData.email" :rules="formRules.email" name="email" label="邮箱"
|
|
|
|
|
+ placeholder="必填" />
|
|
|
|
|
+ </CellGroup>
|
|
|
|
|
+ </Form>
|
|
|
|
|
+ <template #footer>
|
|
|
|
|
+ <div class="g-form__footer inset">
|
|
|
|
|
+ <Button round block type="danger" @click="formRef?.submit">确定</Button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </app-view>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script lang="ts" setup>
|
|
|
|
|
+import { shallowRef, reactive } from 'vue'
|
|
|
|
|
+import { Form, Field, FormInstance, CellGroup, FieldRule, Button, showFailToast } from 'vant'
|
|
|
|
|
+import { updateUserInfoWechatAndEmail } from '@/services/api/user'
|
|
|
|
|
+import { useLoginStore, useUserStore } from '@/stores'
|
|
|
|
|
+import { useNavigation } from '@mobile/router/navigation'
|
|
|
|
|
+import { fullloading } from '@/utils/vant'
|
|
|
|
|
+import { validateRules } from '@/constants/regex'
|
|
|
|
|
+import { decryptAES } from '@/services/websocket/package/crypto'
|
|
|
|
|
+
|
|
|
|
|
+// formRef
|
|
|
|
|
+const formRef = shallowRef<FormInstance>()
|
|
|
|
|
+// loginStore
|
|
|
|
|
+const loginStore = useLoginStore()
|
|
|
|
|
+// userStore
|
|
|
|
|
+const userStore = useUserStore()
|
|
|
|
|
+// router
|
|
|
|
|
+const { router } = useNavigation()
|
|
|
|
|
+
|
|
|
|
|
+const formData = reactive<Model.UserInfoWechatAndEmailReq>({
|
|
|
|
|
+ userid: loginStore.userId, // 用户ID
|
|
|
|
|
+ email: decryptAES(userStore.userInfo.email), // 邮箱
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+// 表单验证规则
|
|
|
|
|
+const formRules: { [key in keyof Model.UserInfoWechatAndEmailReq]?: FieldRule[] } = {
|
|
|
|
|
+ email: [{
|
|
|
|
|
+ validator: (val) => {
|
|
|
|
|
+ if (validateRules.email.validate(val)) {
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+ return validateRules.email.message
|
|
|
|
|
+ }
|
|
|
|
|
+ }],
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const onSubmit = () => {
|
|
|
|
|
+ fullloading((hideLoading) => {
|
|
|
|
|
+ updateUserInfoWechatAndEmail({
|
|
|
|
|
+ data: formData
|
|
|
|
|
+ }).then(() => {
|
|
|
|
|
+ hideLoading()
|
|
|
|
|
+ router.back()
|
|
|
|
|
+ }).catch((err) => {
|
|
|
|
|
+ showFailToast(err)
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+</script>
|