| <template> | 
|     <div class="password"> | 
|         <div class="password_tip"> | 
|             <img src="@/assets/icon/password_ic_tip@2x.png" alt="" /> | 
|             <span>绑定邮箱号可以更好地保护您的账户安全,保护个人信息不被侵害。</span> | 
|         </div> | 
|         <div class="password_list"> | 
|             <div class="password_list_item"> | 
|                 <span>当前绑定</span> | 
|                 <div class="password_list_item_box"> | 
|                     <input type="text" disabled v-model="form.currentMailbox" /> | 
|                 </div> | 
|             </div> | 
|             <div class="password_list_item"> | 
|                 <span>新邮箱号</span> | 
|                 <div class="password_list_item_box"> | 
|                     <input type="text" v-model="form.newMailbox" placeholder="请输入新的邮箱" /> | 
|                 </div> | 
|             </div> | 
|             <div class="password_list_item"> | 
|                 <span>验证码</span> | 
|                 <div class="password_list_item_box"> | 
|                     <input type="text" v-model="form.verificationCode" maxlength="4" placeholder="请输入验证码"> | 
|                     <p @click="getVerificationCode" v-if="!code.isOpen">获取验证码</p> | 
|                     <p @click="getVerificationCode" v-else>{{code.num}}</p> | 
|                 </div> | 
|             </div> | 
|         </div> | 
|         <div class="password_footer"> | 
|             <button v-preventReClick class="password_footer_submit" @click="submit"> | 
|                 <span>完成</span> | 
|             </button> | 
|         </div> | 
|     </div> | 
| </template> | 
|   | 
| <script setup lang="ts"> | 
|     import { reactive, onBeforeUnmount } from 'vue' | 
|     import { Toast } from 'vant' | 
|     import { useStore } from "vuex" | 
|     import { useRouter } from "vue-router" | 
|     import { REGULAR } from '@/utils/utils' | 
|     import { updateMailboxVerification } from '@/interface' | 
|   | 
|     const router = useRouter() | 
|   | 
|     const store = useStore() | 
|   | 
|     // 表单相关 | 
|     let form = reactive<updateMailboxVerification>({ | 
|         currentMailbox: store.state.userInfo.companyUser.phone, | 
|         newMailbox: '', | 
|         verificationCode: '' | 
|     }) | 
|   | 
|     // 验证码相关 | 
|     let code = reactive<{ num: number, isOpen: boolean, timer: number }>({ | 
|         num: 60, | 
|         isOpen: false, | 
|         timer: 0 | 
|     }) | 
|   | 
|     // 获取验证码 | 
|     const getVerificationCode = (): void => { | 
|         code.isOpen = true | 
|         code.timer = setInterval(() => { | 
|             if (code.num === 0) { | 
|                 clearInterval(code.timer) | 
|                 code.isOpen = false | 
|                 code.num = 60 | 
|             } | 
|             code.num = code.num - 1 | 
|         }, 1000) | 
|     } | 
|   | 
|     const submit = (): void => { | 
|         if (!form.newMailbox) { | 
|             Toast({ message: '新邮箱号不能为空' }) | 
|         } else if (!REGULAR.mailboxRegular.test(form.newMailbox)) { | 
|             Toast({ message: '新邮箱不合法' }) | 
|         } else if (!form.verificationCode) { | 
|             Toast({ message: '验证码不能为空' }) | 
|         } else { | 
|             console.log('可以提交') | 
|         } | 
|     } | 
|   | 
|     onBeforeUnmount(() => { | 
|         clearInterval(code.timer) | 
|     }) | 
| </script> | 
|   | 
| <style lang="scss" scoped> | 
|     .password { | 
|         position: absolute; | 
|         width: 100%; | 
|         height: 100%; | 
|         background: white; | 
|         .password_tip { | 
|             padding: 20px 30px; | 
|             display: flex; | 
|             background: #F7F7F7; | 
|             box-sizing: border-box; | 
|             img { | 
|                 width: 24px; | 
|                 height: 24px; | 
|                 margin-right: 10px; | 
|                 margin-top: 8px; | 
|             } | 
|             span { | 
|                 font-size: 24px; | 
|                 font-weight: 400; | 
|                 color: #666666; | 
|             } | 
|         } | 
|         .password_list { | 
|             padding: 0 30px; | 
|             .password_list_item { | 
|                 display: flex; | 
|                 align-items: center; | 
|                 height: 90px; | 
|                 border-bottom: 1PX solid #E5E5E5; | 
|                 span { | 
|                     width: 150px; | 
|                     flex-shrink: 0; | 
|                     font-size: 30px; | 
|                     font-weight: 400; | 
|                     color: #222222; | 
|                 } | 
|                 .password_list_item_box { | 
|                     display: flex; | 
|                     justify-content: space-between; | 
|                     flex: 1; | 
|                     input { | 
|                         border: none; | 
|                         font-size: 30px; | 
|                     } | 
|                     input::-webkit-input-placeholder { | 
|                         font-size: 28px; | 
|                         font-weight: 400; | 
|                         color: #B2B2B2; | 
|                     } | 
|                     p { | 
|                         font-size: 26px; | 
|                         font-weight: 400; | 
|                         color: $nav-color; | 
|                     } | 
|                 } | 
|             } | 
|         } | 
|         .password_footer { | 
|             margin-top: 80px; | 
|             padding: 0 30px; | 
|             .password_footer_submit { | 
|                 width: 100%; | 
|                 height: 88px; | 
|                 border: none; | 
|                 background: #4275FC; | 
|                 box-shadow: 0 0 12px 0 rgba(0, 0, 0, 0.08); | 
|                 border-radius: 8px; | 
|                 display: flex; | 
|                 align-items: center; | 
|                 justify-content: center; | 
|                 span { | 
|                     font-size: 30px; | 
|                     font-weight: 500; | 
|                     color: #FFFFFF; | 
|                 } | 
|             } | 
|         } | 
|     } | 
| </style> |