Merge branch 'master' of https://gitee.com/lvYeJu/lane-crawford-3
This commit is contained in:
@@ -3,12 +3,12 @@ import request from '@/utils/request'
|
||||
interface LoginParamsType {
|
||||
name?: string // 姓名
|
||||
email: string // 邮箱
|
||||
password: string // 密码
|
||||
password?: string // 密码
|
||||
operationType: 'REGISTER' | 'LOGIN' | 'FORGET_PWD'
|
||||
verifyCode?: string // 验证码
|
||||
}
|
||||
|
||||
export const precheckAndSendEmail = (data: LoginParamsType) => {
|
||||
export const precheckAndSendEmail = (data: LoginParamsType): Promise<ApiResponse> => {
|
||||
return request({
|
||||
url: '/api/auth/precheckAndSendEmail',
|
||||
method: 'post',
|
||||
@@ -16,7 +16,7 @@ export const precheckAndSendEmail = (data: LoginParamsType) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const fetchLogin = (data: LoginParamsType) => {
|
||||
export const fetchRegisterOrLogin = (data: LoginParamsType): Promise<LoginResponse> => {
|
||||
return request({
|
||||
url: '/api/auth/registerOrLogin',
|
||||
method: 'post',
|
||||
@@ -24,10 +24,17 @@ export const fetchLogin = (data: LoginParamsType) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const resetPassword = (data: LoginParamsType) => {
|
||||
export const resetPassword = (data: LoginParamsType): Promise<ApiResponse> => {
|
||||
return request({
|
||||
url: '/api/auth/forgotPwd',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export const checkLoginStatus = (): Promise<ApiResponse<LoginResponse>> => {
|
||||
return request({
|
||||
url: '/api/auth/checkLoginStatus',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@@ -98,3 +98,16 @@ export function getTryOnEffectStyleList(styleId: string | number) {
|
||||
method: 'get',
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
interface CustomerInfo {
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
export const customerCheckin = (data: CustomerInfo) => {
|
||||
return request({
|
||||
url: '/api/customers/checkIn',
|
||||
method: 'get',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
@@ -2,114 +2,122 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { useUserInfoStore } from './userInfo'
|
||||
export const useGenerateStore = defineStore({
|
||||
id: 'generate', // 必须指明唯一的pinia仓库的id
|
||||
state: () => {
|
||||
return {
|
||||
style: {
|
||||
id: '',
|
||||
oldId: '',//表示从生成页面返回回来,需要调整的样式id
|
||||
},
|
||||
model: {
|
||||
id: '',
|
||||
},
|
||||
originalTryOn: {//生成穿好衣服的回参
|
||||
id: '',
|
||||
isLike: false,//是否喜欢
|
||||
tryOnUrl:'',
|
||||
},
|
||||
isGenerate: false,//点击继续按钮后是否需要生成
|
||||
id: 'generate', // 必须指明唯一的pinia仓库的id
|
||||
state: () => {
|
||||
return {
|
||||
style: {
|
||||
id: '',
|
||||
oldId: '' //表示从生成页面返回回来,需要调整的样式id
|
||||
},
|
||||
model: {
|
||||
id: ''
|
||||
},
|
||||
originalTryOn: {
|
||||
//生成穿好衣服的回参
|
||||
id: '',
|
||||
isLike: false, //是否喜欢
|
||||
tryOnUrl: ''
|
||||
},
|
||||
isGenerate: false, //点击继续按钮后是否需要生成
|
||||
|
||||
/** 顾客照片信息 */
|
||||
photoInfo: {
|
||||
id: "",
|
||||
url: "",
|
||||
file: null,
|
||||
},
|
||||
/** AI魔改信息 */
|
||||
customizeInfo: {
|
||||
inputText: "",
|
||||
/** 顾客照片信息 */
|
||||
photoInfo: {
|
||||
id: '',
|
||||
url: '',
|
||||
file: null
|
||||
},
|
||||
/** AI魔改信息 */
|
||||
customizeInfo: {
|
||||
inputText: '',
|
||||
|
||||
tryOnId: "",
|
||||
tryOnUrl: "",
|
||||
styleUrl: "",
|
||||
isRegenerated: "",
|
||||
isFavorite: false,
|
||||
},
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
/** 顾客id */
|
||||
customerId: (state) => useUserInfoStore().state.customerId,
|
||||
/** 进店记录id */
|
||||
visitRecordId: (state) => useUserInfoStore().state.visitRecordId,
|
||||
/** 服装id */
|
||||
styleId: (state) => state.style.id || state.style.oldId,
|
||||
/** 模特照片id */
|
||||
modelPhotoId: (state) => state.model.id,
|
||||
/** 原始试穿id-优先AI魔改 */
|
||||
originalTryOnId: (state) => state.customizeInfo.tryOnId || state.originalTryOn.id,
|
||||
/** 顾客照片id */
|
||||
customerPhotoId: (state) => state.photoInfo.id,
|
||||
},
|
||||
actions: {
|
||||
selectStyle(data: any) {
|
||||
this.style.id = data.id
|
||||
console.log(this)
|
||||
},
|
||||
//生成后去掉id 设置oldId来修改样式
|
||||
useStyleGenerate() {
|
||||
if(!this.style.id)return
|
||||
this.style.oldId = this.style.id
|
||||
this.style.id = ''
|
||||
},
|
||||
updateStyle(data) {
|
||||
console.log(data)
|
||||
if (data.id == this.style.oldId) {
|
||||
this.style.oldId = ''
|
||||
}
|
||||
},
|
||||
//模特相关
|
||||
selectModel(data: any) {
|
||||
this.model.id = data.id
|
||||
},
|
||||
setIsGenerate(isGenerate: boolean) {
|
||||
this.isGenerate = isGenerate
|
||||
},
|
||||
clearProductData(){
|
||||
this.style = {
|
||||
id: '',
|
||||
oldId: '',
|
||||
}
|
||||
this.model = {
|
||||
id: '',
|
||||
}
|
||||
this.originalTryOn = {
|
||||
id: '',
|
||||
isLike: false,
|
||||
tryOnUrl:'',
|
||||
}
|
||||
this.isGenerate = false
|
||||
},
|
||||
/** 更新顾客照片信息 */
|
||||
updatePhotoInfo(data: any) {
|
||||
this.photoInfo.id = data.id || ""
|
||||
if (!data.photoUrl) this.photoInfo.url = ""
|
||||
this.photoInfo.file = null
|
||||
},
|
||||
/** 清空 AI魔改信息 */
|
||||
clearCustomizeInfo() {
|
||||
this.customizeInfo.inputText = ""
|
||||
this.customizeInfo.tryOnId = ""
|
||||
this.customizeInfo.tryOnUrl = ""
|
||||
this.customizeInfo.styleUrl = ""
|
||||
this.customizeInfo.isRegenerated = ""
|
||||
this.customizeInfo.isFavorite = false
|
||||
},
|
||||
//设置默认数据
|
||||
clearGenerateData() {
|
||||
this.clearProductData()
|
||||
this.updatePhotoInfo()
|
||||
this.clearCustomizeInfo()
|
||||
}
|
||||
}
|
||||
})
|
||||
tryOnId: '',
|
||||
tryOnUrl: '',
|
||||
styleUrl: '',
|
||||
isRegenerated: '',
|
||||
isFavorite: false
|
||||
},
|
||||
customerInfo: {
|
||||
customerId: '',
|
||||
visitRecordId: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
/** 顾客id */
|
||||
customerId: (state) => state.customerInfo.customerId,
|
||||
/** 进店记录id */
|
||||
visitRecordId: (state) => state.customerInfo.visitRecordId,
|
||||
/** 服装id */
|
||||
styleId: (state) => state.style.id || state.style.oldId,
|
||||
/** 模特照片id */
|
||||
modelPhotoId: (state) => state.model.id,
|
||||
/** 原始试穿id-优先AI魔改 */
|
||||
originalTryOnId: (state) => state.customizeInfo.tryOnId || state.originalTryOn.id,
|
||||
/** 顾客照片id */
|
||||
customerPhotoId: (state) => state.photoInfo.id
|
||||
},
|
||||
actions: {
|
||||
selectStyle(data: any) {
|
||||
this.style.id = data.id
|
||||
console.log(this)
|
||||
},
|
||||
//生成后去掉id 设置oldId来修改样式
|
||||
useStyleGenerate() {
|
||||
if (!this.style.id) return
|
||||
this.style.oldId = this.style.id
|
||||
this.style.id = ''
|
||||
},
|
||||
updateStyle(data) {
|
||||
console.log(data)
|
||||
if (data.id == this.style.oldId) {
|
||||
this.style.oldId = ''
|
||||
}
|
||||
},
|
||||
//模特相关
|
||||
selectModel(data: any) {
|
||||
this.model.id = data.id
|
||||
},
|
||||
setIsGenerate(isGenerate: boolean) {
|
||||
this.isGenerate = isGenerate
|
||||
},
|
||||
clearProductData() {
|
||||
this.style = {
|
||||
id: '',
|
||||
oldId: ''
|
||||
}
|
||||
this.model = {
|
||||
id: ''
|
||||
}
|
||||
this.originalTryOn = {
|
||||
id: '',
|
||||
isLike: false,
|
||||
tryOnUrl: ''
|
||||
}
|
||||
this.isGenerate = false
|
||||
},
|
||||
/** 更新顾客照片信息 */
|
||||
updatePhotoInfo(data: any) {
|
||||
this.photoInfo.id = data.id || ''
|
||||
if (!data.photoUrl) this.photoInfo.url = ''
|
||||
this.photoInfo.file = null
|
||||
},
|
||||
/** 清空 AI魔改信息 */
|
||||
clearCustomizeInfo() {
|
||||
this.customizeInfo.inputText = ''
|
||||
this.customizeInfo.tryOnId = ''
|
||||
this.customizeInfo.tryOnUrl = ''
|
||||
this.customizeInfo.styleUrl = ''
|
||||
this.customizeInfo.isRegenerated = ''
|
||||
this.customizeInfo.isFavorite = false
|
||||
},
|
||||
//设置默认数据
|
||||
clearGenerateData() {
|
||||
this.clearProductData()
|
||||
this.updatePhotoInfo({})
|
||||
this.clearCustomizeInfo()
|
||||
},
|
||||
setCustomerInfo(data: any) {
|
||||
this.customerInfo = data
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// 每一个存储的模块,命名规则use开头,store结尾
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, computed } from 'vue'
|
||||
import { removeLocal, setLocal } from '@/utils/local'
|
||||
|
||||
export const useUserInfoStore = defineStore('userInfo', () => {
|
||||
const state = ref({
|
||||
@@ -27,6 +28,7 @@ export const useUserInfoStore = defineStore('userInfo', () => {
|
||||
|
||||
const setToken = (data: string) => {
|
||||
state.value.token = data
|
||||
setLocal(data, 'token')
|
||||
}
|
||||
|
||||
const getGenerateParams = () => {
|
||||
@@ -45,16 +47,13 @@ export const useUserInfoStore = defineStore('userInfo', () => {
|
||||
}
|
||||
}
|
||||
|
||||
const login = async (data: any) => {
|
||||
return new Promise((resolve, reject) => {})
|
||||
}
|
||||
|
||||
const logOut = () => {
|
||||
// 处理退出登录的一些逻辑
|
||||
return new Promise((resolve) => {
|
||||
state.value.token = ''
|
||||
state.value.userInfo = {}
|
||||
state.value.customerId = ''
|
||||
removeLocal('token')
|
||||
resetGenerateParams()
|
||||
resolve('')
|
||||
})
|
||||
@@ -69,7 +68,6 @@ export const useUserInfoStore = defineStore('userInfo', () => {
|
||||
setGenerateParams,
|
||||
getGenerateParams,
|
||||
resetGenerateParams,
|
||||
logOut,
|
||||
login
|
||||
logOut
|
||||
}
|
||||
})
|
||||
|
||||
45
src/types/api.d.ts
vendored
Normal file
45
src/types/api.d.ts
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
// 全局API响应类型定义
|
||||
declare global {
|
||||
// 基础API响应结构
|
||||
interface ApiResponse<T = any> {
|
||||
success: boolean
|
||||
message: string
|
||||
data?: T
|
||||
code?: number
|
||||
errMsg?: string
|
||||
}
|
||||
|
||||
// 登录/注册相关响应
|
||||
interface LoginResponse {
|
||||
token?: string
|
||||
user?: {
|
||||
id: string
|
||||
name: string
|
||||
email: string
|
||||
}
|
||||
}
|
||||
|
||||
// 通用列表响应
|
||||
interface ListResponse<T> {
|
||||
list: T[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
// 分页参数
|
||||
interface PaginationParams {
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
// 通用错误响应
|
||||
interface ErrorResponse {
|
||||
success: false
|
||||
message: string
|
||||
code?: number
|
||||
errMsg?: string
|
||||
}
|
||||
}
|
||||
|
||||
export {}
|
||||
@@ -6,20 +6,31 @@ import { getLocal } from '@/utils/local'
|
||||
import router from '@/router/index'
|
||||
import { useOverallStore, useGenerateStore } from '@/stores'
|
||||
|
||||
// 扩展 AxiosRequestConfig 接口
|
||||
declare module 'axios' {
|
||||
interface AxiosRequestConfig {
|
||||
loading?: boolean
|
||||
loadingDom?: any
|
||||
repeatRequest?: boolean
|
||||
meta?: {
|
||||
responseAll?: boolean
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 创建axios实例
|
||||
// console.log(import.meta.env,123)
|
||||
|
||||
const service = axios.create({
|
||||
// baseURL: import.meta.env.VITE_APP_URL, // api的base_url
|
||||
timeout: 20000, // 请求超时时间
|
||||
// baseURL: import.meta.env.VITE_APP_URL, // api的base_url
|
||||
timeout: 20000 // 请求超时时间
|
||||
})
|
||||
if(import.meta.env.MODE != 'development'){
|
||||
if (import.meta.env.MODE != 'development') {
|
||||
service.defaults.baseURL = import.meta.env.VITE_APP_URL
|
||||
}
|
||||
axios.defaults.headers.post["Content-Type"] = "application/json";
|
||||
axios.defaults.headers.post['lang'] = 'en'; //配置语言请求头
|
||||
axios.defaults.withCredentials = true; //跨域携带cookie
|
||||
axios.defaults.headers.post['Content-Type'] = 'application/json'
|
||||
axios.defaults.headers.post['lang'] = 'en' //配置语言请求头
|
||||
axios.defaults.withCredentials = true //跨域携带cookie
|
||||
|
||||
// request拦截器
|
||||
service.interceptors.request.use(
|
||||
@@ -36,9 +47,9 @@ service.interceptors.request.use(
|
||||
}
|
||||
// 如果登录了,有token,则请求携带token
|
||||
// Do something before request is sent
|
||||
if (store.token) {
|
||||
if (store.state.token) {
|
||||
config.headers.Authorization = getLocal('token') // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
|
||||
// config.headers['X-Token'] = getLocal('token') // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
|
||||
// config.headers['X-Token'] = getLocal('token') // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
|
||||
}
|
||||
return config
|
||||
},
|
||||
@@ -65,14 +76,15 @@ service.interceptors.response.use(
|
||||
}
|
||||
const res = response.data
|
||||
// 处理异常的情况
|
||||
console.log(res)
|
||||
console.log(res)
|
||||
if (res.code != 0) {
|
||||
showToast({
|
||||
message: res.errMsg,
|
||||
type: 'fail',
|
||||
duration: 5000
|
||||
message: res.errMsg || res.message,
|
||||
// type: 'fail',
|
||||
duration: 5000,
|
||||
position:'top'
|
||||
})
|
||||
|
||||
|
||||
return Promise.reject(new Error('error'))
|
||||
} else {
|
||||
// 默认只返回data,不返回状态码和message
|
||||
@@ -165,14 +177,13 @@ const LoadingInstance: { _count: number } = {
|
||||
_count: 0
|
||||
}
|
||||
function openLoading(loadingDom: any) {
|
||||
useOverallStore().setLoading(true)
|
||||
useOverallStore().setLoading(true)
|
||||
}
|
||||
function closeLoading() {
|
||||
if (LoadingInstance._count > 0) LoadingInstance._count--
|
||||
if (LoadingInstance._count === 0) {
|
||||
useOverallStore().setLoading(false)
|
||||
useOverallStore().setLoading(false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default service
|
||||
|
||||
@@ -46,14 +46,16 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useUserInfoStore } from '@/stores'
|
||||
import { showToast } from 'vant'
|
||||
import { google } from '@/assets/base64'
|
||||
import { fetchLogin } from '@/api/login'
|
||||
import { fetchRegisterOrLogin } from '@/api/login'
|
||||
|
||||
const router = useRouter()
|
||||
const userInfoStore = useUserInfoStore()
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive<Record<string, string>>({
|
||||
const formData = reactive({
|
||||
email: '',
|
||||
password: ''
|
||||
})
|
||||
@@ -109,19 +111,14 @@ const handleLogin = async () => {
|
||||
|
||||
isLoading.value = true
|
||||
|
||||
const response: any = await fetchLogin({ ...formData, operationType: 'LOGIN' } as any)
|
||||
if (response.code === 200) {
|
||||
console.log('登录成功', response)
|
||||
// showToast('登录成功')
|
||||
// router.push('/stylist/customer')
|
||||
} else {
|
||||
showToast(response.message)
|
||||
}
|
||||
fetchRegisterOrLogin({ ...formData, operationType: 'LOGIN' }).then((response) => {
|
||||
console.log('登录成功', response)
|
||||
userInfoStore.setToken(response.token)
|
||||
userInfoStore.setUserInfo(response.user)
|
||||
showToast('登录成功')
|
||||
router.replace('/stylist/customer')
|
||||
})
|
||||
|
||||
// showToast('登录成功')
|
||||
|
||||
// 登录成功后跳转到主页或工作台
|
||||
// router.push('/stylist/customer')
|
||||
}
|
||||
|
||||
// 处理忘记密码
|
||||
|
||||
@@ -16,24 +16,12 @@
|
||||
</div>
|
||||
|
||||
<div class="login-container">
|
||||
<form @submit.prevent="handleConfirm" class="login-form">
|
||||
<div class="login-form">
|
||||
<div class="input-group">
|
||||
<input
|
||||
type="text"
|
||||
v-model="formData.name"
|
||||
placeholder="Name"
|
||||
class="input-field"
|
||||
required
|
||||
/>
|
||||
<input type="text" v-model="formData.name" placeholder="Name" class="input-field" />
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<input
|
||||
type="email"
|
||||
v-model="formData.email"
|
||||
placeholder="Email"
|
||||
class="input-field"
|
||||
required
|
||||
/>
|
||||
<input type="email" v-model="formData.email" placeholder="Email" class="input-field" />
|
||||
</div>
|
||||
<div class="input-group pwd">
|
||||
<input
|
||||
@@ -41,19 +29,18 @@
|
||||
v-model="formData.password"
|
||||
placeholder="Your Password"
|
||||
class="input-field"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 登录按钮 -->
|
||||
<button type="submit" class="login-button">Sign Up</button>
|
||||
<button type="button" class="login-button" @click="handleConfirm">Sign Up</button>
|
||||
|
||||
<!-- Google登录按钮 -->
|
||||
<div type="button" class="google-button" @click="handleGoogleLogin">
|
||||
<div type="button" class="google-button" @click="handleSignupByGoogle">
|
||||
<img :src="google" class="google-icon" />
|
||||
Sign up with Google
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -64,16 +51,16 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { showToast } from 'vant'
|
||||
import { google } from '@/assets/base64'
|
||||
import { fetchLogin } from '@/api/login'
|
||||
import { fetchRegisterOrLogin } from '@/api/login'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
// 表单数据
|
||||
const formData = reactive<Record<string, string>>({
|
||||
const formData = reactive({
|
||||
name: '',
|
||||
email: '',
|
||||
password: ''
|
||||
@@ -135,23 +122,12 @@ const validateForm = () => {
|
||||
return isValid
|
||||
}
|
||||
|
||||
// 计算属性:表单是否有效
|
||||
const isFormValid = computed(() => {
|
||||
return (
|
||||
formData.name &&
|
||||
formData.email &&
|
||||
formData.password &&
|
||||
validateEmail(formData.email) &&
|
||||
validatePassword(formData.password)
|
||||
)
|
||||
})
|
||||
|
||||
// 返回上一页
|
||||
const goBack = () => {
|
||||
router.go(-1)
|
||||
}
|
||||
|
||||
// 处理登录
|
||||
// 处理注册
|
||||
const handleConfirm = async () => {
|
||||
if (!validateForm()) {
|
||||
showToast('请检查输入信息')
|
||||
@@ -160,26 +136,25 @@ const handleConfirm = async () => {
|
||||
|
||||
isLoading.value = true
|
||||
|
||||
const res:any = await fetchLogin({...formData, operationType: 'REGISTER'} as any)
|
||||
if(res.code === 200) {
|
||||
console.log('注册成功', res)
|
||||
// showToast('注册成功')
|
||||
// router.push('/stylist/customer')
|
||||
} else {
|
||||
showToast(res.message)
|
||||
}
|
||||
}
|
||||
|
||||
// 处理忘记密码
|
||||
const handleForgotPassword = () => {
|
||||
showToast('忘记密码功能开发中...')
|
||||
console.log('11111111111')
|
||||
// 这里可以跳转到忘记密码页面
|
||||
// router.push('/forgot-password')
|
||||
fetchRegisterOrLogin({ ...formData, operationType: 'REGISTER' })
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
showToast('注册成功')
|
||||
router.push('/login')
|
||||
} else {
|
||||
showToast(res.message)
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
showToast(err.message)
|
||||
})
|
||||
.finally(() => {
|
||||
isLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
// 处理Google登录
|
||||
const handleGoogleLogin = async () => {
|
||||
const handleSignupByGoogle = async () => {
|
||||
try {
|
||||
isLoading.value = true
|
||||
showToast('Google登录功能开发中...')
|
||||
@@ -193,23 +168,6 @@ const handleGoogleLogin = async () => {
|
||||
isLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 实时验证输入
|
||||
const handleEmailInput = () => {
|
||||
if (formData.email && !validateEmail(formData.email)) {
|
||||
formErrors.email = '请输入有效的邮箱地址'
|
||||
} else {
|
||||
formErrors.email = ''
|
||||
}
|
||||
}
|
||||
|
||||
const handlePasswordInput = () => {
|
||||
if (formData.password && !validatePassword(formData.password)) {
|
||||
formErrors.password = '密码至少需要6位字符'
|
||||
} else {
|
||||
formErrors.password = ''
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="customer-container safe-area-top" :class="{ 'form-mode': pageMode === 'form' }">
|
||||
<template v-if="pageMode === 'entry'">
|
||||
<div class="setting flex flex-between">
|
||||
<van-icon name="arrow-left" color="#fff" size="70" />
|
||||
<van-icon name="arrow-left" color="#fff" size="70" @click="handleBack" />
|
||||
<SvgIcon name="setting" size="70" />
|
||||
</div>
|
||||
<div class="content flex flex-center flex-column">
|
||||
@@ -26,11 +26,16 @@
|
||||
<div class="glass-form">
|
||||
<div class="form-field">
|
||||
<label class="field-label">Customer Name</label>
|
||||
<input v-model="customeData.name" type="text" placeholder="Name" class="form-input" />
|
||||
<input v-model="customerData.name" type="text" placeholder="Name" class="form-input" />
|
||||
</div>
|
||||
<div class="form-field email">
|
||||
<label class="field-label">Customer Email</label>
|
||||
<input v-model="customeData.email" type="email" placeholder="Email" class="form-input" />
|
||||
<input
|
||||
v-model="customerData.email"
|
||||
type="email"
|
||||
placeholder="Email"
|
||||
class="form-input"
|
||||
/>
|
||||
</div>
|
||||
<button class="confirm-btn" @click="handleConfirm">Confirm</button>
|
||||
</div>
|
||||
@@ -42,33 +47,44 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useUserInfoStore } from '@/stores'
|
||||
import { useGenerateStore } from '@/stores'
|
||||
import { showToast } from 'vant'
|
||||
const userInfoStore = useUserInfoStore()
|
||||
import { customerCheckin } from '@/api/workshop'
|
||||
|
||||
const router = useRouter()
|
||||
const generateStore = useGenerateStore()
|
||||
|
||||
type PageMode = 'form' | 'entry'
|
||||
const pageMode = ref<PageMode>('entry')
|
||||
|
||||
const handleBack = () => {
|
||||
router.go(-1)
|
||||
}
|
||||
|
||||
const handleChangeMode = (mode: PageMode) => {
|
||||
pageMode.value = mode
|
||||
}
|
||||
|
||||
const customeData = ref({
|
||||
const customerData = ref({
|
||||
name: '',
|
||||
email: ''
|
||||
})
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (customeData.value.name === '' || customeData.value.email === '') {
|
||||
showToast('please input name and email')
|
||||
if (customerData.value.name === '' || customerData.value.email === '') {
|
||||
showToast({
|
||||
message: 'please input name and email',
|
||||
position: 'top'
|
||||
})
|
||||
return
|
||||
}
|
||||
console.log('customerData.value', customerData.value)
|
||||
|
||||
// await 查找顾客ID
|
||||
// userInfoStore.setCustomerId('')
|
||||
|
||||
router.push('/stylist/index')
|
||||
customerCheckin(customerData.value).then((res) => {
|
||||
console.log('res', res)
|
||||
generateStore.setCustomerInfo(res)
|
||||
router.push('/stylist/index')
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
|
||||
Reference in New Issue
Block a user