feat: 客户checkin
This commit is contained in:
@@ -3,7 +3,7 @@ import request from '@/utils/request'
|
|||||||
interface LoginParamsType {
|
interface LoginParamsType {
|
||||||
name?: string // 姓名
|
name?: string // 姓名
|
||||||
email: string // 邮箱
|
email: string // 邮箱
|
||||||
password: string // 密码
|
password?: string // 密码
|
||||||
operationType: 'REGISTER' | 'LOGIN' | 'FORGET_PWD'
|
operationType: 'REGISTER' | 'LOGIN' | 'FORGET_PWD'
|
||||||
verifyCode?: string // 验证码
|
verifyCode?: string // 验证码
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,3 +98,16 @@ export function getTryOnEffectStyleList(styleId: string | number) {
|
|||||||
method: 'get',
|
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
|
id: 'generate', // 必须指明唯一的pinia仓库的id
|
||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
style: {
|
style: {
|
||||||
id: '',
|
id: '',
|
||||||
oldId: '',//表示从生成页面返回回来,需要调整的样式id
|
oldId: '' //表示从生成页面返回回来,需要调整的样式id
|
||||||
},
|
},
|
||||||
model: {
|
model: {
|
||||||
id: '',
|
id: ''
|
||||||
},
|
},
|
||||||
originalTryOn:{//生成穿好衣服的回参
|
originalTryOn: {
|
||||||
id: '',
|
//生成穿好衣服的回参
|
||||||
isLike: false,//是否喜欢
|
id: '',
|
||||||
tryOnUrl:'',
|
isLike: false, //是否喜欢
|
||||||
},
|
tryOnUrl: ''
|
||||||
isGenerate: false,//点击继续按钮后是否需要生成
|
},
|
||||||
|
isGenerate: false, //点击继续按钮后是否需要生成
|
||||||
|
|
||||||
/** 顾客照片信息 */
|
/** 顾客照片信息 */
|
||||||
photoInfo: {
|
photoInfo: {
|
||||||
id: "",
|
id: '',
|
||||||
url: "",
|
url: '',
|
||||||
file: null,
|
file: null
|
||||||
},
|
},
|
||||||
/** AI魔改信息 */
|
/** AI魔改信息 */
|
||||||
customizeInfo: {
|
customizeInfo: {
|
||||||
inputText: "",
|
inputText: '',
|
||||||
|
|
||||||
tryOnId: "",
|
tryOnId: '',
|
||||||
tryOnUrl: "",
|
tryOnUrl: '',
|
||||||
styleUrl: "",
|
styleUrl: '',
|
||||||
isRegenerated: "",
|
isRegenerated: '',
|
||||||
isFavorite: false,
|
isFavorite: false
|
||||||
},
|
},
|
||||||
}
|
customerInfo: {
|
||||||
|
customerId: '',
|
||||||
|
visitRecordId:''
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
/** 顾客id */
|
/** 顾客id */
|
||||||
customerId: (state) => 1,
|
customerId: (state) => state.customerInfo.customerId,
|
||||||
/** 进店记录id */
|
/** 进店记录id */
|
||||||
visitRecordId: (state) => 1,
|
visitRecordId: (state) => state.customerInfo.visitRecordId,
|
||||||
/** 服装id */
|
/** 服装id */
|
||||||
styleId: (state) => state.style.id || state.style.oldId,
|
styleId: (state) => state.style.id || state.style.oldId,
|
||||||
/** 模特照片id */
|
/** 模特照片id */
|
||||||
@@ -89,5 +94,8 @@ export const useGenerateStore = defineStore({
|
|||||||
this.customizeInfo.isRegenerated = ""
|
this.customizeInfo.isRegenerated = ""
|
||||||
this.customizeInfo.isFavorite = false
|
this.customizeInfo.isFavorite = false
|
||||||
},
|
},
|
||||||
|
setCustomerInfo(data: any) {
|
||||||
|
this.customerInfo = data
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
// 每一个存储的模块,命名规则use开头,store结尾
|
// 每一个存储的模块,命名规则use开头,store结尾
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
import { removeLocal, setLocal } from '@/utils/local'
|
||||||
|
|
||||||
export const useUserInfoStore = defineStore('userInfo', () => {
|
export const useUserInfoStore = defineStore('userInfo', () => {
|
||||||
const state = ref({
|
const state = ref({
|
||||||
@@ -27,6 +28,7 @@ export const useUserInfoStore = defineStore('userInfo', () => {
|
|||||||
|
|
||||||
const setToken = (data: string) => {
|
const setToken = (data: string) => {
|
||||||
state.value.token = data
|
state.value.token = data
|
||||||
|
setLocal(data, 'token')
|
||||||
}
|
}
|
||||||
|
|
||||||
const getGenerateParams = () => {
|
const getGenerateParams = () => {
|
||||||
@@ -51,6 +53,7 @@ export const useUserInfoStore = defineStore('userInfo', () => {
|
|||||||
state.value.token = ''
|
state.value.token = ''
|
||||||
state.value.userInfo = {}
|
state.value.userInfo = {}
|
||||||
state.value.customerId = ''
|
state.value.customerId = ''
|
||||||
|
removeLocal('token')
|
||||||
resetGenerateParams()
|
resetGenerateParams()
|
||||||
resolve('')
|
resolve('')
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,20 +18,19 @@ declare module 'axios' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 创建axios实例
|
// 创建axios实例
|
||||||
// console.log(import.meta.env,123)
|
// console.log(import.meta.env,123)
|
||||||
|
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
// baseURL: import.meta.env.VITE_APP_URL, // api的base_url
|
// baseURL: import.meta.env.VITE_APP_URL, // api的base_url
|
||||||
timeout: 20000, // 请求超时时间
|
timeout: 20000 // 请求超时时间
|
||||||
})
|
})
|
||||||
if(import.meta.env.MODE != 'development'){
|
if (import.meta.env.MODE != 'development') {
|
||||||
service.defaults.baseURL = import.meta.env.VITE_APP_URL
|
service.defaults.baseURL = import.meta.env.VITE_APP_URL
|
||||||
}
|
}
|
||||||
axios.defaults.headers.post["Content-Type"] = "application/json";
|
axios.defaults.headers.post['Content-Type'] = 'application/json'
|
||||||
axios.defaults.headers.post['lang'] = 'en'; //配置语言请求头
|
axios.defaults.headers.post['lang'] = 'en' //配置语言请求头
|
||||||
axios.defaults.withCredentials = true; //跨域携带cookie
|
axios.defaults.withCredentials = true //跨域携带cookie
|
||||||
|
|
||||||
// request拦截器
|
// request拦截器
|
||||||
service.interceptors.request.use(
|
service.interceptors.request.use(
|
||||||
@@ -50,7 +49,7 @@ service.interceptors.request.use(
|
|||||||
// Do something before request is sent
|
// Do something before request is sent
|
||||||
if (store.state.token) {
|
if (store.state.token) {
|
||||||
config.headers.Authorization = getLocal('token') // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改
|
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
|
return config
|
||||||
},
|
},
|
||||||
@@ -77,14 +76,15 @@ service.interceptors.response.use(
|
|||||||
}
|
}
|
||||||
const res = response.data
|
const res = response.data
|
||||||
// 处理异常的情况
|
// 处理异常的情况
|
||||||
console.log(res)
|
console.log(res)
|
||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
showToast({
|
showToast({
|
||||||
message: res.errMsg,
|
message: res.errMsg || res.message,
|
||||||
type: 'fail',
|
// type: 'fail',
|
||||||
duration: 5000
|
duration: 5000,
|
||||||
|
position:'top'
|
||||||
})
|
})
|
||||||
|
|
||||||
return Promise.reject(new Error('error'))
|
return Promise.reject(new Error('error'))
|
||||||
} else {
|
} else {
|
||||||
// 默认只返回data,不返回状态码和message
|
// 默认只返回data,不返回状态码和message
|
||||||
@@ -98,33 +98,35 @@ service.interceptors.response.use(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
if(error?.response){
|
if (error?.response) {
|
||||||
if(error?.response?.status === 401){//如果是记录浏览器页面就不跳转login
|
if (error?.response?.status === 401) {
|
||||||
// showConfirmDialog({
|
//如果是记录浏览器页面就不跳转login
|
||||||
// title: '确定登出',
|
// showConfirmDialog({
|
||||||
// message: '你已被登出,可以取消继续留在该页面,或者重新登录',
|
// title: '确定登出',
|
||||||
// confirmButtonText: '重新登录',
|
// message: '你已被登出,可以取消继续留在该页面,或者重新登录',
|
||||||
// cancelButtonText: '取消'
|
// confirmButtonText: '重新登录',
|
||||||
// }).then(() => {
|
// cancelButtonText: '取消'
|
||||||
// store.loginOut().then(() => {
|
// }).then(() => {
|
||||||
// location.reload() // 为了重新实例化vue-router对象 避免bug
|
// store.loginOut().then(() => {
|
||||||
// })
|
// location.reload() // 为了重新实例化vue-router对象 避免bug
|
||||||
// })
|
// })
|
||||||
router.replace('/login')
|
// })
|
||||||
return Promise.reject(error)
|
router.replace('/login')
|
||||||
}
|
return Promise.reject(error)
|
||||||
error.config && removePending(error.config)
|
}
|
||||||
// 关闭loading
|
error.config && removePending(error.config)
|
||||||
if (error.config?.loading) {
|
// 关闭loading
|
||||||
closeLoading()
|
if (error.config?.loading) {
|
||||||
}
|
closeLoading()
|
||||||
console.log('err' + error) // for debug
|
}
|
||||||
showToast({
|
console.log('err' + error) // for debug
|
||||||
message: error.message,
|
showToast({
|
||||||
type: 'fail',
|
message: error.message,
|
||||||
duration: 5000
|
// type: 'fail',
|
||||||
})
|
duration: 5000,
|
||||||
}
|
position:'top'
|
||||||
|
})
|
||||||
|
}
|
||||||
return Promise.reject(error)
|
return Promise.reject(error)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -175,14 +177,13 @@ const LoadingInstance: { _count: number } = {
|
|||||||
_count: 0
|
_count: 0
|
||||||
}
|
}
|
||||||
function openLoading(loadingDom: any) {
|
function openLoading(loadingDom: any) {
|
||||||
useOverallStore().setLoading(true)
|
useOverallStore().setLoading(true)
|
||||||
}
|
}
|
||||||
function closeLoading() {
|
function closeLoading() {
|
||||||
if (LoadingInstance._count > 0) LoadingInstance._count--
|
if (LoadingInstance._count > 0) LoadingInstance._count--
|
||||||
if (LoadingInstance._count === 0) {
|
if (LoadingInstance._count === 0) {
|
||||||
useOverallStore().setLoading(false)
|
useOverallStore().setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default service
|
export default service
|
||||||
|
|||||||
@@ -26,11 +26,16 @@
|
|||||||
<div class="glass-form">
|
<div class="glass-form">
|
||||||
<div class="form-field">
|
<div class="form-field">
|
||||||
<label class="field-label">Customer Name</label>
|
<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>
|
||||||
<div class="form-field email">
|
<div class="form-field email">
|
||||||
<label class="field-label">Customer Email</label>
|
<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>
|
</div>
|
||||||
<button class="confirm-btn" @click="handleConfirm">Confirm</button>
|
<button class="confirm-btn" @click="handleConfirm">Confirm</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -42,10 +47,12 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useUserInfoStore } from '@/stores'
|
import { useGenerateStore } from '@/stores'
|
||||||
import { showToast } from 'vant'
|
import { showToast } from 'vant'
|
||||||
const userInfoStore = useUserInfoStore()
|
import { customerCheckin } from '@/api/workshop'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
const generateStore = useGenerateStore()
|
||||||
|
|
||||||
type PageMode = 'form' | 'entry'
|
type PageMode = 'form' | 'entry'
|
||||||
const pageMode = ref<PageMode>('entry')
|
const pageMode = ref<PageMode>('entry')
|
||||||
@@ -58,21 +65,26 @@ const handleChangeMode = (mode: PageMode) => {
|
|||||||
pageMode.value = mode
|
pageMode.value = mode
|
||||||
}
|
}
|
||||||
|
|
||||||
const customeData = ref({
|
const customerData = ref({
|
||||||
name: '',
|
name: '',
|
||||||
email: ''
|
email: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
if (customeData.value.name === '' || customeData.value.email === '') {
|
if (customerData.value.name === '' || customerData.value.email === '') {
|
||||||
showToast('please input name and email')
|
showToast({
|
||||||
|
message: 'please input name and email',
|
||||||
|
position: 'top'
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
console.log('customerData.value', customerData.value)
|
||||||
|
|
||||||
// await 查找顾客ID
|
customerCheckin(customerData.value).then((res) => {
|
||||||
// userInfoStore.setCustomerId('')
|
console.log('res', res)
|
||||||
|
generateStore.setCustomerInfo(res)
|
||||||
router.push('/stylist/index')
|
router.push('/stylist/index')
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user