需要修复商城顶部筛选左右滑动问题
This commit is contained in:
67
components/cb-search/cb-search.vue
Normal file
67
components/cb-search/cb-search.vue
Normal file
@@ -0,0 +1,67 @@
|
||||
<script setup>
|
||||
const props = defineProps()
|
||||
|
||||
const placeholderStyle = `font-family: PingFang SC, PingFang SC; font-weight: 500; color: #666666; font-size: 24rpx; font-style: normal; text-transform: none;`
|
||||
|
||||
const name = defineModel({
|
||||
type: String,
|
||||
default: ''
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<view class="cb-search">
|
||||
<image
|
||||
src="/static/images/public/search.png"
|
||||
mode="heightFix"
|
||||
class="left-icon"
|
||||
></image>
|
||||
<input
|
||||
v-model="name"
|
||||
:placeholder-style="placeholderStyle"
|
||||
placeholder="请输入内容"
|
||||
class="search-box"
|
||||
/>
|
||||
<button class="search-btn">搜索</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.cb-search {
|
||||
height: 64rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #f9f9f9;
|
||||
border-radius: 64rpx;
|
||||
padding: 0 0 0 32rpx;
|
||||
.left-icon {
|
||||
height: 48rpx;
|
||||
flex-shrink: 0;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
.search-box {
|
||||
width: 100%;
|
||||
font-size: 24rpx;
|
||||
color: #333333;
|
||||
}
|
||||
.search-btn {
|
||||
margin: 0 8rpx;
|
||||
flex-shrink: 0;
|
||||
width: 120rpx;
|
||||
height: 56rpx;
|
||||
line-height: 56rpx;
|
||||
background: linear-gradient(180deg, #00d993 0%, #00d9c5 100%);
|
||||
border-radius: 64rpx;
|
||||
font-family: PingFang SC, PingFang SC;
|
||||
font-weight: 500;
|
||||
font-size: 28rpx;
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
font-style: normal;
|
||||
text-transform: none;
|
||||
&::after {
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,16 @@
|
||||
<script setup>
|
||||
import { reactive, computed } from 'vue'
|
||||
import { reLaunch } from '@/utils/router'
|
||||
import {
|
||||
validatePhone,
|
||||
validateEmail,
|
||||
validatePassword,
|
||||
validateConfirmPassword
|
||||
} from '@/utils/validate'
|
||||
import { useUI } from '@/utils/use-ui'
|
||||
import { userRegister } from '@/api'
|
||||
|
||||
const { showToast } = useUI()
|
||||
|
||||
const props = defineProps({
|
||||
/**
|
||||
@@ -17,32 +27,67 @@
|
||||
const isPhone = computed(() => props.type === 'phone')
|
||||
|
||||
const formData = reactive({
|
||||
// 手机号
|
||||
// 手机号、邮箱
|
||||
name: '',
|
||||
// 验证码
|
||||
code: '',
|
||||
// 密码
|
||||
password: '',
|
||||
// 确认密码
|
||||
confirmPassword: '',
|
||||
// 邀请码
|
||||
inviteCode: '',
|
||||
agreement: false
|
||||
invitationCode: '54321',
|
||||
agreement: true
|
||||
})
|
||||
|
||||
const isBtn = computed(() => {
|
||||
return (
|
||||
formData.name &&
|
||||
formData.code &&
|
||||
formData.password &&
|
||||
formData.confirmPassword &&
|
||||
formData.inviteCode &&
|
||||
formData.invitationCode &&
|
||||
!formData.agreement
|
||||
)
|
||||
})
|
||||
|
||||
const onRegister = () => {
|
||||
console.log('注册')
|
||||
/** 注册 */
|
||||
const onRegister = async () => {
|
||||
if (isPhone.value) {
|
||||
const phoneValue = validatePhone(formData.name)
|
||||
if (!phoneValue.valid) {
|
||||
showToast(phoneValue.message)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
const emailValue = validateEmail(formData.name)
|
||||
if (!emailValue.valid) {
|
||||
showToast(emailValue.message)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
const passwordValue = validatePassword(formData.password)
|
||||
if (!passwordValue.valid) {
|
||||
showToast(passwordValue.message)
|
||||
return
|
||||
}
|
||||
|
||||
const confirmPasswordValue = validateConfirmPassword(
|
||||
formData.password,
|
||||
formData.confirmPassword
|
||||
)
|
||||
if (!confirmPasswordValue.valid) {
|
||||
showToast(confirmPasswordValue.message)
|
||||
return
|
||||
}
|
||||
|
||||
const data = {
|
||||
type: isPhone.value ? 2 : 1,
|
||||
mobile: formData.name,
|
||||
password: formData.password,
|
||||
invitationCode: formData.invitationCode
|
||||
}
|
||||
await userRegister(data)
|
||||
await showToast('注册成功', 'success')
|
||||
onLogin()
|
||||
}
|
||||
|
||||
const onLogin = () => {
|
||||
@@ -73,12 +118,12 @@
|
||||
icon="3"
|
||||
:placeholder="`请输入${isPhone ? '手机号' : '邮箱'}`"
|
||||
></cb-input>
|
||||
<cb-input
|
||||
<!-- <cb-input
|
||||
v-model="formData.code"
|
||||
type="number"
|
||||
icon="6"
|
||||
placeholder="请输入验证码"
|
||||
></cb-input>
|
||||
></cb-input> -->
|
||||
<cb-input
|
||||
v-model="formData.password"
|
||||
type="password"
|
||||
@@ -92,7 +137,7 @@
|
||||
placeholder="请输入确认密码"
|
||||
></cb-input>
|
||||
<cb-input
|
||||
v-model="formData.inviteCode"
|
||||
v-model="formData.invitationCode"
|
||||
type="number"
|
||||
icon="4"
|
||||
placeholder="请输入邀请码"
|
||||
|
||||
Reference in New Issue
Block a user