feat:登录注册完成
This commit is contained in:
88
src/components/agreement-checkbox/index.vue
Normal file
88
src/components/agreement-checkbox/index.vue
Normal file
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<view class="agreement-checkbox" @tap="toggle">
|
||||
<view
|
||||
class="agreement-checkbox__box"
|
||||
:class="{ 'agreement-checkbox__box--checked': modelValue }"
|
||||
>
|
||||
<image
|
||||
v-if="modelValue"
|
||||
class="agreement-checkbox__checked"
|
||||
:src="staticAssets.iconChecked"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
<view class="agreement-checkbox__text">
|
||||
<text class="agreement-checkbox__plain">我已阅读并同意</text>
|
||||
<text class="agreement-checkbox__link" @tap.stop="openAgreement('service')">《用户服务协议》</text>
|
||||
<text class="agreement-checkbox__plain">和</text>
|
||||
<text class="agreement-checkbox__link" @tap.stop="openAgreement('privacy')">《隐私政策》</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { staticAssets } from '@/utils/static-assets'
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: boolean]
|
||||
}>()
|
||||
|
||||
function toggle() {
|
||||
emit('update:modelValue', !props.modelValue)
|
||||
}
|
||||
|
||||
function openAgreement(type: 'service' | 'privacy') {
|
||||
uni.navigateTo({
|
||||
url: `/pages/agreement/index?type=${type}`,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.agreement-checkbox {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 16rpx;
|
||||
padding: 0 8rpx;
|
||||
}
|
||||
|
||||
.agreement-checkbox__box {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
border: 2rpx solid #ccc;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
margin-top: 4rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.agreement-checkbox__box--checked {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.agreement-checkbox__checked {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
}
|
||||
|
||||
.agreement-checkbox__text {
|
||||
flex: 1;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.agreement-checkbox__plain {
|
||||
color: $color-text-secondary;
|
||||
}
|
||||
|
||||
.agreement-checkbox__link {
|
||||
color: $color-link;
|
||||
}
|
||||
</style>
|
||||
72
src/components/app-navbar/index.vue
Normal file
72
src/components/app-navbar/index.vue
Normal file
@@ -0,0 +1,72 @@
|
||||
<template>
|
||||
<view class="app-navbar" :style="{ paddingTop: statusBarHeight + 'px' }">
|
||||
<view class="app-navbar__bar">
|
||||
<view class="app-navbar__back" @tap="onBack">
|
||||
<text class="app-navbar__back-icon">‹</text>
|
||||
</view>
|
||||
<text class="app-navbar__title">{{ title }}</text>
|
||||
<view class="app-navbar__placeholder" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
defineProps<{
|
||||
title: string
|
||||
}>()
|
||||
|
||||
const statusBarHeight = ref(0)
|
||||
const sys = uni.getSystemInfoSync()
|
||||
statusBarHeight.value = sys.statusBarHeight ?? 0
|
||||
|
||||
function onBack() {
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length > 1) {
|
||||
uni.navigateBack()
|
||||
} else {
|
||||
uni.reLaunch({ url: '/pages/device/index' })
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-navbar {
|
||||
background: $color-bg-page;
|
||||
}
|
||||
|
||||
.app-navbar__bar {
|
||||
height: 88rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 24rpx;
|
||||
}
|
||||
|
||||
.app-navbar__back {
|
||||
width: 80rpx;
|
||||
height: 88rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.app-navbar__back-icon {
|
||||
font-size: 52rpx;
|
||||
line-height: 1;
|
||||
color: $color-text;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.app-navbar__title {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
font-size: 34rpx;
|
||||
font-weight: 500;
|
||||
color: $color-text;
|
||||
}
|
||||
|
||||
.app-navbar__placeholder {
|
||||
width: 80rpx;
|
||||
}
|
||||
</style>
|
||||
129
src/components/app-tab-bar/index.vue
Normal file
129
src/components/app-tab-bar/index.vue
Normal file
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<view class="app-tab-bar" :style="{ paddingBottom: safeBottom + 'px' }">
|
||||
<view
|
||||
class="app-tab-bar__item"
|
||||
:class="{ 'app-tab-bar__item--active': activeTab === 'device' }"
|
||||
@tap="switchTo('device')"
|
||||
>
|
||||
<view class="app-tab-bar__icon-box">
|
||||
<image
|
||||
class="app-tab-bar__icon"
|
||||
:src="activeTab === 'device' ? staticAssets.tabDeviceActive : staticAssets.tabDevice"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
<text class="app-tab-bar__text">设备</text>
|
||||
</view>
|
||||
<view
|
||||
class="app-tab-bar__item"
|
||||
:class="{ 'app-tab-bar__item--active': activeTab === 'mine' }"
|
||||
@tap="switchTo('mine')"
|
||||
>
|
||||
<view class="app-tab-bar__icon-box">
|
||||
<image
|
||||
class="app-tab-bar__icon"
|
||||
:src="activeTab === 'mine' ? staticAssets.tabMineActive : staticAssets.tabMine"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
<text class="app-tab-bar__text">我的</text>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from 'vue'
|
||||
import { staticAssets } from '@/utils/static-assets'
|
||||
|
||||
export type TabKey = 'device' | 'mine'
|
||||
|
||||
const props = defineProps<{
|
||||
current: TabKey
|
||||
}>()
|
||||
|
||||
const safeBottom = uni.getSystemInfoSync().safeAreaInsets?.bottom ?? 0
|
||||
|
||||
const routes: Record<TabKey, string> = {
|
||||
device: '/pages/device/index',
|
||||
mine: '/pages/mine/index',
|
||||
}
|
||||
|
||||
function resolveTabFromRoute(): TabKey {
|
||||
const route = getCurrentPages().at(-1)?.route ?? ''
|
||||
return route.includes('mine') ? 'mine' : 'device'
|
||||
}
|
||||
|
||||
const activeTab = ref<TabKey>(props.current)
|
||||
|
||||
watch(
|
||||
() => props.current,
|
||||
(value) => {
|
||||
activeTab.value = value
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
activeTab.value = resolveTabFromRoute()
|
||||
})
|
||||
|
||||
function switchTo(key: TabKey) {
|
||||
if (activeTab.value === key) return
|
||||
activeTab.value = key
|
||||
uni.reLaunch({ url: routes[key] })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.app-tab-bar {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 100;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-around;
|
||||
min-height: 100rpx;
|
||||
padding-top: 10rpx;
|
||||
background: #ffffff;
|
||||
border-top: 1rpx solid #eeeeee;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.app-tab-bar__item {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8rpx;
|
||||
min-height: 96rpx;
|
||||
}
|
||||
|
||||
.app-tab-bar__icon-box {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.app-tab-bar__icon {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
/* 设备 / 我的:未选中、选中文字样式完全一致 */
|
||||
.app-tab-bar__text {
|
||||
font-size: 22rpx;
|
||||
font-weight: 400;
|
||||
color: #999999;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.app-tab-bar__item--active .app-tab-bar__text {
|
||||
color: #333333;
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
119
src/components/base-input/index.vue
Normal file
119
src/components/base-input/index.vue
Normal file
@@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<view class="base-input">
|
||||
<view v-if="iconSrc" class="base-input__icon">
|
||||
<image
|
||||
class="base-input__icon-img"
|
||||
:class="{ 'base-input__icon-img--lock': icon === 'lock' }"
|
||||
:src="iconSrc"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
</view>
|
||||
<input
|
||||
class="base-input__field"
|
||||
:type="inputType"
|
||||
:password="password"
|
||||
:value="modelValue"
|
||||
:placeholder="placeholder"
|
||||
:placeholder-class="placeholderClass"
|
||||
:maxlength="maxlength"
|
||||
@input="onInput"
|
||||
/>
|
||||
<view v-if="$slots.suffix" class="base-input__suffix">
|
||||
<slot name="suffix" />
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { staticAssets } from '@/utils/static-assets'
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
modelValue: string
|
||||
placeholder?: string
|
||||
icon?: 'phone' | 'shield' | 'lock'
|
||||
type?: 'text' | 'password' | 'number'
|
||||
maxlength?: number
|
||||
}>(),
|
||||
{
|
||||
placeholder: '',
|
||||
type: 'text',
|
||||
maxlength: 140,
|
||||
},
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: string]
|
||||
}>()
|
||||
|
||||
const password = computed(() => props.type === 'password')
|
||||
const inputType = computed(() => {
|
||||
if (props.type === 'number') return 'number'
|
||||
if (props.type === 'password') return 'text'
|
||||
return 'text'
|
||||
})
|
||||
|
||||
const iconSrc = computed(() => {
|
||||
if (!props.icon) return ''
|
||||
if (props.icon === 'phone') return staticAssets.iconPhone
|
||||
if (props.icon === 'lock') return staticAssets.iconPassword
|
||||
return staticAssets.iconCode
|
||||
})
|
||||
|
||||
const placeholderClass = 'base-input__placeholder'
|
||||
|
||||
function onInput(e: Event) {
|
||||
const { value } = (e as CustomEvent<{ value: string }>).detail
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.base-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 96rpx;
|
||||
padding: 0 32rpx;
|
||||
background: $color-bg-input;
|
||||
border: 2rpx solid $color-border;
|
||||
border-radius: $radius-input;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.base-input__icon {
|
||||
flex-shrink: 0;
|
||||
margin-right: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.base-input__icon-img {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
|
||||
.base-input__icon-img--lock {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
|
||||
.base-input__field {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
font-size: 28rpx;
|
||||
color: $color-text;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.base-input__suffix {
|
||||
flex-shrink: 0;
|
||||
margin-left: 16rpx;
|
||||
}
|
||||
|
||||
:deep(.base-input__placeholder) {
|
||||
color: $color-text-placeholder;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
</style>
|
||||
35
src/components/brand-logo/index.vue
Normal file
35
src/components/brand-logo/index.vue
Normal file
@@ -0,0 +1,35 @@
|
||||
<template>
|
||||
<view class="brand-logo">
|
||||
<image
|
||||
class="brand-logo__image"
|
||||
:src="staticAssets.logo"
|
||||
mode="aspectFit"
|
||||
/>
|
||||
<text class="brand-logo__name">虫子智家</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { staticAssets } from '@/utils/static-assets'
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.brand-logo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.brand-logo__image {
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.brand-logo__name {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: $color-text;
|
||||
letter-spacing: 4rpx;
|
||||
}
|
||||
</style>
|
||||
51
src/components/primary-button/index.vue
Normal file
51
src/components/primary-button/index.vue
Normal file
@@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<view
|
||||
class="primary-button"
|
||||
:class="{ 'primary-button--disabled': disabled }"
|
||||
@tap="onTap"
|
||||
>
|
||||
<text class="primary-button__text">{{ text }}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
text: string
|
||||
disabled?: boolean
|
||||
}>(),
|
||||
{ disabled: false },
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
click: []
|
||||
}>()
|
||||
|
||||
function onTap() {
|
||||
if (props.disabled) return
|
||||
emit('click')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.primary-button {
|
||||
height: 96rpx;
|
||||
background: $color-primary;
|
||||
border-radius: $radius-button;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: $shadow-button;
|
||||
}
|
||||
|
||||
.primary-button--disabled {
|
||||
opacity: 0.45;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.primary-button__text {
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
56
src/components/sms-code-btn/index.vue
Normal file
56
src/components/sms-code-btn/index.vue
Normal file
@@ -0,0 +1,56 @@
|
||||
<template>
|
||||
<view
|
||||
class="sms-code-btn"
|
||||
:class="{ 'sms-code-btn--disabled': disabled || counting }"
|
||||
@tap="onTap"
|
||||
>
|
||||
<text class="sms-code-btn__text">{{ label }}</text>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps<{
|
||||
counting: boolean
|
||||
seconds: number
|
||||
disabled?: boolean
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
send: []
|
||||
}>()
|
||||
|
||||
const label = computed(() => {
|
||||
if (props.counting) return `${props.seconds}s`
|
||||
return '获取验证码'
|
||||
})
|
||||
|
||||
function onTap() {
|
||||
if (props.disabled || props.counting) return
|
||||
emit('send')
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.sms-code-btn {
|
||||
padding: 12rpx 20rpx;
|
||||
border: 2rpx solid $color-primary;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.sms-code-btn--disabled {
|
||||
opacity: 0.5;
|
||||
border-color: #ccc;
|
||||
}
|
||||
|
||||
.sms-code-btn__text {
|
||||
font-size: 24rpx;
|
||||
color: $color-primary;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sms-code-btn--disabled .sms-code-btn__text {
|
||||
color: #999;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user