From 4167ed652a17b0771c5511b9839ab1aa7c0dd7d6 Mon Sep 17 00:00:00 2001 From: wangxiaowei <1121133807@qq.com> Date: Thu, 9 Apr 2026 15:12:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=B8=8D=E8=A6=81=E7=9A=84?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- env/.env.development | 6 +- src/App.vue | 1 - src/api/tea-room.ts | 75 --- src/api/teaSpecialist-order.ts | 84 --- src/api/user.ts | 1 - .../order/tea-specialist/order-detail.vue | 604 ------------------ .../order/tea-specialist/order-list.vue | 196 ------ src/hooks/useLocation.ts | 188 ------ src/pages/store/room-detail.vue | 2 +- 9 files changed, 4 insertions(+), 1153 deletions(-) delete mode 100644 src/api/teaSpecialist-order.ts delete mode 100644 src/bundle/order/tea-specialist/order-detail.vue delete mode 100644 src/bundle/order/tea-specialist/order-list.vue delete mode 100644 src/hooks/useLocation.ts diff --git a/env/.env.development b/env/.env.development index 62ed729..66c4c3f 100644 --- a/env/.env.development +++ b/env/.env.development @@ -8,10 +8,10 @@ VITE_DELETE_CONSOLE = false VITE_SHOW_SOURCEMAP = true # 请求地址 -VITE_SERVER_BASEURL = 'https://76458.com' +VITE_SERVER_BASEURL = 'https://test1.stnav.com' # 图片上传路径 -VITE_UPLOAD_BASEURL = 'https://76458.com/upload' +VITE_UPLOAD_BASEURL = 'https://test1.stnav.com/upload' # 上传图片请求地址 -VITE_UPLOAD_BASEURL = 'https://76458.com/storeapi/upload/image' +VITE_UPLOAD_BASEURL = 'https://test1.stnav.com/storeapi/upload/image' VITE_UPLOAD_IMAGE_URL = 'https://chaz.oss-cn-shanghai.aliyuncs.com/' \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index 7910d8c..8405d52 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,7 +2,6 @@ import { onHide, onLaunch, onShow } from '@dcloudio/uni-app' import { navigateToInterceptor } from '@/router/interceptor' import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only' - import { LOCATION_DEFAULT_CITY, LOCATION_DEFAULT_LAT, LOCATION_DEFAULT_LNG, LOCATION_LAT_KEY, LOCATION_LNG_KEY, LOCATION_CITY_KEY } from '@/hooks/useLocation' onLaunch((options) => { // 处理直接进入页面路由的情况:如h5直接输入路由、微信小程序分享后进入等 diff --git a/src/api/tea-room.ts b/src/api/tea-room.ts index ad59203..cd723fe 100644 --- a/src/api/tea-room.ts +++ b/src/api/tea-room.ts @@ -10,81 +10,6 @@ import type { } from '@/api/types/tea-room' import type { ITeaSpecialistFuture7DaysResult, ITeaSpecialistOrderDetailsResult } from '@/api/types/tea' -/** - * 经纬度转换为城市 - */ -export interface ILocationToCityParams { - latitude: number - longitude: number -} - -export function getLocationToCity(data: ILocationToCityParams) { - return http.Post<{ - message: string - result: { - ad_info: { - province: string - city: string - district: string - adcode: string - }, - location: { - lat: number - lng: number - } - } - }>('/api/common/cityAddress', - data, - { - meta: { ignoreAuth: true } - } - ) -} - -/** - * 获取门店列表 - */ -export interface IHomeTeaStoreListParams { - page: number - size: number - search: string - latitude: number - longitude: number -} - -export function getHomeTeaStoreList(data: IHomeTeaStoreListParams) { - 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) -} /** * 茶室详情 diff --git a/src/api/teaSpecialist-order.ts b/src/api/teaSpecialist-order.ts deleted file mode 100644 index 3fb8c98..0000000 --- a/src/api/teaSpecialist-order.ts +++ /dev/null @@ -1,84 +0,0 @@ -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/user.ts b/src/api/user.ts index 4259598..9c29a02 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -1,5 +1,4 @@ import { http } from '@/http/alova' -import type { IUserAddressListResult, IUserAddressDetailsResult, IUserCouponListResult } from '@/api/types/user' import type { IOrderListResult } from '@/api/types/teaSpecialist-order' import type { IUserResult } from '@/api/types/user' diff --git a/src/bundle/order/tea-specialist/order-detail.vue b/src/bundle/order/tea-specialist/order-detail.vue deleted file mode 100644 index c9ca8c4..0000000 --- a/src/bundle/order/tea-specialist/order-detail.vue +++ /dev/null @@ -1,604 +0,0 @@ - -{ - "layout": "default", - "style": { - "navigationStyle": "custom" - } -} - - - - - - - - diff --git a/src/bundle/order/tea-specialist/order-list.vue b/src/bundle/order/tea-specialist/order-list.vue deleted file mode 100644 index ac3c3aa..0000000 --- a/src/bundle/order/tea-specialist/order-list.vue +++ /dev/null @@ -1,196 +0,0 @@ -{ - "needLogin": true, - "layout": "default", - "style": { - "navigationStyle": "custom" - } -} - - - - - - - diff --git a/src/hooks/useLocation.ts b/src/hooks/useLocation.ts deleted file mode 100644 index fdcef75..0000000 --- a/src/hooks/useLocation.ts +++ /dev/null @@ -1,188 +0,0 @@ -import { getLocationToCity } from '@/api/tea-room' - -const LOCATION_EXPIRE_MS = 30 * 24 * 60 * 60 * 1000 // 定位缓存30天 -const LOCATION_DENY_INTERVAL = 60 * 60 * 1000 // 未授权定位,弹窗间隔1小时 - -export const LOCATION_EXPIRE_KEY = 'location_expire_time' // 定位缓存KEY -export const LOCATION_DEFAULT_CITY = '上海市' // 默认城市 -export const LOCATION_DEFAULT_LAT = 31.230393 // 上海经度 -export const LOCATION_DEFAULT_LNG = 121.473629 // 上海纬度 -export const LOCATION_DENY_TIME_KEY = 'location_deny_time' // 未授权定位,重新授权时间KEY -export const LOCATION_CITY_KEY = 'city' // 城市缓存KEY -export const LOCATION_LAT_KEY = 'latitude' // 城市缓存KEY -export const LOCATION_LNG_KEY = 'longitude' // 城市缓存KEY - -// 检查过期时间 -export function handleCheckLocationCacheHooks() { - const expire = uni.getStorageSync(LOCATION_EXPIRE_KEY) - if (expire && Date.now() > expire) { - uni.removeStorageSync(LOCATION_LAT_KEY) - uni.removeStorageSync(LOCATION_LNG_KEY) - uni.removeStorageSync(LOCATION_EXPIRE_KEY) - return false - } - return true -} - -// 设置经纬度缓存 -export function handleSetLocationCacheHooks(lat: number, lng: number) { - uni.setStorageSync(LOCATION_LAT_KEY, lat) - uni.setStorageSync(LOCATION_LNG_KEY, lng) - uni.setStorageSync(LOCATION_EXPIRE_KEY, Date.now() + LOCATION_EXPIRE_MS) -} - -// 初始化经纬度 -export async function handleEnsureLocationAuthHooks() { - // 1. 检查缓存 - if (handleCheckLocationCacheHooks()) { - const lat = uni.getStorageSync(LOCATION_LAT_KEY) - const lng = uni.getStorageSync(LOCATION_LNG_KEY) - if (lat && lng) return { lat, lng } - } - - // 2. 获取定位 - return new Promise<{ lat: number, lng: number, }>((resolve) => { - uni.authorize({ - scope: 'scope.userLocation', - success() { - uni.getLocation({ - type: 'gcj02', - success(res) { - handleSetLocationCacheHooks(res.latitude, res.longitude) - resolve({ lat: res.latitude, lng: res.longitude}) - }, - fail() { - // 定位失败,返回默认上海 - handleSetLocationCacheHooks(LOCATION_DEFAULT_LAT, LOCATION_DEFAULT_LNG) - resolve({ lat: LOCATION_DEFAULT_LAT, lng: LOCATION_DEFAULT_LNG}) - } - }) - }, - fail() { - // 用户拒绝授权 - if (shouldShowAuthModal()) { - uni.setStorageSync(LOCATION_DENY_TIME_KEY, Date.now()) - uni.showModal({ - title: '提示', - content: '需要获取您的地理位置,请授权定位服务', - showCancel: false, - success: () => { - // 可引导用户去设置页面 - uni.openSetting({}) - } - }) - } - // 返回默认上海 - handleSetLocationCacheHooks(LOCATION_DEFAULT_LAT, LOCATION_DEFAULT_LNG) - resolve({ lat: LOCATION_DEFAULT_LAT, lng: LOCATION_DEFAULT_LNG }) - } - }) - }) -} - -/** - * 检查并弹窗授权地理位置(每小时弹一次,授权后自动获取定位) - * 返回 Promise,true 表示已授权,false 表示未授权 - */ -export function checkLocationAuthWithModal(): Promise<{ lat: number, lng: number } | false> { - return new Promise((resolve) => { - uni.getSetting({ - success(settingRes) { - const hasAuth = settingRes.authSetting && settingRes.authSetting['scope.userLocation'] - if (hasAuth) { - // 已授权,自动获取并返回经纬度 - uni.getLocation({ - type: 'gcj02', - success(res) { - handleSetLocationCacheHooks(res.latitude, res.longitude) - resolve({ lat: res.latitude, lng: res.longitude }) - }, - fail() { - resolve(false) - } - }) - } else { - // 未授权,判断是否需要弹窗 - const lastDeny = uni.getStorageSync(LOCATION_DENY_TIME_KEY) - - if (!lastDeny || (Date.now() - lastDeny > LOCATION_DENY_INTERVAL)) { - - uni.setStorageSync(LOCATION_DENY_TIME_KEY, Date.now()) - uni.showModal({ - title: '提示', - content: '需要获取您的地理位置,请授权定位服务', - showCancel: false, - success: () => { - uni.openSetting({ - success(openRes) { - const nowAuth = openRes.authSetting && openRes.authSetting['scope.userLocation'] - if (nowAuth) { - // 用户授权后,自动获取并返回经纬度 - uni.getLocation({ - type: 'gcj02', - success(res) { - handleSetLocationCacheHooks(res.latitude, res.longitude) - resolve({ lat: res.latitude, lng: res.longitude }) - }, - fail() { - resolve(false) - } - }) - } else { - resolve(false) - } - } - }) - } - }) - } else { - resolve(false) - } - } - }, - fail() { - resolve(false) - } - }) - }) -} - - -/** - * 设置城市 - */ -export function setLocationCity(city: string) { - uni.setStorageSync(LOCATION_CITY_KEY, city) -} - -/** - * 经纬度转换为城市 - * @returns - */ -export async function handleGetLocationCity(lat: number, lng: number) { - try { - console.log("🚀 ~ handleGetLocationCity ~ res:", lat, lng) - - const res = await getLocationToCity({ latitude: lat, longitude: lng }) - if (res.message == "Success") { - const params = { - latitude: res.result.location.lat, - longitude: res.result.location.lng, - city: res.result.ad_info.city - } - setLocationCity(params.city) - // uni.$emit('locationUpdate', params) // 通知页面 - return params - } else { - setLocationCity(LOCATION_DEFAULT_CITY) - } - } catch (error) { - setLocationCity(LOCATION_DEFAULT_CITY) - } -} - -// 检查是否需要弹授权框 -function shouldShowAuthModal() { - const lastDeny = uni.getStorageSync(LOCATION_DENY_TIME_KEY) - return !lastDeny || (Date.now() - lastDeny > LOCATION_DENY_INTERVAL) -} diff --git a/src/pages/store/room-detail.vue b/src/pages/store/room-detail.vue index 3204406..4fb0822 100644 --- a/src/pages/store/room-detail.vue +++ b/src/pages/store/room-detail.vue @@ -41,7 +41,7 @@ -