From 0cad65c2954ef3a28bed9ea1605c354dd5da6475 Mon Sep 17 00:00:00 2001 From: wangxiaowei <1121133807@qq.com> Date: Wed, 12 Nov 2025 17:40:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=94=B6=E8=97=8F=E8=8C=B6?= =?UTF-8?q?=E5=AE=A4=E6=8E=A5=E5=8F=A3=E5=92=8C=E5=AE=8C=E5=96=84=E8=8C=B6?= =?UTF-8?q?=E5=AE=A4=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/.env | 13 +- src/api/home.ts | 12 + src/api/login.ts | 44 ++- src/api/tea-room.ts | 91 ++++++ src/api/teaSpecialist-order.ts | 84 ++++++ src/api/types/home.ts | 0 src/api/types/login.ts | 1 + src/api/types/tea-room.ts | 56 ++++ src/api/types/teaSpecialist-order.ts | 17 ++ src/api/types/user.ts | 50 ++++ src/api/user.ts | 131 +++++++++ src/bundle/collect/collect.vue | 250 +++++++++------- src/bundle/order/douyin/order-list.vue | 1 + src/bundle/order/tea-room/order-list.vue | 1 + .../order/tea-specialist/order-detail.vue | 271 ++++++++++-------- .../order/tea-specialist/order-list.vue | 153 +++++----- src/bundle/tea-room/room.vue | 111 ++++--- src/components/Pay.vue | 3 +- src/hooks/useLocation.ts | 94 +++++- src/hooks/useTeaSpecialistOrder.ts | 97 +++++++ src/http/alova.ts | 6 +- src/http/tools/enum.ts | 6 +- src/manifest.json | 4 +- src/pages.json | 4 + src/pages/city/city.vue | 33 ++- src/pages/index/index.vue | 153 ++++++---- src/pages/login/login.vue | 49 +++- src/pages/my/my.vue | 78 ++--- src/pages/search/search.vue | 119 ++++++-- src/router/interceptor.ts | 3 +- src/store/user.ts | 36 ++- src/utils/order.ts | 56 +++- 32 files changed, 1522 insertions(+), 505 deletions(-) create mode 100644 src/api/home.ts create mode 100644 src/api/tea-room.ts create mode 100644 src/api/teaSpecialist-order.ts create mode 100644 src/api/types/home.ts create mode 100644 src/api/types/tea-room.ts create mode 100644 src/api/types/teaSpecialist-order.ts create mode 100644 src/api/types/user.ts create mode 100644 src/api/user.ts create mode 100644 src/hooks/useTeaSpecialistOrder.ts diff --git a/env/.env b/env/.env index f1a5320..a63ca5a 100644 --- a/env/.env +++ b/env/.env @@ -2,7 +2,7 @@ VITE_APP_TITLE = '茶址' VITE_APP_PORT = 9000 VITE_UNI_APPID = '__UNI__D1E5001' -VITE_WX_APPID = 'wxa2abb91f64032a2b' +VITE_WX_APPID = 'wx63e106209b842919' # h5部署网站的base,配置到 manifest.config.ts 里的 h5.router.base VITE_APP_PUBLIC_BASE=/ @@ -19,13 +19,4 @@ VITE_APP_PROXY=false VITE_APP_PROXY_PREFIX = '/api' # 第二个请求地址 (目前alova中可以使用) -VITE_SERVER_BASEURL = 'https://cz.stnav.com' - -# 默认地址 -VITE_DEFAULT_LONGITUDE = 113.665412 -VITE_DEFAULT_LATITUDE = 34.757975 -VITE_DEFAULT_ADDRESS = '上海市' -VITE_DEFAULT_LOCATION_EXPIRE_MS = 30 * 24 * 60 * 60 * 1000 # 30天 -VITE_DEFAULT_LOCATION_EXPIRE_KEY = 'location_expire_time' -VITE_DEFAULT_LOCATION_DENY_TIME_KEY = 'location_deny_time' -VITE_DEFAULT_LOCATION_DENY_INTERVAL = 60 * 60 * 1000 # 1小时 \ No newline at end of file +VITE_SERVER_BASEURL = 'https://cz.stnav.com' \ No newline at end of file diff --git a/src/api/home.ts b/src/api/home.ts new file mode 100644 index 0000000..6396bab --- /dev/null +++ b/src/api/home.ts @@ -0,0 +1,12 @@ +import { http } from '@/http/alova' + +/** + * 获取首页轮播图 + */ +export function getHomeBannerList() { + return http.Post<{ list: Array<{ address: string;}> }>('/api/index/carouselLists', null, + { + meta: { ignoreAuth: true } + } + ) +} \ No newline at end of file diff --git a/src/api/login.ts b/src/api/login.ts index 670e5f3..2d8c49e 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -1,5 +1,6 @@ import type { ICaptcha, IUpdateInfo, IUpdatePassword, IUserInfoVo, IUserLogin } from './types/login' -import { http } from '@/http/http' +import { http } from '@/http/alova' + /** * 登录表单 @@ -11,12 +12,21 @@ export interface ILoginForm { uuid: string } +/** + * 手机密码登录 + */ +export interface IMobileLoginForm { + account: string + terminal: number + scene: number +} + /** * 获取验证码 * @returns ICaptcha 验证码 */ export function getCode() { - return http.get('/user/getCode') + return http.Get('/user/getCode') } /** @@ -24,35 +34,48 @@ export function getCode() { * @param loginForm 登录表单 */ export function login(loginForm: ILoginForm) { - return http.post('/user/login', loginForm) + return http.Post('/api/user/login', loginForm) +} + +/** + * 用户登录 + * @param loginForm 登录表单 + */ +export function mobileLogin(loginForm: IMobileLoginForm) { + return http.Post('/api/login/account', + loginForm, + { + meta: { ignoreAuth: true } // 忽略认证 + } + ) } /** * 获取用户信息 */ export function getUserInfo() { - return http.get('/user/info') + return http.Get('/api/user/info') } /** * 退出登录 */ export function logout() { - return http.get('/user/logout') + return http.Get('/user/logout') } /** * 修改用户信息 */ export function updateInfo(data: IUpdateInfo) { - return http.post('/user/updateInfo', data) + return http.Get('/user/updateInfo', data) } /** * 修改用户密码 */ export function updateUserPassword(data: IUpdatePassword) { - return http.post('/user/updatePassword', data) + return http.Get('/user/updatePassword', data) } /** @@ -79,5 +102,10 @@ export function getWxCode() { * @returns Promise 包含登录结果 */ export function wxLogin(data: { code: string }) { - return http.post('/user/wxLogin', data) + return http.Post('/api/login/mnpLogin', + data, + { + meta: { ignoreAuth: true } // 忽略认证 + } + ) } diff --git a/src/api/tea-room.ts b/src/api/tea-room.ts new file mode 100644 index 0000000..0db1bdd --- /dev/null +++ b/src/api/tea-room.ts @@ -0,0 +1,91 @@ +import { http } from '@/http/alova' +import type { IHomeTeaRoomListResult, IOpenCityListResult, ITeaRoomDetailResult } from '@/api/types/tea-room' + +/** + * 获取茶室列表 + */ +export interface IHomeTeaRoomListParams { + page: number + size: number + search: string + latitude: number + longitude: number +} + +export function getHomeTeaRoomList(data: any) { + return http.Post('/api/teaStore/teaStoreLists', + data, + { + meta: { ignoreAuth: true } + } + ) +} + +/** + * 获取茶室开通城市列表 + */ +export function getOpenCityList() { + return http.Post('/api/teaStore/teaStoreCity', + { + meta: { ignoreAuth: true } + } + ) +} + +/** + * 茶室搜索历史 + */ +export function getTeaRoomSearchHistory() { + return http.Post<{ list: Array }>('/api/teaStore/teaStoreSearchHistory') +} + +/** + * 清除茶室搜索历史 + */ +export function clearTeaRoomSearchHistory() { + return http.Post('/api/teaStore/delTeaStoreSearchHistory', null) +} + +/** + * 茶室详情 + */ +export interface IRoomDetailParams { + id: number + latitude: number + longitude: number + user_id: number +} + +export function getTeaRoomDetail(data: IRoomDetailParams) { + return http.Post('/api/teaStore/teaStoreDetails', + data + ) +} + +/** + * 收藏茶室 + */ +export interface ICollectTeaRoomParams { + id: number + status: number // 1:收藏 0:取消收藏 +} + +export function collectTeaRoom(data: ICollectTeaRoomParams) { + return http.Post('/api/teaStore/teaStoreCollect', + data + ) +} + +/** + * 收藏的茶室列表 + */ +export interface ICollectTeaRoomListParams { + page: number + size: number +} + +export function getCollectTeaRoomList(data: ICollectTeaRoomListParams) { + return http.Post('/api/teaStore/teaStoreCollectList', + data + ) +} \ No newline at end of file diff --git a/src/api/teaSpecialist-order.ts b/src/api/teaSpecialist-order.ts new file mode 100644 index 0000000..3fb8c98 --- /dev/null +++ b/src/api/teaSpecialist-order.ts @@ -0,0 +1,84 @@ +import { http } from '@/http/alova' +import type { IOrderListResult, IOrderDetailsResult } from '@/api/types/teaSpecialist-order' + +/** + * 茶艺师-获取订单列表 + */ +export interface ITeaSpecialistOrderListParams { + page: number + size: number + order_status: string + search: string +} + +export function getTeaSpecialistOrderList(data: ITeaSpecialistOrderListParams) { + return http.Post('/api/order/orderList', + data + ) +} + +/** + * 茶艺师-获取订单详情 + */ +export interface ITeaSpecialistOrderDetailsParams { + id: number +} + +export function getTeaSpecialistOrderDetails(data: ITeaSpecialistOrderDetailsParams) { + return http.Post('/api/order/orderDetails', + data + ) +} + +/** + * 茶艺师-取消订单 + */ +export interface ICancelTeaSpecialistOrderParams { + id: number +} + +export function cancelTeaSpecialistOrder(data: ICancelTeaSpecialistOrderParams) { + return http.Post('/api/order/cancelOrder', + data + ) +} + +/** + * 茶艺师-删除订单 + */ +export interface IDeleteTeaSpecialistOrderParams { + id: number +} + +export function deleteTeaSpecialistOrder(data: IDeleteTeaSpecialistOrderParams) { + return http.Post('/api/order/delOrder', + data + ) +} + +/** + * 茶艺师-确认(完成)订单 + */ +export interface IConfirmTeaSpecialistOrderParams { + id: number +} + +export function confirmTeaSpecialistOrder(data: IConfirmTeaSpecialistOrderParams) { + return http.Post('/api/order/userConfirmOrder', + data + ) +} + +/** + * 茶艺师-订单退款 + */ +export interface IRefundTeaSpecialistOrderParams { + id: number + order_type: string +} + +export function refundTeaSpecialistOrder(data: IRefundTeaSpecialistOrderParams) { + return http.Post('/api/pay/refund', + data + ) +} \ No newline at end of file diff --git a/src/api/types/home.ts b/src/api/types/home.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/api/types/login.ts b/src/api/types/login.ts index fb911a9..108f726 100644 --- a/src/api/types/login.ts +++ b/src/api/types/login.ts @@ -11,6 +11,7 @@ export interface IUserInfoVo { channel: number is_new_user: number mobile: string + username: string } /** diff --git a/src/api/types/tea-room.ts b/src/api/types/tea-room.ts new file mode 100644 index 0000000..e534c76 --- /dev/null +++ b/src/api/types/tea-room.ts @@ -0,0 +1,56 @@ +/** + * 茶室列表接口返回数据 + */ +export interface IHomeTeaRoomListResult { + count: number + list: Array + more: number + page: string + size: string +} + +/** + * 茶室开通城市列表接口返回数据 + */ +export interface IOpenCityListResult { + list: Array<{ + city_id: number + del: number + dtime: string + name: string + status: number + }> +} + +/** + * 茶室详情接口返回数据 + */ +export interface ITeaRoomDetailResult { + details: { + address: string + city: string + city_id: number + collect: number + contact_phone: string + customer_service: string + day_time: string + del: number + district: string + district_id: number + dtime: string + end_time: string + id: number + image: string + latitude: string + longitude: string + name: string + operation_type: number, + province: string + province_id: number + shop_status: number + star: number + start_time: string + status: number + update_dtime: string + } +} \ No newline at end of file diff --git a/src/api/types/teaSpecialist-order.ts b/src/api/types/teaSpecialist-order.ts new file mode 100644 index 0000000..15bd80d --- /dev/null +++ b/src/api/types/teaSpecialist-order.ts @@ -0,0 +1,17 @@ +/** + * 订单列表返回数据 + */ +export interface IOrderListResult { + count: number + list: Array + more: number + page: string + size: string +} + +/** + * 订单详情返回数据 + */ +export interface IOrderDetailsResult { + details: any +} \ No newline at end of file diff --git a/src/api/types/user.ts b/src/api/types/user.ts new file mode 100644 index 0000000..1080b4f --- /dev/null +++ b/src/api/types/user.ts @@ -0,0 +1,50 @@ +/** + * 用户信息结果类型 + */ +export interface IUserInfoResult { + account: string + avatar: string + create_time: string + has_auth: boolean + has_password: boolean + id: number + mobile: string + nickname: string + real_name: string + sex: string + sn: number + user_money: string + version: number +} + +/** + * 地址列表 + */ +export interface IUserAddressListResult { + 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 interface IUserAddressDetailsResult extends IUserAddressListResult { + address_details: IUserAddressListResult +} + +/** + * 优惠券列表 + */ +export interface IUserCouponListResult { + no_use: Array + use: Array +} \ No newline at end of file diff --git a/src/api/user.ts b/src/api/user.ts new file mode 100644 index 0000000..7d8891f --- /dev/null +++ b/src/api/user.ts @@ -0,0 +1,131 @@ +import { http } from '@/http/alova' +import type { IUserAddressListResult, IUserAddressDetailsResult, IUserCouponListResult } from '@/api/types/user' +import type { IOrderListResult } from '@/api/types/teaSpecialist-order' + + +/** + * 获取用户个人信息 + */ +export function getUserInfo() { + return http.Post('/api/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 +} + +export function getCoupons(data: IGetCouponsParams) { + return http.Post('/api/UserCoupon/UserCoupinList', data) +} + +/** + * 优惠券列表(从个人中心点击进去) + */ +export interface IGetMyCouponsParams { + status: 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) +} \ No newline at end of file diff --git a/src/bundle/collect/collect.vue b/src/bundle/collect/collect.vue index 5f8f5ae..96cfae8 100644 --- a/src/bundle/collect/collect.vue +++ b/src/bundle/collect/collect.vue @@ -16,99 +16,109 @@ - - - - - - - - - - - - - - 凝香茶业 - - - - - - - 100+收藏 - - - - 营业时间:00:00-23:59 - - - 打烊了 - - - - - - 青浦区仓路478号 - - - - - - - - - - - - - 可约9:00 - - - - - - 凝香茶业 - - - - - - 金牌茶艺师 - - - - - - - - - 上门服务 - - - 到点服务 - - - 28岁 - - - - - - - - 100+收藏 - - - - ¥180 - /小时 - - - - + + + + + + + + + + + + + @@ -117,31 +127,69 @@ diff --git a/src/bundle/order/tea-specialist/order-list.vue b/src/bundle/order/tea-specialist/order-list.vue index 0779752..2b7b580 100644 --- a/src/bundle/order/tea-specialist/order-list.vue +++ b/src/bundle/order/tea-specialist/order-list.vue @@ -1,4 +1,5 @@ { + "needLogin": true, "layout": "default", "style": { "navigationStyle": "custom" @@ -8,25 +9,25 @@ diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue index 37266bc..64579e4 100644 --- a/src/pages/login/login.vue +++ b/src/pages/login/login.vue @@ -19,16 +19,18 @@ - 手机号一键登录 - 其它手机号登录 + 立即登录 + 测试-账号登录 + + - + - 我已阅读并同意 《服务协议》《隐私政策》,未注册手机号登录后将自动你为您创建账号 + 我已阅读并同意 《服务协议》《隐私政策》,未注册手机号登录后将自动你为您创建账号 @@ -36,19 +38,46 @@ diff --git a/src/pages/search/search.vue b/src/pages/search/search.vue index 8c8bd25..7599315 100644 --- a/src/pages/search/search.vue +++ b/src/pages/search/search.vue @@ -1,5 +1,6 @@ { + "needLogin": true, "layout": "tabbar", "style": { // 'custom' 表示开启自定义导航栏,默认 'default' @@ -11,57 +12,125 @@ - - + - + 历史搜索 - - 茶叶 + + {{ item.content }} - + + + diff --git a/src/router/interceptor.ts b/src/router/interceptor.ts index 3842f8a..2b0236f 100644 --- a/src/router/interceptor.ts +++ b/src/router/interceptor.ts @@ -13,7 +13,8 @@ const loginRoute = import.meta.env.VITE_LOGIN_URL function isLogined() { const userStore = useUserStore() - return !!userStore.userInfo.username + console.log("🚀 ~ isLogined ~ userStore.isLoggedIn:", userStore.isLoggedIn) + return !!userStore.isLoggedIn } const isDev = import.meta.env.DEV diff --git a/src/store/user.ts b/src/store/user.ts index 4ed0b98..a4d92a3 100644 --- a/src/store/user.ts +++ b/src/store/user.ts @@ -7,6 +7,7 @@ import { logout as _logout, wxLogin as _wxLogin, getWxCode, + mobileLogin as _mobileLogin } from '@/api/login' import { toast } from '@/utils/toast' @@ -22,9 +23,13 @@ const userInfoState: IUserInfoVo = { account: '', channel: 0, is_new_user: 1, - mobile: '' + mobile: '', + username: '', } +// 默认未登录 +const isLoggedIn = ref(false) + export const useUserStore = defineStore( 'user', () => { @@ -52,16 +57,16 @@ export const useUserStore = defineStore( userInfo.value = { ...userInfoState } uni.removeStorageSync('userInfo') uni.removeStorageSync('token') + isLoggedIn.value = false } /** * 获取用户信息 */ const getUserInfo = async () => { const res = await _getUserInfo() - const userInfo = res.data + const userInfo = res setUserInfo(userInfo) uni.setStorageSync('userInfo', userInfo) - uni.setStorageSync('token', userInfo.token) // TODO 这里可以增加获取用户路由的方法 根据用户的角色动态生成路由 return res } @@ -83,6 +88,19 @@ export const useUserStore = defineStore( return res } + /** + * 账号密码登录 + */ + const mobileLogin = async (account: string, terminal: number, scene: number) => { + const res = await _mobileLogin({ account, terminal, scene}) + console.log("🚀 ~ mobileLogin ~ res:", res) + uni.setStorageSync('token', res.token) + + await getUserInfo() + isLoggedIn.value = true + return res + } + /** * 退出登录 并 删除用户信息 */ @@ -99,8 +117,12 @@ export const useUserStore = defineStore( console.log('微信登录code', data) const res = await _wxLogin(data) - await getUserInfo() - return res + uni.setStorageSync('token', res.token) + + const user = await getUserInfo() + + isLoggedIn.value = true + return res && user } return { @@ -111,7 +133,9 @@ export const useUserStore = defineStore( setUserAvatar, logout, setUserInfo, - removeUserInfo + removeUserInfo, + isLoggedIn, + mobileLogin } }, { diff --git a/src/utils/order.ts b/src/utils/order.ts index c082cf4..39e9041 100644 --- a/src/utils/order.ts +++ b/src/utils/order.ts @@ -165,4 +165,58 @@ export const OrderStatusTitle: Record> [OrderStatus.AfterSaleApply]: '申请售后', [OrderStatus.AfterSaleProcessing]: '申请售后中' } -} \ No newline at end of file +} + + +// 茶艺师订单状态数字(根据UI图还缺已退款、待接单、售后中、售后完成) +export enum TeaSpecialistOrderStatus { + Pending = 0, // 待付款(未支付) + Pay = 1, // 预约单、已预约(已支付) + Cancelled = 2, // 已取消(订单取消) + Confirm = 3, // 待确认(已接单) + Serving = 4, // 服务中 + Finished = 5, // 已完成 +} + +// 茶艺师订单状态文本 +export enum TeaSpecialistOrderStatusText { + All = 'all', // 待付款 + Pending = 'pending', // 待付款 + Pay = 'pay', // 已支付(预约单、已预约) + Cancelled = 'cancelled', // 已取消 + Confirm = 'confirm', // 待确认 + Serving = 'serving', // 服务中 + Finished = 'finished', // 已完成 +} + +// 状态内容映射 +export const TeaSpecialistOrderStatusTextValue: Record = { + [TeaSpecialistOrderStatus.Pending]: { + title: '等待付款' + }, + [TeaSpecialistOrderStatus.Pay]: { + title: '已预约' + }, + [TeaSpecialistOrderStatus.Cancelled]: { + title: '订单取消' + }, + [TeaSpecialistOrderStatus.Confirm]: { + title: '订单待确认' + }, + [TeaSpecialistOrderStatus.Serving]: { + title: '服务中' + }, + [TeaSpecialistOrderStatus.Finished]: { + title: '交易完成' + }, +} + +export const TeaSpecialistOrderStatusValue: Record = { + [TeaSpecialistOrderStatusText.All]: '', + [TeaSpecialistOrderStatusText.Pending]: 0, + [TeaSpecialistOrderStatusText.Pay]: 1, + [TeaSpecialistOrderStatusText.Cancelled]: 2, + [TeaSpecialistOrderStatusText.Confirm]: 3, + [TeaSpecialistOrderStatusText.Serving]: 4, + [TeaSpecialistOrderStatusText.Finished]: 5, +}