| | |
| | | { |
| | | layout: 'default', |
| | | style: { |
| | | navigationStyle: 'custom', |
| | | navigationBarTitleText: '登录', |
| | | }, |
| | | } |
| | | </route> |
| | | |
| | | <template> |
| | | <wd-img class="w-full h-[260rpx]" src="/static/images/pic2.jpg" /> |
| | | <wd-form ref="form" :model="model" class="mt-2"> |
| | | <wd-cell-group border> |
| | | <wd-input |
| | | label="用户名" |
| | | label-width="100px" |
| | | prop="username" |
| | | clearable |
| | | v-model="model.username" |
| | | placeholder="请输入用户名" |
| | | :rules="[{ required: true, message: '请填写用户名' }]" |
| | | /> |
| | | <wd-input |
| | | label="密码" |
| | | label-width="100px" |
| | | prop="password" |
| | | show-password |
| | | clearable |
| | | v-model="model.password" |
| | | placeholder="请输入密码" |
| | | :rules="[{ required: true, message: '请填写密码' }]" |
| | | /> |
| | | </wd-cell-group> |
| | | <view class="footer mt-6"> |
| | | <wd-button type="primary" size="large" @click="handleSubmit" block>提交</wd-button> |
| | | </view> |
| | | </wd-form> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { currRoute } from '@/utils' |
| | | import { useUserStore, useAccessStore } from '@/store' |
| | | import { useToast } from 'wot-design-uni' |
| | | import { login } from '@/service/login' |
| | | const userStore = useUserStore() |
| | | const accessStore = useAccessStore() |
| | | const { success: showSuccess } = useToast() |
| | | |
| | | const model = reactive<{ |
| | | username: string |
| | | password: string |
| | | }>({ |
| | | username: 'admin', |
| | | password: 'admin123', |
| | | }) |
| | | |
| | | const form = ref() |
| | | function handleSubmit() { |
| | | form.value |
| | | .validate() |
| | | .then(({ valid, errors }) => { |
| | | if (valid) { |
| | | toLogin() |
| | | } |
| | | }) |
| | | .catch((error) => { |
| | | console.log(error, 'error') |
| | | }) |
| | | } |
| | | const toLogin = async () => { |
| | | const res = await login(model) |
| | | console.error(res) |
| | | accessStore.setAccessInfo(res as any) |
| | | console.error(accessStore.accessInfo.access_token) |
| | | // userStore.setUserInfo({ nickname: '菲鸽', avatar: '', token: 'abcdef' }) |
| | | const { query } = currRoute() |
| | | console.error(query.redirect) |
| | | uni.switchTab({ url: query.redirect }) |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | </script> |
| | | |
| | | <template> |
| | | |
| | | </template> |
| | | |
| | | <style scoped lang="scss"> |
| | | |
| | | .footer { |
| | | padding: 12px; |
| | | } |
| | | </style> |