From 018a784a8ca1f59d79fd539d06e7480dbb1acd99 Mon Sep 17 00:00:00 2001 From: wangxiaowei <1121133807@qq.com> Date: Wed, 17 Dec 2025 00:45:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/.env | 11 +- src/api/login.ts | 29 +--- src/api/store.ts | 22 +++ src/api/user.ts | 145 +++-------------- src/bundle/account/switch.vue | 80 ++++++---- src/bundle/coupon/coupon.vue | 211 ------------------------- src/bundle/coupon/my-coupon.vue | 182 --------------------- src/bundle/profile/change-mobile.vue | 30 ++-- src/bundle/profile/change-password.vue | 1 + src/bundle/profile/profile.vue | 50 +++--- src/components/RenewTime.vue | 103 ++++++++++++ src/http/alova.ts | 22 +-- src/pages/index/index.vue | 75 +++++++-- src/pages/login/login.vue | 211 +++++++++---------------- src/pages/login/mobile.vue | 1 + src/pages/my/my.vue | 17 +- src/pages/store/renew.vue | 16 +- src/store/index.ts | 1 + src/store/store.ts | 48 ++++++ src/store/user.ts | 16 +- 20 files changed, 455 insertions(+), 816 deletions(-) create mode 100644 src/api/store.ts delete mode 100644 src/bundle/coupon/coupon.vue delete mode 100644 src/bundle/coupon/my-coupon.vue create mode 100644 src/components/RenewTime.vue create mode 100644 src/store/store.ts diff --git a/env/.env b/env/.env index e8d1d55..b496484 100644 --- a/env/.env +++ b/env/.env @@ -2,7 +2,7 @@ VITE_APP_TITLE = '茶址' VITE_APP_PORT = 9002 VITE_UNI_APPID = '__UNI__D1E5001' -VITE_WX_APPID = 'wx63e106209b842919' +VITE_WX_APPID = 'wx14a689c7c318bea8' # h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base VITE_APP_PUBLIC_BASE=/ @@ -15,8 +15,11 @@ VITE_SERVER_BASEURL = 'https://cz.stnav.com' VITE_UPLOAD_BASEURL = 'https://cz.stnav.com/upload' # h5是否需要配置代理 -VITE_APP_PROXY=false -VITE_APP_PROXY_PREFIX = '/api' +VITE_APP_PROXY=true +VITE_APP_PROXY_PREFIX = '/storeapi' # 第二个请求地址 (目前alova中可以使用) -VITE_SERVER_BASEURL = 'https://cz.stnav.com' \ No newline at end of file +VITE_SERVER_BASEURL = 'https://cz.stnav.com' + +# 上传图片请求地址 +VITE_UPLOAD_BASEURL = 'https://cz.stnav.com/storeapi/upload/image' \ No newline at end of file diff --git a/src/api/login.ts b/src/api/login.ts index 2d8c49e..07697da 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -1,7 +1,6 @@ import type { ICaptcha, IUpdateInfo, IUpdatePassword, IUserInfoVo, IUserLogin } from './types/login' import { http } from '@/http/alova' - /** * 登录表单 */ @@ -17,8 +16,10 @@ export interface ILoginForm { */ export interface IMobileLoginForm { account: string - terminal: number + password: string scene: number + terminal: number + channel: number } /** @@ -34,7 +35,7 @@ export function getCode() { * @param loginForm 登录表单 */ export function login(loginForm: ILoginForm) { - return http.Post('/api/user/login', loginForm) + return http.Post('/storeapi/user/login', loginForm) } /** @@ -42,7 +43,7 @@ export function login(loginForm: ILoginForm) { * @param loginForm 登录表单 */ export function mobileLogin(loginForm: IMobileLoginForm) { - return http.Post('/api/login/account', + return http.Post('/storeapi/storeLogin/account', loginForm, { meta: { ignoreAuth: true } // 忽略认证 @@ -54,28 +55,14 @@ export function mobileLogin(loginForm: IMobileLoginForm) { * 获取用户信息 */ export function getUserInfo() { - return http.Get('/api/user/info') + return http.Post('/storeapi/user/info') } /** * 退出登录 */ export function logout() { - return http.Get('/user/logout') -} - -/** - * 修改用户信息 - */ -export function updateInfo(data: IUpdateInfo) { - return http.Get('/user/updateInfo', data) -} - -/** - * 修改用户密码 - */ -export function updateUserPassword(data: IUpdatePassword) { - return http.Get('/user/updatePassword', data) + return http.Post('/storeapi/storeLogin/logout') } /** @@ -102,7 +89,7 @@ export function getWxCode() { * @returns Promise 包含登录结果 */ export function wxLogin(data: { code: string }) { - return http.Post('/api/login/mnpLogin', + return http.Post('/storeapi/login/mnpLogin', data, { meta: { ignoreAuth: true } // 忽略认证 diff --git a/src/api/store.ts b/src/api/store.ts new file mode 100644 index 0000000..c182770 --- /dev/null +++ b/src/api/store.ts @@ -0,0 +1,22 @@ +import { http } from '@/http/alova' + +/** + * 获取门店列表 + */ +export function getStoreList() { + return http.Post('/storeapi/Store/userStoreList') +} + +/** + * 门店详情 + */ +export function getStoreDetails(id: number) { + return http.Post('/storeapi/store/userStoreDetails', { id }) +} + +/** + * 切换门店信息 + */ +export function switchStore(id: number) { + return http.Post('/storeapi/store/switchStore', { id }) +} \ No newline at end of file diff --git a/src/api/user.ts b/src/api/user.ts index 1f27774..a146356 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -8,139 +8,34 @@ import type { IUserResult } from '@/api/types/user' * 获取用户个人信息 */ export function getUserInfo() { - return http.Post('/api/user/info') + return http.Post('/storeapi/user/info') } -/** - * 获取优惠券列表 - */ -export function getUserCoupons() { - return http.Post('/api/UserCoupon/UserCoupinList') -} - -/** - * 获取用户地址 - */ -export function getUserAddress() { - return http.Post('/api/user/addressList') -} - -/** - * 用户添加地址 - */ -export interface IAddUserAddressParams { - id: number - contact: string - telephone: string - province: string - province_id?: number - city: string - city_id?: number - district: string - district_id?: number - address: string - is_default: number -} - -export function addUserAddress(data: IAddUserAddressParams) { - return http.Post('/api/user/addAddress', data) -} - -/** - * 编辑用户地址 - */ -export interface IEditUserAddressParams extends IAddUserAddressParams { - id: number -} - -export function editUserAddress(data: IAddUserAddressParams) { - return http.Post('/api/user/editAddress', data) -} - -/** - * 删除用户地址 - */ -export interface IDeleteUserAddressParams { - id: number -} - -export function deleteUserAddress(data: IDeleteUserAddressParams) { - return http.Post('/api/user/delAddress', data) -} - -/** - * 获取地址详情 - */ - -export interface IUserAddressDetailsParams extends IDeleteUserAddressParams {} -export function userAddressDetails(data: IUserAddressDetailsParams) { - return http.Post('/api/user/addressDetails', data) -} - -/** - * 优惠券列表(从订单页获取) - */ -export interface IGetCouponsParams { - id: number - numbers: number - type_id: number -} - -export function getCoupons(data: IGetCouponsParams) { - return http.Post('/api/UserCoupon/UserCoupinList', data) -} - -/** - * 优惠券列表(从个人中心点击进去) - */ -export interface IGetMyCouponsParams { - status: number - type_id: number -} -export function getMyCoupons(data: IGetMyCouponsParams) { - return http.Post('/api/UserCoupon/orderCoupinList', data) -} - -/** - * 个人中心优惠券 - */ -export function getMyCoupon() { - return http.Post('/api/UserCoupon/coupinList') -} - -/** - * 领取个人中心优惠券 - */ -export interface IClaimMyCouponParams { - id: number -} - -export function claimMyCoupon(data: IClaimMyCouponParams) { - return http.Post('/api/UserCoupon/receiveCoupon', data) -} - - -/** - * 金额使用记录 - */ -export interface IGetUserMoneyLogParams { - page: number - size: number - month: string -} - -export function getUserMoneyLog(data: IGetUserMoneyLogParams) { - return http.Post('/api/user/moneyLogList', data) -} /** * 修改用户信息 */ export interface IUpdateUserInfoParams { - field: string, - value: string | number + nickname?: string + avatar?: string + mobile?: number + band_mobile?: string + password?: string } export function updateUserInfo(data: IUpdateUserInfoParams) { - return http.Post('/api/user/setInfo', data) + console.log("🚀 ~ updateUserInfo ~ data:", data) + return http.Post('/storeapi/user/updateUser', data) +} + +/** + * 获取验证码 + */ +export interface IGetVerificationCodeParams { + mobile: string + scene: number +} + +export function getVerificationCode(data: IGetVerificationCodeParams) { + return http.Post('/storeapi/sms/sendCode', data) } diff --git a/src/bundle/account/switch.vue b/src/bundle/account/switch.vue index b50968c..5398b49 100644 --- a/src/bundle/account/switch.vue +++ b/src/bundle/account/switch.vue @@ -7,37 +7,26 @@ } - - diff --git a/src/pages/login/mobile.vue b/src/pages/login/mobile.vue index 301af16..0ee8062 100644 --- a/src/pages/login/mobile.vue +++ b/src/pages/login/mobile.vue @@ -1,4 +1,5 @@ { + "needLogin": true, "layout": "default", "style": { "navigationBarTitleText": "", diff --git a/src/pages/my/my.vue b/src/pages/my/my.vue index 72027a2..b2569b0 100644 --- a/src/pages/my/my.vue +++ b/src/pages/my/my.vue @@ -70,16 +70,14 @@ function formatAccount(account: string) { onShow(() => { const userStore = useUserStore() isLogin.value = userStore.isLoggedIn - console.log('🚀 ~ isLogin.value:', 1) + console.log("🚀 ~ isLogin.value:", isLogin.value) if (isLogin.value) { - console.log('🚀 ~ isLogin.value:', 3) // 获取用户详情信息接口 getUserInfo().then((res) => { user.value = res }) } else { - console.log('🚀 ~ isLogin.value:', 4) Object.keys(user.value).forEach((key) => { user.value[key] = '' }) @@ -88,8 +86,6 @@ onShow(() => { onLoad(() => { uni.$on('clearUser', () => { - console.log('🚀 ~ isLogin.value:', 2) - const userStore = useUserStore() isLogin.value = userStore.isLoggedIn @@ -107,10 +103,9 @@ const My = { // 跳转到个人信息 handleToProfile: () => { if (!isLogin.value) { - router.navigateTo('/bundle/profile/profile') - } - else { router.navigateTo('/pages/login/login') + } else { + router.navigateTo('/bundle/profile/profile') } }, @@ -192,11 +187,11 @@ const My = { - - {{ isLogin ? user.nickname : '立即登录' }} + + {{ isLogin ? user.nickname || '暂无昵称' : '立即登录' }} - + 账号: {{ formatAccount(user.account || user.mobile) }} diff --git a/src/pages/store/renew.vue b/src/pages/store/renew.vue index 1224d8e..d09cd18 100644 --- a/src/pages/store/renew.vue +++ b/src/pages/store/renew.vue @@ -14,7 +14,7 @@ - + 续单 @@ -37,8 +37,8 @@ 确定 - - + + @@ -53,6 +53,10 @@ import type { ITeaSpecialistFuture7DaysResult } from '@/api/types/tea' import { getNext7Days, renewTeaRoomOrder } from '@/api/tea-room' + // 续单 + const showRenewTimePopup = ref(false) + + // mescroll const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook const downOption = { @@ -150,6 +154,12 @@ // totalReserveMoney.value = Number(toTimes(params[3], order.value.room_price)) }, + /** + * 一键续订时间 + */ + handleChooseRenewTime: (item) => { + console.log("🚀 ~ item:", item) + } } diff --git a/src/store/index.ts b/src/store/index.ts index 6a276cd..8c71144 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -15,3 +15,4 @@ export default store // 模块统一导出 export * from './user' +export * from './store' diff --git a/src/store/store.ts b/src/store/store.ts new file mode 100644 index 0000000..629d9ae --- /dev/null +++ b/src/store/store.ts @@ -0,0 +1,48 @@ +import { defineStore } from 'pinia' + +interface IDefaultStoreVo { + id: number + name: string + index: number +} + +const defaultStoreState: IDefaultStoreVo = { + id: 0, + name: '', + index: 0, +} + +export const useStoreStore = defineStore( + 'store', + () => { + // 这里后续可添加店铺管理相关 state、action + const storeList = ref>([]) + const defaultStore = ref({...defaultStoreState}) + + /** + * 设置门店列表 + * @param stores + */ + const setStoreList = (stores: Array) => { + storeList.value = stores + } + + /** + * 设置默认选择的门店 + * @param store + */ + const setDefaultStore = (store: IDefaultStoreVo) => { + defaultStore.value = store + } + + return { + setStoreList, + storeList, + defaultStore, + setDefaultStore + } + }, + { + persist: true, + }, +) \ No newline at end of file diff --git a/src/store/user.ts b/src/store/user.ts index 97c47cb..a4c93c1 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -54,8 +54,9 @@ export const useUserStore = defineStore( const removeUserInfo = () => { isLoggedIn.value = false userInfo.value = { ...userInfoState } - uni.removeStorageSync('userInfo') - uni.removeStorageSync('token') + + // 清除所有缓存 + uni.clearStorageSync() } /** * 获取用户信息 @@ -89,9 +90,8 @@ export const useUserStore = defineStore( /** * 账号密码登录 */ - const mobileLogin = async (account: string, terminal: number, scene: number) => { - const res = await _mobileLogin({ account, terminal, scene}) - console.log("🚀 ~ mobileLogin ~ res:", res) + const mobileLogin = async (account: string, password: string, scene: number, terminal: number, channel: number) => { + const res = await _mobileLogin({ account, password, scene, terminal, channel }) uni.setStorageSync('token', res.token) await getUserInfo() @@ -103,11 +103,9 @@ export const useUserStore = defineStore( * 退出登录 并 删除用户信息 */ const logout = async () => { - // 清除所有缓存 - uni.clearStorageSync() - - _logout() + const res = await _logout() removeUserInfo() + return res } /** * 微信登录