diff --git a/package-lock.json b/package-lock.json index 460bac2..7b7b463 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0", "hasInstallScript": true, "dependencies": { + "@microsoft/fetch-event-source": "^2.0.1", "axios": "^1.3.6", "gsap": "^3.13.0", "normalize.css": "^8.0.1", @@ -581,6 +582,12 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@microsoft/fetch-event-source": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@microsoft/fetch-event-source/-/fetch-event-source-2.0.1.tgz", + "integrity": "sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA==", + "license": "MIT" + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmmirror.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -8827,6 +8834,11 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "@microsoft/fetch-event-source": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@microsoft/fetch-event-source/-/fetch-event-source-2.0.1.tgz", + "integrity": "sha512-W6CLUJ2eBMw3Rec70qrsEW0jOm/3twwJv21mrmj2yORiaVmVYGS4sSS5yUwvQc1ZlDLYGPnClVWmUUMagKNsfA==" + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmmirror.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", diff --git a/package.json b/package.json index b32ca60..4c3fc9e 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "postinstall": "husky install" }, "dependencies": { + "@microsoft/fetch-event-source": "^2.0.1", "axios": "^1.3.6", "gsap": "^3.13.0", "normalize.css": "^8.0.1", diff --git a/src/api/login.ts b/src/api/login.ts new file mode 100644 index 0000000..b8322e4 --- /dev/null +++ b/src/api/login.ts @@ -0,0 +1,33 @@ +import request from '@/utils/request' + +interface LoginParamsType { + name?: string // 姓名 + email: string // 邮箱 + password: string // 密码 + operationType: 'REGISTER' | 'LOGIN' | 'FORGET_PWD' + verifyCode?: string // 验证码 +} + +export const precheckAndSendEmail = (data: LoginParamsType) => { + return request({ + url: '/api/auth/precheckAndSendEmail', + method: 'post', + data + }) +} + +export const fetchLogin = (data: LoginParamsType) => { + return request({ + url: '/api/auth/registerOrLogin', + method: 'post', + data + }) +} + +export const resetPassword = (data: LoginParamsType) => { + return request({ + url: '/api/auth/forgotPwd', + method: 'post', + data + }) +} diff --git a/src/stores/index.ts b/src/stores/index.ts index e8fe839..210bc93 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -7,3 +7,4 @@ store.use(createPersistedState()) export default store export * from './modules/generate' export * from './modules/overall' +export * from './modules/userInfo' diff --git a/src/stores/modules/userInfo.ts b/src/stores/modules/userInfo.ts index 9af438d..0cc3f03 100644 --- a/src/stores/modules/userInfo.ts +++ b/src/stores/modules/userInfo.ts @@ -3,40 +3,73 @@ import { defineStore } from 'pinia' import { ref, computed } from 'vue' export const useUserInfoStore = defineStore('userInfo', () => { - // state - const num = ref(0) - const name = ref('张三') - const token = ref('') + const state = ref({ + userInfo: {}, + customerId: '', + token: '', + generateParams: { + stylistId: '', + sex: '' + } + }) // getters - const getUserInfo = computed(() => ({ - num: num.value, - name: name.value, - token: token.value - })) + const getUserInfo = computed(() => state.value.userInfo) // actions const setUserInfo = (data: any) => { - name.value = data.name - token.value = data.token + state.value.userInfo = data } - const loginOut = () => { + const setCustomerId = (data: string) => { + state.value.customerId = data + } + + const setToken = (data: string) => { + state.value.token = data + } + + const getGenerateParams = () => { + return state.value.generateParams + } + + const setGenerateParams = (data: any) => { + state.value.generateParams = data + } + + const resetGenerateParams = () => { + state.value.customerId = '' + state.value.generateParams = { + stylistId: '', + sex: '' + } + } + + const login = async (data: any) => { + return new Promise((resolve, reject) => {}) + } + + const logOut = () => { // 处理退出登录的一些逻辑 - return new Promise((rez) => { - rez('111') + return new Promise((resolve) => { + state.value.token = '' + state.value.userInfo = {} + state.value.customerId = '' + resetGenerateParams() + resolve('') }) } return { - // state - num, - name, - token, - // getters + state, getUserInfo, - // actions + setToken, setUserInfo, - loginOut + setCustomerId, + setGenerateParams, + getGenerateParams, + resetGenerateParams, + logOut, + login } }) diff --git a/src/utils/request.ts b/src/utils/request.ts index cd0ea23..5a711e9 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -10,7 +10,7 @@ import { useOverallStore } from '@/stores' // 创建axios实例 console.log(import.meta.env.VITE_APP_URL,123) const service = axios.create({ - baseURL: import.meta.env.VITE_APP_URL, // api的base_url + // baseURL: import.meta.env.VITE_APP_URL, // api的base_url // baseURL: import.meta.env.VITE_APP_URL, // api的base_url timeout: 20000, // 请求超时时间 }) diff --git a/src/views/asistant/components/NoticeItem.vue b/src/views/asistant/components/NoticeItem.vue index 7b9134a..31fb18a 100644 --- a/src/views/asistant/components/NoticeItem.vue +++ b/src/views/asistant/components/NoticeItem.vue @@ -13,8 +13,7 @@
- - diff --git a/src/views/asistant/components/NoticeList.vue b/src/views/asistant/components/NoticeList.vue index 9f578ca..e2842a3 100644 --- a/src/views/asistant/components/NoticeList.vue +++ b/src/views/asistant/components/NoticeList.vue @@ -1,7 +1,7 @@