feat: 客户checkin
This commit is contained in:
@@ -3,7 +3,7 @@ import request from '@/utils/request'
|
||||
interface LoginParamsType {
|
||||
name?: string // 姓名
|
||||
email: string // 邮箱
|
||||
password: string // 密码
|
||||
password?: string // 密码
|
||||
operationType: 'REGISTER' | 'LOGIN' | 'FORGET_PWD'
|
||||
verifyCode?: string // 验证码
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
@@ -4,43 +4,48 @@ export const useGenerateStore = defineStore({
|
||||
id: 'generate', // 必须指明唯一的pinia仓库的id
|
||||
state: () => {
|
||||
return {
|
||||
style: {
|
||||
id: '',
|
||||
oldId: '',//表示从生成页面返回回来,需要调整的样式id
|
||||
},
|
||||
model: {
|
||||
id: '',
|
||||
},
|
||||
originalTryOn:{//生成穿好衣服的回参
|
||||
id: '',
|
||||
isLike: false,//是否喜欢
|
||||
tryOnUrl:'',
|
||||
},
|
||||
isGenerate: false,//点击继续按钮后是否需要生成
|
||||
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,
|
||||
},
|
||||
}
|
||||
tryOnId: '',
|
||||
tryOnUrl: '',
|
||||
styleUrl: '',
|
||||
isRegenerated: '',
|
||||
isFavorite: false
|
||||
},
|
||||
customerInfo: {
|
||||
customerId: '',
|
||||
visitRecordId:''
|
||||
}
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
/** 顾客id */
|
||||
customerId: (state) => 1,
|
||||
customerId: (state) => state.customerInfo.customerId,
|
||||
/** 进店记录id */
|
||||
visitRecordId: (state) => 1,
|
||||
visitRecordId: (state) => state.customerInfo.visitRecordId,
|
||||
/** 服装id */
|
||||
styleId: (state) => state.style.id || state.style.oldId,
|
||||
/** 模特照片id */
|
||||
@@ -89,5 +94,8 @@ export const useGenerateStore = defineStore({
|
||||
this.customizeInfo.isRegenerated = ""
|
||||
this.customizeInfo.isFavorite = false
|
||||
},
|
||||
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 = () => {
|
||||
@@ -51,6 +53,7 @@ export const useUserInfoStore = defineStore('userInfo', () => {
|
||||
state.value.token = ''
|
||||
state.value.userInfo = {}
|
||||
state.value.customerId = ''
|
||||
removeLocal('token')
|
||||
resetGenerateParams()
|
||||
resolve('')
|
||||
})
|
||||
|
||||
@@ -18,20 +18,19 @@ declare module 'axios' {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 创建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(
|
||||
@@ -50,7 +49,7 @@ service.interceptors.request.use(
|
||||
// Do something before request is sent
|
||||
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
|
||||
},
|
||||
@@ -77,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
|
||||
@@ -98,33 +98,35 @@ service.interceptors.response.use(
|
||||
}
|
||||
},
|
||||
(error) => {
|
||||
if(error?.response){
|
||||
if(error?.response?.status === 401){//如果是记录浏览器页面就不跳转login
|
||||
// showConfirmDialog({
|
||||
// title: '确定登出',
|
||||
// message: '你已被登出,可以取消继续留在该页面,或者重新登录',
|
||||
// confirmButtonText: '重新登录',
|
||||
// cancelButtonText: '取消'
|
||||
// }).then(() => {
|
||||
// store.loginOut().then(() => {
|
||||
// location.reload() // 为了重新实例化vue-router对象 避免bug
|
||||
// })
|
||||
// })
|
||||
router.replace('/login')
|
||||
return Promise.reject(error)
|
||||
}
|
||||
error.config && removePending(error.config)
|
||||
// 关闭loading
|
||||
if (error.config?.loading) {
|
||||
closeLoading()
|
||||
}
|
||||
console.log('err' + error) // for debug
|
||||
showToast({
|
||||
message: error.message,
|
||||
type: 'fail',
|
||||
duration: 5000
|
||||
})
|
||||
}
|
||||
if (error?.response) {
|
||||
if (error?.response?.status === 401) {
|
||||
//如果是记录浏览器页面就不跳转login
|
||||
// showConfirmDialog({
|
||||
// title: '确定登出',
|
||||
// message: '你已被登出,可以取消继续留在该页面,或者重新登录',
|
||||
// confirmButtonText: '重新登录',
|
||||
// cancelButtonText: '取消'
|
||||
// }).then(() => {
|
||||
// store.loginOut().then(() => {
|
||||
// location.reload() // 为了重新实例化vue-router对象 避免bug
|
||||
// })
|
||||
// })
|
||||
router.replace('/login')
|
||||
return Promise.reject(error)
|
||||
}
|
||||
error.config && removePending(error.config)
|
||||
// 关闭loading
|
||||
if (error.config?.loading) {
|
||||
closeLoading()
|
||||
}
|
||||
console.log('err' + error) // for debug
|
||||
showToast({
|
||||
message: error.message,
|
||||
// type: 'fail',
|
||||
duration: 5000,
|
||||
position:'top'
|
||||
})
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
@@ -175,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
|
||||
|
||||
@@ -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,10 +47,12 @@
|
||||
<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')
|
||||
@@ -58,21 +65,26 @@ 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