对接接口

This commit is contained in:
wangxiaowei
2025-10-16 16:26:57 +08:00
parent 76da09be91
commit 2f59d0e8ba
21 changed files with 405 additions and 197 deletions

View File

@ -20,7 +20,7 @@
``` ```
#### 2. 页面或组件传创建的方法需要以当前文件名称作为对象按照驼峰命名 #### 2. 页面或组件传创建的方法需要以当前文件名称作为对象按照驼峰命名
``` ```
const detail = { const Detail = {
handleConfirmHour: () => { handleConfirmHour: () => {
if (totalHour.value <= 0) { if (totalHour.value <= 0) {
toast.info('至少起订N小时') toast.info('至少起订N小时')
@ -33,7 +33,7 @@
#### 3. 页面或组件传创建的内部方法需要放在函数最下面这种方法前面不需要加上handle #### 3. 页面或组件传创建的内部方法需要放在函数最下面这种方法前面不需要加上handle
``` ```
const detail = { const Detail = {
handleConfirmHour: () => { handleConfirmHour: () => {
if (totalHour.value <= 0) { if (totalHour.value <= 0) {
toast.info('至少起订N小时') toast.info('至少起订N小时')
@ -59,7 +59,7 @@
#### 4. 如果组件名称与定义的对象函数名冲突则对象函数名后面加上s #### 4. 如果组件名称与定义的对象函数名冲突则对象函数名后面加上s
``` ```
import coupon from '@/components/coupon/coupon.vue' import coupon from '@/components/coupon/coupon.vue'
const coupons = { const Coupons = {
handleConfirmHour: () => { handleConfirmHour: () => {
if (totalHour.value <= 0) { if (totalHour.value <= 0) {
toast.info('至少起订N小时') toast.info('至少起订N小时')

5
env/.env vendored
View File

@ -23,3 +23,8 @@ VITE_API_SECONDARY_URL = 'https://cz.stnav.com'
# 公众号APPID # 公众号APPID
VITE_WX_SERVICE_ACCOUNT_APPID = 'wx0224f558e3b3f499' VITE_WX_SERVICE_ACCOUNT_APPID = 'wx0224f558e3b3f499'
# 默认地址
VITE_DEFAULT_LONGITUDE = 113.665412
VITE_DEFAULT_LATITUDE = 34.757975
VITE_DEFAULT_ADDRESS = '上海市'

View File

@ -5,7 +5,7 @@
import {snsapiBaseAuthorize} from '@/hooks/useWeiXin' import {snsapiBaseAuthorize} from '@/hooks/useWeiXin'
import {initJweixinSDK} from '@/utils/jwexin' import {initJweixinSDK} from '@/utils/jwexin'
onLaunch((options) => { onLaunch(async (options) => {
// 处理直接进入页面路由的情况如h5直接输入路由、微信小程序分享后进入等 // 处理直接进入页面路由的情况如h5直接输入路由、微信小程序分享后进入等
// https://github.com/unibest-tech/unibest/issues/192 // https://github.com/unibest-tech/unibest/issues/192
console.log('App Launch', options) console.log('App Launch', options)
@ -17,8 +17,7 @@
} }
// 微信静默授权 // 微信静默授权
snsapiBaseAuthorize() await initJweixinSDK()
initJweixinSDK()
}) })
onShow((options) => { onShow((options) => {
console.log('App Show', options) console.log('App Show', options)

18
src/api/city.ts Normal file
View File

@ -0,0 +1,18 @@
import { http } from '@/http/alova'
/**
* 获取城市
*/
export interface ICityParams {
longitude: number
latitude: number
}
export function getCity(data: ICityParams) {
return http.Post('/api/Area/getArea',
data,
{
meta: { ignoreAuth: true}
}
)
}

View File

@ -4,24 +4,45 @@ import type { IIndexResult } from '@/api/types/home'
/** /**
* 获取首页数据 * 获取首页数据
*/ */
export interface IIndexData { export interface IIndexParams {
id: number id: number
} }
export function getDecorate(data: IIndexData) { export function getDecorate(data: IIndexParams) {
return http.Get('/api/index/decorate', {params: data}) return http.Get('/api/index/decorate', {
params: data,
meta: { ignoreAuth: true}
})
} }
/** /**
* 获取茶艺师等级 * 获取茶艺师等级
*/ */
export function getTeaSpecialistLevels() { export function getTeaSpecialistLevels() {
return http.Post('/api/Teamaster/teamasterLevel') return http.Post('/api/Teamaster/teamasterLevel',
null,
{
meta: { ignoreAuth: true}
}
)
} }
/** /**
* 获取茶艺师列表 * 获取茶艺师列表
*/ */
export function getTeaSpecialist() { export interface ITeaSpecialistParams {
return http.Post('/api/Teamaster/teamasterLevel') level_id: string
page: number
size: number
latitude: number
longitude: number
}
export function getTeaSpecialist(data: ITeaSpecialistParams) {
return http.Post('/api/Teamaster/teamasterList',
data,
{
meta: { ignoreAuth: true }
}
)
} }

View File

@ -9,5 +9,8 @@ export interface IJweiXinSignature {
} }
export function wxSignature(data: IJweiXinSignature) { export function wxSignature(data: IJweiXinSignature) {
return http.Get<IJweiXin>('/api/wechat/jsConfig', { params: data }) return http.Get<IJweiXin>('/api/wechat/jsConfig', {
params: data,
meta: { ignoreAuth: true }, // 用于切换请求地址
})
} }

View File

@ -11,22 +11,12 @@ export interface IWxSnsapiBaseLoginForm {
} }
export function wxSnsapiBaseLogin(data: IWxSnsapiBaseLoginForm) { export function wxSnsapiBaseLogin(data: IWxSnsapiBaseLoginForm) {
return http.Post<IUserInfoVo>('/api/login/oaLogin', data, { return http.Post<IUserInfoVo>('/api/login/oaLogin',
meta: { ignoreAuth: true }, // 忽略认证 data,
}) {
} meta: { ignoreAuth: true } // 忽略认证
}
/** )
* 手机验证码登录
*/
export interface IPhoneLoginForm {
account: number,
scene: number,
terminal: number
}
export function phoneLogin(data: IPhoneLoginForm) {
return http.Post<IUserLogin>('/api/login/oaLogin', data)
} }
/** /**
@ -38,7 +28,12 @@ export interface ISMSLogin {
} }
export function smsCode(data: ISMSLogin) { export function smsCode(data: ISMSLogin) {
return http.Post('/api/sms/sendCode',data) return http.Post<IUserInfoVo>('/api/sms/sendCode',
data,
{
meta: { ignoreAuth: true } // 忽略认证
}
)
} }
/** /**

20
src/api/tea.ts Normal file
View File

@ -0,0 +1,20 @@
import { http } from '@/http/alova'
import type { ITeaSpecialistDetailsResult } from '@/api/types/tea'
/**
* 获取茶艺师详情
*/
export interface ITeaSpecialistDetailsParams {
id: number
longitude: number
latitude: number
}
export function getTeaSpecialistDetails(data: ITeaSpecialistDetailsParams) {
return http.Post<ITeaSpecialistDetailsResult>('/api/Teamaster/teamasterDetails',
data,
{
meta: { ignoreAuth: true }
}
)
}

View File

@ -4,3 +4,14 @@
export interface IIndexResult { export interface IIndexResult {
data: String data: String
} }
/**
* 首页列表数据返回
*/
export interface IIndexListResult {
count: Number
list: Array<any>
more: Number
page: string
size: string
}

28
src/api/types/tea.ts Normal file
View File

@ -0,0 +1,28 @@
/**
* 茶艺师详情返回结果
*/
export interface ITeaSpecialistDetailsResult {
teamaster: Array<any>
}
/**
* 茶艺师详情字段
*/
export interface ITeaSpecialistDetailsFields {
name: string
star: number
reservation_num: number
distance: number
speed: number
real: {
gender: number
both: number
height: number
weight: number
interests: string
}
teamasterlabel: Array<any>
teamasterLevel: Array<any>
price: number
fare_price: number
}

View File

@ -3,7 +3,7 @@
<wd-navbar safeAreaInsetTop :bordered="false" :custom-class="customClass" :fixed="fixed" :placeholder="fixed" :zIndex="zIndex"> <wd-navbar safeAreaInsetTop :bordered="false" :custom-class="customClass" :fixed="fixed" :placeholder="fixed" :zIndex="zIndex">
<template #left> <template #left>
<view class="h-48rpx flex items-center" @click="navbar.back"> <view class="h-48rpx flex items-center" @click="navbar.back">
<view class="mt-4rpx"> <view class="mt-4rpx" v-if="leftArrow">
<wd-icon name="thin-arrow-left" size="30rpx" :color="iconLeftColor" ></wd-icon> <wd-icon name="thin-arrow-left" size="30rpx" :color="iconLeftColor" ></wd-icon>
</view> </view>
<view class="text-[#303133] text-36rpx ml-24rpx leading-48rpx" v-if="!layoutLeft">{{ title }}</view> <view class="text-[#303133] text-36rpx ml-24rpx leading-48rpx" v-if="!layoutLeft">{{ title }}</view>
@ -45,6 +45,11 @@
default: '' default: ''
}, },
leftArrow: {
type: Boolean,
default: true
},
// 是否开启左侧自定义布局 // 是否开启左侧自定义布局
layoutLeft: { layoutLeft: {
type: Boolean, type: Boolean,

View File

@ -23,9 +23,9 @@ const getUrlCode = (): { [key: string]: string | undefined } => {
/** /**
* 微信静默授权登录 * 微信静默授权登录
*/ */
export function snsapiBaseAuthorize() { export async function snsapiBaseAuthorize() {
// TODO 测试代码 // TODO 测试代码
// wxSnsapiBaseLogin({code: '0316MW1w32OBM53meU2w3GPdbe16MW1p'}).then((res: IUserInfoVo) => { // wxSnsapiBaseLogin({code: '051wM51w3488N53ThD3w3obLDm2wM51r'}).then((res: IUserInfoVo) => {
// console.log("登录成功 ~ snsapiBaseAuthorize ~ res:", res) // console.log("登录成功 ~ snsapiBaseAuthorize ~ res:", res)
// // 映射 IUserLogin 到 IUserInfoVo // // 映射 IUserLogin 到 IUserInfoVo
// useUserStore().setUserInfo(res) // useUserStore().setUserInfo(res)
@ -41,41 +41,40 @@ export function snsapiBaseAuthorize() {
// is_new_user: 1, // is_new_user: 1,
// id: 4, // id: 4,
// sn:"39317465", // sn:"39317465",
// token: "c6416f9ebed9f06d3807d01e9c9a9693", // token: "013f5128f0208f2f9d9285af5070ae7b",
// nickname: '微信用户', // nickname: '微信用户',
// mobile: '15005837859' // mobile: '15005837859'
// } // }
// useUserStore().setUserInfo(res) // useUserStore().setUserInfo(res)
// // console.log(useUserStore().userInfo) // console.log(useUserStore().userInfo)
// return // return
// let local = window.location.href // 获取页面url let local = window.location.href // 获取页面url
// let appid = import.meta.env.VITE_WX_SERVICE_ACCOUNT_APPID // 公众号的APPID let appid = import.meta.env.VITE_WX_SERVICE_ACCOUNT_APPID // 公众号的APPID
// console.log("🚀 ~ snsapiBaseAuthorize ~ appid:", appid) console.log("🚀 ~ snsapiBaseAuthorize ~ appid:", appid)
// let code = getUrlCode().code // 截取code let code = getUrlCode().code // 截取code
// // 获取之前的code // 获取之前的code
// let oldCode = uni.getStorageSync('wechatCode') let oldCode = uni.getStorageSync('wechatCode')
// if (code == null || code === '' || code == 'undefined' || code == oldCode) { if (code == null || code === '' || code == 'undefined' || code == oldCode) {
// // 如果没有code就去请求获取code // 如果没有code就去请求获取code
// console.log('当前没有code进入授权页面') console.log('当前没有code进入授权页面')
// let uri = encodeURIComponent(local) let uri = encodeURIComponent(local)
// // 设置旧的code为0避免死循环 // 设置旧的code为0避免死循环
// uni.setStorageSync('wechatCode',0) uni.setStorageSync('wechatCode',0)
// window.location.href = window.location.href =
// `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${uri}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect` `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${uri}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`
// } else { } else {
// // 保存最新code // 保存最新code
// uni.setStorageSync('wechatCode',code) uni.setStorageSync('wechatCode',code)
// // 使用code换取用户信息 // 使用code换取用户信息(同步写法)
// wxSnsapiBaseLogin({code}).then((res: IUserInfoVo) => { try {
// console.log("登录成功 ~ snsapiBaseAuthorize ~ res:", res) const res: IUserInfoVo = await wxSnsapiBaseLogin({code})
// // 映射 IUserLogin 到 IUserInfoVo console.log("登录成功 ~ snsapiBaseAuthorize ~ res:", res)
// useUserStore().setUserInfo(res) useUserStore().setUserInfo(res)
// }).catch(err => { } catch (err) {
// // 失败就重新授权 uni.setStorageSync('wechatCode', 0)
// uni.setStorageSync('wechatCode', 0) console.log('请求失败', err)
// console.log('请求失败', err) }
// }) }
// }
} }

View File

@ -70,8 +70,6 @@ const alovaInstance = createAlova({
const userStore = useUserStore() const userStore = useUserStore()
const { token } = userStore.userInfo as unknown as IUserInfo const { token } = userStore.userInfo as unknown as IUserInfo
console.log("🚀 ~ userStore.userInfo:", userStore.userInfo)
console.log("🚀 ~ token:", token)
if (!token) { if (!token) {
throw new Error('[请求错误]:未登录') throw new Error('[请求错误]:未登录')
} }

View File

@ -133,7 +133,6 @@
{ {
"path": "pages/my/my", "path": "pages/my/my",
"type": "page", "type": "page",
"needLogin": true,
"layout": "tabbar", "layout": "tabbar",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"

View File

@ -68,7 +68,7 @@
</wd-popup> </wd-popup>
<view> <view>
<navbar :title="isReserve ? '预约茶艺师' : '茶艺师详情'" fixed> <navbar :title="isReserve ? '预约茶艺师' : '茶艺师详情'" fixed :left-arrow="false">
<template #right> <template #right>
<view class="flex items-center ml-114rpx"> <view class="flex items-center ml-114rpx">
<view class="mr-16rpx flex items-center" @click="Detail.handleCollect"> <view class="mr-16rpx flex items-center" @click="Detail.handleCollect">
@ -92,18 +92,18 @@
<!-- 昵称显示 --> <!-- 昵称显示 -->
<view class="bg-white rounded-t-16rpx px-30rpx"> <view class="bg-white rounded-t-16rpx px-30rpx">
<view class="font-bold text-34rpx leading-48rpx text-#303133 pt-36rpx">茶艺师的名字</view> <view class="font-bold text-34rpx leading-48rpx text-#303133 pt-36rpx">{{ info.name }}</view>
<view class="flex items-center justify-between"> <view class="flex items-center justify-between mt-4rpx">
<view class="flex items-center"> <view class="flex items-center">
<wd-rate v-model="rate" readonly active-color="#FF5951" allow-half active-icon="star-filled" icon="star" space="4rpx"/> <wd-rate v-model="rate" readonly active-color="#FF5951" allow-half active-icon="star-filled" icon="star" space="4rpx"/>
<view class="font-400 text-26rpx text-#606266 ml-8rpx">4.5 推荐</view> <view class="font-400 text-26rpx text-#606266 ml-8rpx">{{ info.star }} 推荐</view>
</view> </view>
<view class="font-400 text-22rpx leading-32rpx text-#6A6363">已预约 10+</view> <view class="font-400 text-22rpx leading-32rpx text-#6A6363">已预约 {{ info.reservation_num > 10 ? info.reservation_num + '+' : info.reservation_num }}</view>
</view> </view>
<view class="flex items-center justify-between mt-24rpx"> <view class="flex items-center justify-between mt-24rpx">
<view class="flex items-center"> <view class="flex items-center">
<view class=" mr-20rpx"> <view class="mr-20rpx" v-if="is90">
<wd-tag color="#FF5951" bg-color="#FEF1F0" custom-class="!rounded-6rpx !px-16rpx !py-4rpx !h-40rpx">90后茶艺师</wd-tag> <wd-tag color="#FF5951" bg-color="#FEF1F0" custom-class="!rounded-6rpx !px-16rpx !py-4rpx !h-40rpx">90后茶艺师</wd-tag>
</view> </view>
<view class="w-160rpx h-40rpx relative mr-44rpx top-6rpx"> <view class="w-160rpx h-40rpx relative mr-44rpx top-6rpx">
@ -111,11 +111,11 @@
<wd-img :src="`${OSS}icon/icon_gold_medal.png`" width="36rpx" height="36rpx"></wd-img> <wd-img :src="`${OSS}icon/icon_gold_medal.png`" width="36rpx" height="36rpx"></wd-img>
</view> </view>
<view> <view>
<tea-specialist-level :level="'junior'"></tea-specialist-level> <tea-specialist-level :level="TeaSpecialistLevelValue[info.teamasterLevel[0].level_name]"></tea-specialist-level>
</view> </view>
</view> </view>
</view> </view>
<view class="font-400 text-24rpx leading-34rpx text-#818CA9">距离您10.3km 预计30分钟</view> <view class="font-400 text-24rpx leading-34rpx text-#818CA9">距离您{{ info.distance }}km 预计{{ info.speed }}分钟</view>
</view> </view>
</view> </view>
@ -125,22 +125,22 @@
<view class="flex justify-between items-center mx-88rpx text-center mt-30rpx"> <view class="flex justify-between items-center mx-88rpx text-center mt-30rpx">
<view> <view>
<view class="font-400 text-28rpx leading-40rpx text-#606266">性别</view> <view class="font-400 text-28rpx leading-40rpx text-#606266">性别</view>
<view class="font-bold text-30rpx leading-42rpx text-#303133 mt-12rpx"></view> <view class="font-bold text-30rpx leading-42rpx text-#303133 mt-12rpx">{{ info.real.gender == 1 ? '男' : '女' }}</view>
</view> </view>
<view class="w-4rpx h-66rpx bg-#F6F7F9"></view> <view class="w-4rpx h-66rpx bg-#F6F7F9"></view>
<view> <view>
<view class="font-400 text-28rpx leading-40rpx text-#606266">年龄</view> <view class="font-400 text-28rpx leading-40rpx text-#606266">年龄</view>
<view class="font-bold text-30rpx leading-42rpx text-#303133 mt-12rpx">21</view> <view class="font-bold text-30rpx leading-42rpx text-#303133 mt-12rpx">{{ info.real.both }}</view>
</view> </view>
<view class="w-4rpx h-66rpx bg-#F6F7F9"></view> <view class="w-4rpx h-66rpx bg-#F6F7F9"></view>
<view> <view>
<view class="font-400 text-28rpx leading-40rpx text-#606266">身高</view> <view class="font-400 text-28rpx leading-40rpx text-#606266">身高</view>
<view class="font-bold text-30rpx leading-42rpx text-#303133 mt-12rpx">165cm</view> <view class="font-bold text-30rpx leading-42rpx text-#303133 mt-12rpx">{{ info.real.height }}cm</view>
</view> </view>
<view class="w-4rpx h-66rpx bg-#F6F7F9"></view> <view class="w-4rpx h-66rpx bg-#F6F7F9"></view>
<view> <view>
<view class="font-400 text-28rpx leading-40rpx text-#606266">体重</view> <view class="font-400 text-28rpx leading-40rpx text-#606266">体重</view>
<view class="font-bold text-30rpx leading-42rpx text-#303133 mt-12rpx">53kg</view> <view class="font-bold text-30rpx leading-42rpx text-#303133 mt-12rpx">{{ info.real.weight }}kg</view>
</view> </view>
</view> </view>
@ -158,7 +158,7 @@
<view class="font-400 text-26rpx leading-36rpx text-#606266">兴趣爱好</view> <view class="font-400 text-26rpx leading-36rpx text-#606266">兴趣爱好</view>
</view> </view>
<view class="mt-20rpx font-400 text-28rpx leading-40rpx text-#303133"> <view class="mt-20rpx font-400 text-28rpx leading-40rpx text-#303133">
爱好茶艺喜欢旅游把爱好当工作 {{ info.real.interests }}
</view> </view>
</view> </view>
</view> </view>
@ -180,25 +180,25 @@
<view class="font-400 text-26rpx leading-36rpx text-#606266">计费标准</view> <view class="font-400 text-26rpx leading-36rpx text-#606266">计费标准</view>
</view> </view>
<view class=" mt-22rpx"> <view class="mt-22rpx">
<view class="flex items-center justify-between"> <view class="flex items-center justify-between">
<view class="w-8rpx h-8rpx rounded-8rpx bg-#6A6363 mr-14rpx"></view> <view class="w-8rpx h-8rpx rounded-8rpx bg-#6A6363 mr-14rpx"></view>
<view class="flex-1 flex items-center justify-between font-500 text-26rpx leading-48rpx text-#303133"> <view class="flex-1 flex items-center justify-between font-500 text-26rpx leading-48rpx text-#303133">
<view>服务费</view> <view>服务费</view>
<view>160/小时</view> <view>{{ info.price }}/小时</view>
</view> </view>
</view> </view>
<view class="flex items-center justify-between mt-20rpx"> <view class="flex items-center justify-between mt-20rpx">
<view class="w-8rpx h-8rpx rounded-8rpx bg-#6A6363 mr-14rpx"></view> <view class="w-8rpx h-8rpx rounded-8rpx bg-#6A6363 mr-14rpx"></view>
<view class="flex-1 flex items-center justify-between font-500 text-26rpx leading-48rpx text-#303133"> <view class="flex-1 flex items-center justify-between font-500 text-26rpx leading-48rpx text-#303133">
<view>车马费</view> <view>车马费</view>
<view>3.00/公里</view> <view>{{ info.fare_price }}/公里</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class=""> <view>
<view class="flex items-center mt-24rpx"> <view class="flex items-center mt-24rpx">
<view class="mr-12rpx flex items-center"> <view class="mr-12rpx flex items-center">
<wd-img :src="`${OSS}icon/icon_info.png`" width="36rpx" height="36rpx"></wd-img> <wd-img :src="`${OSS}icon/icon_info.png`" width="36rpx" height="36rpx"></wd-img>
@ -247,7 +247,7 @@
</view> </view>
<!-- 操作按钮 --> <!-- 操作按钮 -->
<view class=""> <view>
<!-- 邀约状态下的按钮 --> <!-- 邀约状态下的按钮 -->
<view v-if="isReserve" class="mx-60rpx rounded-8rpx h-90rpx leading-90rpx text-center mt-52rpx bg-#4C9F44 text-#fff text-30rpx leading-42rpx font-bold" <view v-if="isReserve" class="mx-60rpx rounded-8rpx h-90rpx leading-90rpx text-center mt-52rpx bg-#4C9F44 text-#fff text-30rpx leading-42rpx font-bold"
@click="Detail.handleReserve"> @click="Detail.handleReserve">
@ -270,10 +270,31 @@
<script lang="ts" setup> <script lang="ts" setup>
import TeaSpecialistLevel from '@/components/TeaSpecialistLevel.vue' import TeaSpecialistLevel from '@/components/TeaSpecialistLevel.vue'
import { useMessage } from 'wot-design-uni' import { useMessage } from 'wot-design-uni'
import { getTeaSpecialistDetails } from '@/api/tea'
import { ITeaSpecialistDetailsFields } from '@/api/types/tea'
import {toast} from '@/utils/toast' import {toast} from '@/utils/toast'
import {TeaSpecialistLevelValue} from '@/utils/teaSpecialist'
const OSS = inject('OSS') const OSS = inject('OSS')
// 茶艺师
const id = ref<number>(0)
const info = reactive<ITeaSpecialistDetailsFields>({
name: '',
star: 0,
reservation_num: 0,
distance: 0,
speed: 0,
real: { gender: 1, both: 18, height: 165, weight: 53, interests: '爱好茶艺,喜欢旅游,把爱好当工作' },
teamasterlabel: [],
teamasterLevel: [],
price: 0,
fare_price: 0,
})
const latitude = ref<number>(0) // 纬度
const longitude = ref<number>(0) // 经度
const is90 = ref<boolean>(false)
// 是否是预约茶艺师页面 // 是否是预约茶艺师页面
const isReserve = ref<boolean>(false) const isReserve = ref<boolean>(false)
@ -289,7 +310,7 @@
const current = ref<number>(0) const current = ref<number>(0)
// 评分 // 评分
const rate = ref(4.5) const rate = ref<number>(1)
// 打赏主茶艺师 // 打赏主茶艺师
const showTipTeaSpecialistPopup = ref<boolean>(false) const showTipTeaSpecialistPopup = ref<boolean>(false)
@ -302,6 +323,30 @@
const isOtherTip = ref<boolean>(false) // 是否是其他打赏金额 const isOtherTip = ref<boolean>(false) // 是否是其他打赏金额
const tipMoney = ref<Number>(0) // 其他打赏金额 const tipMoney = ref<Number>(0) // 其他打赏金额
onLoad(async (args) => {
id.value = args.id || 0
latitude.value = args.lat || 0
longitude.value = args.lng || 0
// 获取茶艺师详情
const res = await getTeaSpecialistDetails({
id: args.id,
latitude: latitude.value,
longitude: longitude.value
})
// 将返回的数据合并到 reactive 对象中
Object.assign(info, res.teamaster || {})
rate.value = info.star
if (info.teamasterlabel) {
info.teamasterlabel.map(item => {
if (item.label_name == '90后茶艺师') {
is90.value = true
}
})
}
})
const Detail = { const Detail = {
// 处理收藏 // 处理收藏
handleCollect: () => { handleCollect: () => {

View File

@ -17,20 +17,22 @@
<view class="text-36rpx leading-50rpx text-#303133 mr-38rpx"> <view class="text-36rpx leading-50rpx text-#303133 mr-38rpx">
预约茶艺师 预约茶艺师
</view> </view>
<view class="flex items-center line-1" @click="Index.handleToCity"> <view class="flex items-center line-1 city-picker">
<view class="">
<wd-icon name="location" size="32rpx"></wd-icon> <wd-icon name="location" size="32rpx"></wd-icon>
</view> <wd-picker :columns="cityColumns" v-model="cityValue" @confirm="Index.handleSelectCity" use-default-slot>
<view class="mr-10rpx font-400 leading-44rpx text-32rpx pl-10rpx line-1">上海市</view> <view class="mr-10rpx font-400 leading-44rpx text-32rpx pl-10rpx line-1">{{ defaultCity }}</view>
</wd-picker>
<wd-img width="14rpx" height="9rpx" :src="`${OSS}icon/icon_arrow_down.png`" /> <wd-img width="14rpx" height="9rpx" :src="`${OSS}icon/icon_arrow_down.png`" />
</view> </view>
</view> </view>
</template> </template>
</wd-navbar> </wd-navbar>
<view class="search-box relative" @click="Index.handleToSearch"> <view class="search-box relative">
<wd-search placeholder="茶艺师名称" cancel-txt="搜索" placeholder-left hide-cancel custom-input-class="!h-72rpx"> <wd-search placeholder="茶艺师名称" cancel-txt="搜索" placeholder-left hide-cancel custom-input-class="!h-72rpx" v-model="teaSpecialistName" light >
</wd-search> </wd-search>
<view class="absolute top-1/2 -translate-y-1/2 right-34rpx w-142rpx h-64rpx leading-64rpx text-center rounded-32rpx bg-#4C9F44 text-#fff font-400 text-32rpx"> <view
class="absolute top-1/2 -translate-y-1/2 right-34rpx w-142rpx h-64rpx leading-64rpx text-center rounded-32rpx bg-#4C9F44 text-#fff font-400 text-32rpx"
@click="Index.handleSearch">
搜索 搜索
</view> </view>
</view> </view>
@ -82,11 +84,10 @@
</view> </view>
</view> </view>
<mescroll-body @init="mescrollInit" @down="downCallback" @up="Index.upCallback" <mescroll-body @init="mescrollInit" @down="downCallback" :down="downOption" @up="Index.upCallback" :up="upOption" fixed>
:fixed="true"> <view class="flex items-center bg-white p-20rpx rounded-10rpx mx-30rpx mb-20rpx" v-for="(item, index) in list" :key="index" @click="Index.handleToReserveTeaSpecialist(item.id)">
<view class="flex items-center bg-white p-20rpx rounded-10rpx mx-30rpx mb-20rpx" v-for="(item, index) in 100" :key="index" @click="Index.handleToReserveTeaSpecialist(item)">
<view class="mr-28rpx relative"> <view class="mr-28rpx relative">
<wd-img width="200rpx" height="200rpx" :src="`${OSS}images/home/home_image5.png`"></wd-img> <wd-img width="200rpx" height="200rpx" :src="item.image"></wd-img>
<view class="tea-specialist-time absolute top-6rpx left-0 text-[#fff] font-400 text-18rpx leading-26rpx flex items-center justify-center"> <view class="tea-specialist-time absolute top-6rpx left-0 text-[#fff] font-400 text-18rpx leading-26rpx flex items-center justify-center">
可约9:00 可约9:00
</view> </view>
@ -94,46 +95,53 @@
<view class="flex-1"> <view class="flex-1">
<view class="flex items-center"> <view class="flex items-center">
<view class="font-bold text-[#303133] text-30rpx leading-42rpx mr-14rpx"> <view class="font-bold text-[#303133] text-30rpx leading-42rpx mr-14rpx">
茶艺师昵称 {{ item.name }}
</view> </view>
<view> <view>
<tea-specialist-level :level="'junior'"></tea-specialist-level> <tea-specialist-level :level="TeaSpecialistLevelValue[item.teamasterLevel[0].level_name]"></tea-specialist-level>
</view> </view>
</view> </view>
<view class="flex items-center"> <view class="flex items-center">
<view class="mr-12rpx"> <template v-for="(label, labelIndex) in item.teamasterlabel" :key="labelIndex">
<wd-tag color="#40AE36" bg-color="#40AE36" plain custom-class="!rounded-4rpx">上门服务</wd-tag> <!-- 上门服务 -->
<view class="mr-12rpx" v-if="label.id == 1">
<wd-tag color="#40AE36" bg-color="#40AE36" plain custom-class="!rounded-4rpx">{{ label.label_name }}</wd-tag>
</view> </view>
<view class="mr-12rpx">
<wd-tag color="#F55726" bg-color="#F55726" plain>到点服务</wd-tag> <!-- 到点服务 -->
<view class="mr-12rpx" v-if="label.id == 2">
<wd-tag color="#F55726" bg-color="#F55726" plain custom-class="!rounded-4rpx">{{ label.label_name }}</wd-tag>
</view> </view>
</template>
<view class="mr-12rpx"> <view class="mr-12rpx">
<wd-tag color="#818CA9" bg-color="#F3F3F3">28</wd-tag> <wd-tag color="#818CA9" bg-color="#F3F3F3">{{ item.both }}</wd-tag>
</view> </view>
<view class="flex items-center mt-8rpx"> <view class="flex items-center mt-8rpx">
<wd-img :src="`${OSS}icon/icon_woman.png`" width="28rpx" height="28rpx"></wd-img> <wd-img :src="item.sex == 1 ? `${OSS}icon/icon_man.png` : `${OSS}icon/icon_woman.png`" width="28rpx" height="28rpx"></wd-img>
<!-- <wd-img :src="`${OSS}icon/icon_man.png`" width="28rpx" height="28rpx"></wd-img> -->
</view> </view>
</view> </view>
<view class="flex items-center justify-between mt-18rpx"> <view class="flex items-center justify-between mt-18rpx">
<view class="flex items-center mr-20rpx"> <view class="mr-20rpx w-200rpx">
<view class="flex items-center" v-if="item.authent_status == 1">
<view class="flex items-center"> <view class="flex items-center">
<wd-img :src="`${OSS}icon/icon_store_cert.png`" width="36rpx" height="36rpx"></wd-img> <wd-img :src="`${OSS}icon/icon_store_cert.png`" width="36rpx" height="36rpx"></wd-img>
</view> </view>
<text class="ml-8rpx font-400 text-24rpx leading-4rpx text-#303133">商家认证</text> <text class="ml-8rpx font-400 text-24rpx leading-4rpx text-#303133">商家认证</text>
</view> </view>
</view>
<view class="flex items-center font-400 text-24rpx leading-34rpx text-#92928C">距您14km</view> <view class="flex items-center font-400 text-24rpx leading-34rpx text-#92928C">距您{{ item.distance }}km</view>
</view> </view>
<view class="font-400 text-[#FF5951] text-26rpx leading-40rpx flex items-center justify-between mt-4rpx"> <view class="font-400 text-[#FF5951] text-26rpx leading-40rpx flex items-center justify-between mt-4rpx">
<view class=""> <view class="">
<text class="text-32rpx">180</text> <text class="text-32rpx">{{ item.price }}</text>
<text class="text-24rpx">/小时</text> <text class="text-24rpx">/小时</text>
</view> </view>
<view class="font-400 text-22rpx leading-32rpx text-#92928C">最快30分钟到达</view> <view class="font-400 text-22rpx leading-32rpx text-#92928C">最快{{ item.speed }}分钟到达</view>
</view> </view>
</view> </view>
</view> </view>
@ -147,10 +155,11 @@
import { onPageScroll, onReachBottom } from '@dcloudio/uni-app' import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js" import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
import TeaSpecialistLevel from '@/components/TeaSpecialistLevel.vue' import TeaSpecialistLevel from '@/components/TeaSpecialistLevel.vue'
import { OrderSource, OrderStatus } from '@/utils/order' import {getLocation} from '@/utils/jwexin'
import {getlocation} from '@/utils/jwexin' import {TeaSpecialistLevelValue} from '@/utils/teaSpecialist'
import {getDecorate, getTeaSpecialistLevels} from '@/api/home' import {getDecorate, getTeaSpecialistLevels, getTeaSpecialist} from '@/api/home'
// import {TeaSpecialistLevels} from '@/utils/teaSpecialist' import {getCity} from '@/api/city'
import type { IIndexListResult } from '@/api/types/home'
const OSS = inject('OSS') const OSS = inject('OSS')
@ -158,65 +167,89 @@
const TeaSpecialistLevels = reactive<Array<{ id: number, status: number, level_name: string}>>([]) const TeaSpecialistLevels = reactive<Array<{ id: number, status: number, level_name: string}>>([])
const selectedLevel = ref<Array<any>>([]) // 选择茶艺师的点击等级 const selectedLevel = ref<Array<any>>([]) // 选择茶艺师的点击等级
// 分页 // 分页相关
const { mescrollInit, downCallback } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
const downOption = {
auto: true
}
const upOption = {
auto: true,
textNoMore: '~ 已经到底啦 ~', //无更多数据的提示
}
const latitude = ref<number>(import.meta.env.VITE_DEFAULT_LATITUDE) // 纬度
const longitude = ref<number>(import.meta.env.VITE_DEFAULT_LONGITUDE) // 经度
const defaultCity = ref<string>(import.meta.env.VITE_DEFAULT_ADDRESS) // 默认城市
const list = ref<Array<any>>([]) // 茶艺师列表
const teaSpecialistName = ref<string>('') // 茶艺师名称
const cityColumns = ref<Array<{label: string, value: string}>>([])
const cityValue = ref<string>('')
onLoad(() => { onLoad(async () => {
// getlocation((res) => { // 授权获取地址
// console.log('经纬度:' + res.latitude + ',' + res.longitude) await getLocation((res) => {
// }) latitude.value = res.latitude
longitude.value = res.longitude
Index.handleSearch()
})
// 获取城市列表
getCity({latitude: latitude.value, longitude: longitude.value}).then((res: any) => {
cityColumns.value = res.area_list.map(item => {
return {
label: item.getArea[0].name,
value: item.getArea[0].lat + ',' + item.getArea[0].lng
}
})
})
// getDecorate({id: 1}).then((res: any) => { // getDecorate({id: 1}).then((res: any) => {
// const data = JSON.parse(res.data) // const data = JSON.parse(res.data)
// console.log('装修数据:', data) // console.log('装修数据:', data)
// }) // })
// 获取茶艺师等级 // 等待授权完成后再加载数据
getTeaSpecialistLevels().then((res:Array<any>) => { getTeaSpecialistLevels().then((res:Array<any>) => {
TeaSpecialistLevels.push(...res) TeaSpecialistLevels.push(...res)
}) })
}) })
const Index = { const Index = {
// 城市 // 选择城市
handleToCity: () => { handleSelectCity: (e: any) => {
uni.navigateTo({ cityValue.value = e.value
url: '/pages/city/city' defaultCity.value = e.selectedItems.label
})
const val = e.value.split(',')
latitude.value = parseFloat(val[0])
longitude.value = parseFloat(val[1])
Index.handleSearch()
}, },
// 搜索 // 搜索
handleToSearch: () => { handleSearch: () => {
uni.navigateTo({ list.value = []
url: '/pages/search/search' getMescroll().resetUpScroll()
})
}, },
// 上拉加载的回调: 其中num:当前页 从1开始, size:每页数据条数,默认10 // 上拉加载的回调: 其中num:当前页 从1开始, size:每页数据条数,默认10
upCallback: (mescroll) => { upCallback: (mescroll) => {
// 需要留一下数据为空的时候显示的空数据图标内容 const filter = {
level_id: selectedLevel.value.join(',') || '0',
page: mescroll.num,
size: mescroll.size,
latitude: latitude.value,
longitude: longitude.value,
search: teaSpecialistName.value
}
console.log('filter:', filter)
// apiGoods(mescroll.num, mescroll.size).then(res=>{ getTeaSpecialist(filter).then((res: IIndexListResult) => {
// const curPageData = res.list || [] // 当前页数据 const curPageData = res.list || [] // 当前页数据
// if(mescroll.num == 1) goods.value = []; // 第一页需手动制空列表 if(mescroll.num == 1) list.value = [] // 第一页需手动制空列表
// goods.value = goods.value.concat(curPageData); //追加新数据 list.value = list.value.concat(curPageData) //追加新数据
// //联网成功的回调,隐藏下拉刷新和上拉加载的状态; mescroll.endSuccess(curPageData.length, Boolean(res.more))
// //mescroll会根据传的参数,自动判断列表如果无任何数据,则提示空;列表无下一页数据,则提示无更多数据; }).catch(() => {
mescroll.endErr() // 请求失败, 结束加载
// //方法一(推荐): 后台接口有返回列表的总页数 totalPage })
// //mescroll.endByPage(curPageData.length, totalPage); //必传参数(当前页的数据个数, 总页数)
// //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
// //mescroll.endBySize(curPageData.length, totalSize); //必传参数(当前页的数据个数, 总数据量)
// //方法三(推荐): 您有其他方式知道是否有下一页 hasNext
// //mescroll.endSuccess(curPageData.length, hasNext); //必传参数(当前页的数据个数, 是否有下一页true/false)
// //方法四 (不推荐),会存在一个小问题:比如列表共有20条数据,每页加载10条,共2页.如果只根据当前页的数据个数判断,则需翻到第三页才会知道无更多数据.
// mescroll.endSuccess(curPageData.length); // 请求成功, 结束加载
// }).catch(()=>{
mescroll.endErr(); // 请求失败, 结束加载
// })
}, },
handleClick: (item: any) => { handleClick: (item: any) => {
@ -227,13 +260,12 @@
// 跳转到预约茶艺师页面 // 跳转到预约茶艺师页面
handleToReserveTeaSpecialist: (id: number = 1) => { handleToReserveTeaSpecialist: (id: number = 1) => {
uni.navigateTo({ uni.navigateTo({
url: `/pages/index/detail` url: `/pages/index/detail?id=${id}&lat=${latitude.value}&lng=${longitude.value}`
}) })
}, },
// 选择茶艺师等级 // 选择茶艺师等级
handleToggleTeaSpecialistLevel: (value: any) => { handleToggleTeaSpecialistLevel: (value: any) => {
// 切换茶艺师等级
const index = selectedLevel.value.indexOf(value); const index = selectedLevel.value.indexOf(value);
if (index > -1) { if (index > -1) {
// 如果已经选择了该等级,则取消选择 // 如果已经选择了该等级,则取消选择
@ -242,6 +274,8 @@
// 如果未选择该等级,则添加选择 // 如果未选择该等级,则添加选择
selectedLevel.value.push(value); selectedLevel.value.push(value);
} }
Index.handleSearch()
}, },
// 跳转到团体预约页面 // 跳转到团体预约页面
@ -297,4 +331,16 @@
background-image: url(#{$OSS}images/collect/collect_image1.png); background-image: url(#{$OSS}images/collect/collect_image1.png);
background-size: 100% 100%; background-size: 100% 100%;
} }
.city-picker {
:deep() {
.wd-picker__action--cancel {
color: #666666 !important;
}
.wd-picker__action {
color: #4C9F44;
}
}
}
</style> </style>

View File

@ -1,6 +1,5 @@
<route lang="jsonc" type="page"> <route lang="jsonc" type="page">
{ {
"needLogin": true,
"layout": "tabbar", "layout": "tabbar",
"style": { "style": {
"navigationStyle": "custom" "navigationStyle": "custom"
@ -182,6 +181,7 @@
import {OrderStatus} from '@/utils/order' import {OrderStatus} from '@/utils/order'
import {toast} from '@/utils/toast' import {toast} from '@/utils/toast'
import { useUserStore } from '@/store' import { useUserStore } from '@/store'
import {snsapiBaseAuthorize} from '@/hooks/useWeiXin'
const OSS = inject('OSS') const OSS = inject('OSS')
const navbarHeight = inject('navbarHeight') const navbarHeight = inject('navbarHeight')
@ -254,15 +254,23 @@
}, },
// 跳转到个人信息 // 跳转到个人信息
handleToProfile: () => { handleToProfile: async () => {
if (isLogin.value) { if (isLogin.value) {
uni.navigateTo({ uni.navigateTo({
url: '/bundle/profile/profile' url: '/bundle/profile/profile'
}) })
} else { } else {
// 登录操作
await snsapiBaseAuthorize()
const userStore = useUserStore()
if (!userStore.userInfo.mobile) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/login/mobile' url: '/pages/login/mobile'
}) })
} else {
userInfo.value = userStore.userInfo
isLogin.value = true
}
} }
}, },

View File

@ -19,7 +19,9 @@
</template> </template>
<template #title> <template #title>
<view class="search-box flex items-center ml-26rpx"> <view class="search-box flex items-center ml-26rpx">
<wd-search v-model="keywords" placeholder="搜索茶址名称" hide-cancel placeholder-left <wd-search v-model="keywords" placeholder="搜索茶址名称" hide-cancel
placeholder-left
custom-input-class="!text-left"
placeholderStyle="text-align:left;line-heigt: 44rpx;color: #C9C9C9; font-size: 32rpx;font-weight: normal;"></wd-search> placeholderStyle="text-align:left;line-heigt: 44rpx;color: #C9C9C9; font-size: 32rpx;font-weight: normal;"></wd-search>
</view> </view>
</template> </template>

View File

@ -47,7 +47,7 @@
<view class="upwarp-tip">{{ mescroll.optUp.textLoading }}</view> <view class="upwarp-tip">{{ mescroll.optUp.textLoading }}</view>
</view> </view>
<!-- 无数据 --> <!-- 无数据 -->
<view v-if="upLoadType===2" class="upwarp-nodata">{{ mescroll.optUp.textNoMore }}</view> <view v-if="upLoadType===2" class="upwarp-nodata">暂无了</view>
</view> </view>
</view> </view>

View File

@ -18,21 +18,20 @@ export function isWechat() {
} }
} }
export function initJweixinSDK(callback: (res?: any) => void = () => {}) { export async function initJweixinSDK(): Promise<any> {
if (typeof window.entryUrl === 'undefined' || window.entryUrl === '') { if (typeof window.entryUrl === 'undefined' || window.entryUrl === '') {
window.entryUrl = location.href.split('#')[0] window.entryUrl = location.href.split('#')[0]
console.log("🚀 ~ initJweixin ~ window.entryUrl:", window.entryUrl) console.log("🚀 ~ initJweixin ~ window.entryUrl:", window.entryUrl)
} }
let isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 let isiOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
// 进行签名的时候 Android 不用使用之前的链接, ios 需要
let signLink = isiOS ? window.entryUrl : location.href.split('#')[0]; let signLink = isiOS ? window.entryUrl : location.href.split('#')[0];
console.log('-----------当前签名url--------------') console.log('-----------当前签名url--------------')
console.log(signLink) console.log(signLink)
// var uri = encodeURIComponent(location.href.split('#')[0]); //获取当前url然后传递给后台获取授权和签名信息 let url = encodeURIComponent(signLink);
let url = encodeURIComponent(signLink); //获取当前url然后传递给后台获取授权和签名信息 const res = await wxSignature({ url })
wxSignature({ url }).then((res) => {
console.log("🚀 ~ initJweixin ~ res:", res) console.log("🚀 ~ initJweixin ~ res:", res)
return new Promise((resolve) => {
wx.config({ wx.config({
debug: false, debug: false,
appId: res.appId, appId: res.appId,
@ -43,20 +42,19 @@ export function initJweixinSDK(callback: (res?: any) => void = () => {}) {
}); });
wx.ready(function() { wx.ready(function() {
console.log('config注入成功') console.log('config注入成功')
if (callback) { resolve(res)
callback(res)
}
}) })
}) })
} }
export function getlocation(callback: (res: any) => void ) { // 获取经纬度
export async function getLocation(callback: (res: any) => void ) {
if (!isWechat()) { if (!isWechat()) {
//console.log('不是微信客户端') console.log('不是微信客户端')
return return
} }
initJweixinSDK(function(res) { await initJweixinSDK()
wx.ready(function() { wx.ready(function() {
wx.getLocation({ wx.getLocation({
type: 'gcj02', // 默认为wgs84的gps坐标如果要返回直接给openLocation用的火星坐标可传入'gcj02' type: 'gcj02', // 默认为wgs84的gps坐标如果要返回直接给openLocation用的火星坐标可传入'gcj02'
@ -72,5 +70,4 @@ export function getlocation(callback: (res: any) => void ) {
// } // }
}); });
}); });
});
} }

View File

@ -7,11 +7,20 @@ export enum TeaSpecialistLevel {
Enthusiast = '茶艺爱好者' Enthusiast = '茶艺爱好者'
} }
// 订单来源对应名称
export const TeaSpecialistLevelValue = {
['金牌茶艺师']: 'gold',
['高级茶艺师']: 'senior',
['中级茶艺师']: 'intermediate',
['初级茶艺师']: 'junior',
['茶艺爱好者']: 'enthusiast',
}
// 茶艺师对象结构 // 茶艺师对象结构
export const TeaSpecialistLevels = [ export const TeaSpecialistLevels = [
{ id: 1, value: 'gold', label: TeaSpecialistLevel.Gold}, { id: 1, value: 'gold', label: TeaSpecialistLevel.Gold},
{ id: 2,value: 'senior', label: TeaSpecialistLevel.Senior }, { id: 2, value: 'senior', label: TeaSpecialistLevel.Senior },
{ id: 3,value: 'intermediate', label: TeaSpecialistLevel.Intermediate }, { id: 3, value: 'intermediate', label: TeaSpecialistLevel.Intermediate },
{ id: 4,value: 'junior', label: TeaSpecialistLevel.Junior }, { id: 4, value: 'junior', label: TeaSpecialistLevel.Junior },
{ id: 5,value: 'enthusiast', label: TeaSpecialistLevel.Enthusiast } { id: 5, value: 'enthusiast', label: TeaSpecialistLevel.Enthusiast }
]; ];