对接接口

This commit is contained in:
wangxiaowei
2025-12-17 00:45:31 +08:00
parent 977f7d4038
commit 018a784a8c
20 changed files with 455 additions and 816 deletions

View File

@ -1,5 +1,6 @@
<!-- 使用 type="home" 属性设置首页其他页面不需要设置默认为page -->
<route lang="jsonc" type="home">{
"needLogin": true,
"layout": "tabbar",
"style": {
// 'custom' 表示开启自定义导航栏,默认 'default'
@ -14,7 +15,7 @@
<wd-navbar safeAreaInsetTop :bordered="false" custom-style="background-color: transparent !important;">
<template #left>
<view class="flex items-center line-1 w-450rpx" @click="router.navigateTo('/bundle/account/switch')">
<view class="mr-10rpx font-400 leading-44rpx text-32rpx pl-10rpx line-1">茶址24小时智能茶室(中新店)</view>
<view class="mr-10rpx font-400 leading-44rpx text-32rpx pl-10rpx line-1">{{ useStore.defaultStore.name || '暂无门店信息' }}</view>
<wd-img width="14rpx" height="9rpx" :src="`${OSS}icon/icon_arrow_down.png`" />
</view>
</template>
@ -124,20 +125,12 @@
<script lang="ts" setup>
import { router } from '@/utils/tools'
import { getStoreList, getStoreDetails } from '@/api/store'
import { useStoreStore } from '@/store'
const OSS = inject('OSS')
const navbarHeight = inject('navbarHeight')
// 分页
const downOption = {
auto: true
}
const upOption = {
auto: true,
textNoMore: '~ 已经到底啦 ~', //无更多数据的提示
}
const keywords = ref<string>('')
const list = ref<Array<any>>([])
const useStore = useStoreStore()
// 扫码验券弹出框
const showScanMenu = ref<boolean>(false)
@ -153,16 +146,65 @@
}
])
// 门店列表
const storeList = ref<Array<any>>([])
const defaultStore = ref<{ id: number; name: string; index: number }>({
id: 0,
name: '',
index: 0
})
const store = ref<any>({})
onLoad(async() => {
onShow(() => {
// 初始化页面数据
Index.handleInit()
})
onLoad(async() => {
})
const Index = {
handleInit: async() => {
await Index.handleGetStoreList()
await Index.handleGetStoreDetails()
},
/**
* 获取门店列表
*/
handleGetStoreList: async() => {
console.log("🚀 ~ Index.handleGetStoreList:", 'Index.handleGetStoreLis123')
const storeLists = await getStoreList()
// 保证 storeList.value 一定为数组
storeList.value = Array.isArray(storeLists.list) ? storeLists.list : Object.values(storeLists.list || {})
console.log("🚀 ~ storeList.value:", storeList.value)
console.log("🚀 ~ storeList.value:", storeList.value.length)
if (storeList.value.length > 0) {
useStore.setStoreList(storeList.value)
// 如果没有设置默认门店的话则设置第一个门店为默认门店
console.log("🚀 ~ useStore.defaultStore:", useStore.defaultStore)
if (useStore.defaultStore.id == 0) {
useStore.setDefaultStore({
id: storeList.value[0].id,
name: storeList.value[0].name,
index: 0
})
}
}
},
/**
* 获取门店详情
*/
handleGetStoreDetails: async() => {
if (!defaultStore.value) return
const storeDetails = await getStoreDetails(useStore.defaultStore.id)
store.value = storeDetails.details
console.log("🚀 ~ storeDetails:", storeDetails)
},
/**
@ -193,6 +235,13 @@
}
})
},
/**
* 一键续订时间
*/
handleChooseRenewTime: (item) => {
console.log("🚀 ~ item:", item)
}
}
</script>

View File

@ -26,16 +26,17 @@
<view class="mt-20rpx">
<wd-input v-model="model.mobile" type="text" placeholder="请输入账号" inputmode="numeric" no-border
custom-class="!bg-[#F6F7F8] !rounded-16rpx"
custom-input-class="!px-32rpx !h-104rpx" @input="Login.handleInputMobile" />
custom-input-class="!px-32rpx !h-104rpx"/>
</view>
</view>
<view class="mt-40rpx">
<view class="font-400 text-30rpx text-[#606266] leading-44rpx">密码</view>
<view class="mt-20rpx">
<wd-input v-model="model.passowrd" type="safe-password" placeholder="请输入密码" no-border
<view class="mt-20rpx password-input">
<wd-input v-model="model.passowrd" show-password placeholder="请输入密码" no-border
custom-class="!bg-[#F6F7F8] !rounded-16rpx"
custom-input-class="!px-32rpx !h-104rpx" />
custom-input-class="!px-32rpx !h-104rpx">
</wd-input>
</view>
</view>
@ -51,152 +52,84 @@
</view>
</template>
<script lang="ts" setup>
import { mobile as testMobile } from '@/utils/test'
import { router } from '@/utils/tools'
import { useToast } from 'wot-design-uni'
import { mobile as testMobile } from '@/utils/test'
import { router } from '@/utils/tools'
import { useToast } from 'wot-design-uni'
import { useUserStore } from '@/store'
const OSS = inject('OSS')
const toast = useToast()
const disabled = ref<boolean>(true)
const OSS = inject('OSS')
const toast = useToast()
/** 页面 **/
let pageType = 'login' // 页面类型 login:登录 edit:修改手机号
const page = ref<{ title: string, desc: string }>({ title: '其他手机号登录', desc: '请输入你要登录的手机号' })
const showEditSuccessPopup = ref<boolean>(false) // 显示手机号修改成功弹窗
const userId = ref<number>(0) // 用户ID修改手机号时需要传
/** 表单相关 **/
const model = reactive<{
mobile: string
passowrd: string
}>({
mobile: '15005837859',
passowrd: '123456'
})
/** 验证码倒计时 **/
const countDownTime = ref<number>(1 * 60 * 1000) // 60s倒计时
const startCountDown = ref<boolean>(false) // 是否开始倒计时
const countDown = ref<any>(null) // 倒计时组件
/** 表单相关 **/
const model = reactive<{
mobile: string
passowrd: string
}>({
mobile: '',
passowrd: ''
})
/** 结束 **/
onLoad((args) => {
/** 服务协议和隐私政策 **/
const agree = ref<boolean>(false)
/** 结束 **/
})
onLoad((args) => {
// 从个人登录页面进入
if (args.type === 'edit') {
userId.value = Number(args.userId) || 0 // userId仅做测试使用实际请传真实用户ID
const Login = {
// 登录
handleToLogin: async () => {
// TODO 如果是edit的话就是修改手机号
if (!testMobile(model.mobile)) {
toast.info('请输入正确的账号')
return
}
page.value.title = '修改手机号'
page.value.desc = '手机号一年内可修改2次'
pageType = 'edit'
if (!model.passowrd) {
toast.info('请输入密码')
return
}
uni.showLoading({
title: '登录中...'
})
try {
const userStore = useUserStore()
const res = await userStore.mobileLogin(model.mobile, model.passowrd, 1, 1, 1)
uni.hideLoading()
toast.success('登录成功')
setTimeout(() => {
router.navigateBack()
}, 1000)
} catch (error) {
toast.info('登录失败,请稍后重试')
uni.hideLoading
return
}
}
}
})
const Login = {
// 验证手机号
handleInputMobile: (e: { value: string }) => {
model.mobile = e.value
disabled.value = !testMobile(model.mobile)
},
// 发送验证码
handleCountDown: () => {
if (disabled.value) {
toast.show({
iconClass: 'info-circle',
msg: '手机号码错误请重新输入',
direction: 'vertical'
})
return
}
startCountDown.value = true
nextTick(() => {
countDown.value?.start()
// 发送验证码请求
})
},
// 验证码倒计时结束
handleFinishCountDown: () => {
startCountDown.value = false
},
// 登录
handleToLogin: () => {
// TODO 如果是edit的话就是修改手机号
if (pageType === 'login' && !agree.value) {
toast.show({
iconClass: 'info-circle',
msg: '请同意服务协议和隐私政策',
direction: 'vertical'
})
return
}
if (!testMobile(model.mobile)) {
toast.show({
iconClass: 'info-circle',
msg: '手机号码错误请重新输入',
direction: 'vertical'
})
return
}
if (!model.code) {
toast.show({
iconClass: 'info-circle',
msg: '验证码错误',
direction: 'vertical'
})
return
}
},
// 获取手机号
handleGetPhoneNumber: (e: object) => {
console.log("🚀 ~ e:", e)
},
handleAgree: (e: any) => {
console.log('e', e)
},
// 跳转到服务协议页面
handleToService: () => {
disabled.value = !disabled.value
console.log("🚀 ~ disabled:", disabled)
},
// 跳转到隐私政策页面
handleToPrivacy: () => {
},
// 修改手机成功后返回
handleToBack: () => {
uni.navigateBack()
}
}
</script>
<style lang="scss">
page {
background-color: #fff;
}
page {
background-color: #fff;
}
.login-bg {
background-color: #fff;
background-image: url(#{$OSS}images/store/login/image1.png);
background-size: 100% 420rpx;
background-repeat: no-repeat;
}
.login-bg {
background-color: #fff;
background-image: url(#{$OSS}images/store/login/image1.png);
background-size: 100% 420rpx;
background-repeat: no-repeat;
}
.password-input {
:deep() {
.wd-input__icon {
padding-right: 20rpx !important;
background: transparent !important;
}
}
}
</style>

View File

@ -1,4 +1,5 @@
<route lang="jsonc" type="page">{
"needLogin": true,
"layout": "default",
"style": {
"navigationBarTitleText": "",

View File

@ -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 = {
</view>
<view class="relative z-10 ml-22rpx flex flex-1 items-center justify-between">
<view class="flex-1" @click="My.handleToProfile">
<view class="ml-8rpx flex items-center text-36rpx leading-50rpx" style="color: #fff;">
{{ isLogin ? user.nickname : '立即登录' }}
<view class="ml-8rpx flex items-center text-36rpx leading-50rpx text-[#fff]">
{{ isLogin ? user.nickname || '暂无昵称' : '立即登录' }}
<wd-icon v-if="isLogin" name="arrow-right" size="24rpx" color="#fff" class="ml-8rpx" />
</view>
<view v-if="isLogin" class="ml-8rpx mt-8rpx text-24rpx leading-34rpx" style="color: #fff;">
<view v-if="isLogin" class="ml-8rpx mt-8rpx text-24rpx leading-34rpx text-[#fff]">
账号: {{ formatAccount(user.account || user.mobile) }}
</view>
</view>

View File

@ -14,7 +14,7 @@
<view class="mt-38rpx">
<mescroll-body ref="mescrollItem0" @init="mescrollInit" @down="downCallback" @up="Renew.upCallback" :down="downOption" :up="upOption">
<view class="bg-white rounded-16rpx p-30rpx mx-32rpx relative">
<view class="absolute top-0 right-0 bg-[#4C9F44] text-[#fff] w-160rpx h-64rpx leading-64rpx text-center xd" @click="showBookTimePopup = true">
<view class="absolute top-0 right-0 bg-[#4C9F44] text-[#fff] w-160rpx h-64rpx leading-64rpx text-center xd" @click="showRenewTimePopup = true">
续单
</view>
<view class="flex items-center">
@ -37,8 +37,8 @@
<view class="bg-[#4C9F44] w-630rpx h-90rpx text-[#fff] text-center leading-90rpx rounded-8rpx mx-auto mt-50rpx">确定</view>
<!-- 选择预定时间 -->
<!-- <booking-time v-model="showBookTimePopup" :day="sevenDay" @selectedTime="Reserve.handleChooseReserveTime"></booking-time> -->
<!-- 选择续订时间 -->
<renew-time v-model="showRenewTimePopup" @selectedTime="Renew.handleChooseRenewTime"></renew-time>
</view>
</template>
@ -53,6 +53,10 @@
import type { ITeaSpecialistFuture7DaysResult } from '@/api/types/tea'
import { getNext7Days, renewTeaRoomOrder } from '@/api/tea-room'
// 续单
const showRenewTimePopup = ref<boolean>(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)
}
}
</script>