wui-components-v2 1.2.22 → 1.2.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { defineOptions, defineProps, reactive, ref } from 'vue'
|
|
2
|
+
import { defineEmits, defineOptions, defineProps, reactive, ref } from 'vue'
|
|
3
3
|
import { useRouter } from 'uni-mini-router'
|
|
4
4
|
import { useGlobalToast } from '../../composables/useGlobalToast'
|
|
5
5
|
import { getUserConfig, login } from '../../api/login'
|
|
6
6
|
import { useUser } from '../../composables/useUser'
|
|
7
7
|
import { useTabbar } from '../../composables/useTabbar'
|
|
8
8
|
import type { TabbarItem } from '../../composables/useTabbar'
|
|
9
|
+
import type { UserInfo } from '../../composables/types/user'
|
|
9
10
|
|
|
10
11
|
defineOptions({
|
|
11
12
|
name: 'LoginForm',
|
|
12
13
|
})
|
|
13
14
|
|
|
14
15
|
const props = defineProps<Props>()
|
|
16
|
+
|
|
17
|
+
// 登录成功回调,向父级抛出用户信息
|
|
18
|
+
const emit = defineEmits<{
|
|
19
|
+
'login-success': [user: UserInfo]
|
|
20
|
+
}>()
|
|
15
21
|
// 定义 Props 类型
|
|
16
22
|
interface Props {
|
|
17
23
|
tabbarItems: TabbarItem[]
|
|
@@ -52,6 +58,8 @@ function handleSubmit() {
|
|
|
52
58
|
if (res1.status === 'success') {
|
|
53
59
|
// 保存用户信息
|
|
54
60
|
setUserInfo(res1.user)
|
|
61
|
+
// 抛出登录成功事件(携带用户信息)
|
|
62
|
+
emit('login-success', res1.user)
|
|
55
63
|
|
|
56
64
|
// 记住账号密码
|
|
57
65
|
if (model.remember) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { defineOptions, defineProps, ref } from 'vue'
|
|
2
|
+
import { defineEmits, defineOptions, defineProps, ref } from 'vue'
|
|
3
3
|
import { useRouter } from 'uni-mini-router'
|
|
4
4
|
import type { TabbarItem } from '../../composables/useTabbar'
|
|
5
|
+
import type { UserInfo } from '../../composables/types/user'
|
|
5
6
|
import loginForm from '../login-form/login-form.vue'
|
|
6
7
|
import phoneLoginForm from '../phone-login-form/phone-login-form.vue'
|
|
7
8
|
|
|
@@ -19,6 +20,16 @@ interface Props {
|
|
|
19
20
|
}
|
|
20
21
|
const router = useRouter()
|
|
21
22
|
|
|
23
|
+
// 登录成功回调,向父级抛出用户信息
|
|
24
|
+
const emit = defineEmits<{
|
|
25
|
+
'login-success': [user: UserInfo]
|
|
26
|
+
}>()
|
|
27
|
+
|
|
28
|
+
// 透传子组件登录成功事件
|
|
29
|
+
function onLoginSuccess(user: UserInfo) {
|
|
30
|
+
emit('login-success', user)
|
|
31
|
+
}
|
|
32
|
+
|
|
22
33
|
// 登录模式
|
|
23
34
|
const loginMode = ref('account')
|
|
24
35
|
|
|
@@ -41,9 +52,10 @@ function changeLoginMode(mode: string) {
|
|
|
41
52
|
:tabbar-items="props.tabbarItems"
|
|
42
53
|
:url="props.url"
|
|
43
54
|
:gurl="props.gurl"
|
|
55
|
+
@login-success="onLoginSuccess"
|
|
44
56
|
/>
|
|
45
57
|
<!-- //账号登录 -->
|
|
46
|
-
<loginForm v-if="loginMode === 'account'" :tabbar-items="props.tabbarItems" />
|
|
58
|
+
<loginForm v-if="loginMode === 'account'" :tabbar-items="props.tabbarItems" @login-success="onLoginSuccess" />
|
|
47
59
|
|
|
48
60
|
<view v-if="props.gurl" class="pa-3 pt-0">
|
|
49
61
|
<wd-divider>或</wd-divider>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { defineOptions, defineProps, onUnmounted, reactive, ref } from 'vue'
|
|
2
|
+
import { defineEmits, defineOptions, defineProps, onUnmounted, reactive, ref } from 'vue'
|
|
3
3
|
import { useRouter } from 'uni-mini-router'
|
|
4
4
|
import { useGlobalToast } from '../../composables/useGlobalToast'
|
|
5
5
|
import { getUserConfig } from '../../api/login'
|
|
@@ -7,12 +7,18 @@ import { req } from '../../api/index'
|
|
|
7
7
|
import { useUser } from '../../composables/useUser'
|
|
8
8
|
import { useTabbar } from '../../composables/useTabbar'
|
|
9
9
|
import type { TabbarItem } from '../../composables/useTabbar'
|
|
10
|
+
import type { UserInfo } from '../../composables/types/user'
|
|
10
11
|
|
|
11
12
|
defineOptions({
|
|
12
13
|
name: 'PhoneLoginForm',
|
|
13
14
|
})
|
|
14
15
|
|
|
15
16
|
const props = defineProps<Props>()
|
|
17
|
+
|
|
18
|
+
// 登录成功回调,向父级抛出用户信息
|
|
19
|
+
const emit = defineEmits<{
|
|
20
|
+
'login-success': [user: UserInfo]
|
|
21
|
+
}>()
|
|
16
22
|
// 定义 Props 类型
|
|
17
23
|
interface Props {
|
|
18
24
|
gurl?: string// 获取验证码接口
|
|
@@ -144,6 +150,8 @@ function handleSubmit() {
|
|
|
144
150
|
if (res1.status === 'success') {
|
|
145
151
|
// 保存用户信息
|
|
146
152
|
setUserInfo(res1.user)
|
|
153
|
+
// 抛出登录成功事件(携带用户信息)
|
|
154
|
+
emit('login-success', res1.user)
|
|
147
155
|
// 跳转首页
|
|
148
156
|
router.pushTab('/pages/index/index')
|
|
149
157
|
setTabbarItemActive('index')
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<!-- 纯色风格登录页面 -->
|
|
2
2
|
<script setup lang="ts">
|
|
3
|
-
import { defineOptions, defineProps } from 'vue'
|
|
4
3
|
import loginFormBox from '../login-form-box/login-form-box.vue'
|
|
5
4
|
import { useManualTheme } from '../../composables/useManualTheme'
|
|
6
5
|
import type { TabbarItem } from '../../composables/useTabbar'
|
|
6
|
+
import type { UserInfo } from '../../composables/types/user'
|
|
7
7
|
import companyLogo from '../../static/companyLogo.png'
|
|
8
8
|
|
|
9
9
|
defineOptions({
|
|
@@ -21,6 +21,16 @@ interface Props {
|
|
|
21
21
|
customLoginImg?: string // 自定义登录图片(默认使用 companyLogo)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
// 登录成功回调,向父级抛出用户信息
|
|
25
|
+
const emit = defineEmits<{
|
|
26
|
+
'login-success': [user: UserInfo]
|
|
27
|
+
}>()
|
|
28
|
+
|
|
29
|
+
// 透传登录成功事件
|
|
30
|
+
function onLoginSuccess(user: UserInfo) {
|
|
31
|
+
emit('login-success', user)
|
|
32
|
+
}
|
|
33
|
+
|
|
24
34
|
const props = withDefaults(defineProps<Props>(), {
|
|
25
35
|
showRagister: false,
|
|
26
36
|
gurl: '',
|
|
@@ -53,6 +63,7 @@ const { currentThemeColor } = useManualTheme()
|
|
|
53
63
|
:show-ragister="showRagister"
|
|
54
64
|
:gurl="props.gurl"
|
|
55
65
|
:url="props.url"
|
|
66
|
+
@login-success="onLoginSuccess"
|
|
56
67
|
/>
|
|
57
68
|
</view>
|
|
58
69
|
</view>
|