对接接口

This commit is contained in:
wangxiaowei
2025-12-17 23:34:08 +08:00
parent 018a784a8c
commit df863a2f41
19 changed files with 792 additions and 389 deletions

View File

@ -164,7 +164,6 @@
})
const Index = {
handleInit: async() => {
await Index.handleGetStoreList()
@ -175,13 +174,9 @@
* 获取门店列表
*/
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)
@ -204,14 +199,12 @@
if (!defaultStore.value) return
const storeDetails = await getStoreDetails(useStore.defaultStore.id)
store.value = storeDetails.details
console.log("🚀 ~ storeDetails:", storeDetails)
},
/**
* 选择扫码验券菜单
*/
handleSelectScanMenu: (item: { item: { name: string }}) => {
console.log("🚀 ~ item:", item)
if (item.item.name === '扫码验券') {
Index.handleScanCode()
} else if (item.item.name === '输入券码') {
@ -234,13 +227,6 @@
console.log('scanCode err:', err)
}
})
},
/**
* 一键续订时间
*/
handleChooseRenewTime: (item) => {
console.log("🚀 ~ item:", item)
}
}
</script>

View File

@ -100,7 +100,7 @@
toast.success('登录成功')
setTimeout(() => {
router.navigateBack()
router.reLaunch('/pages/index/index')
}, 1000)
} catch (error) {
toast.info('登录失败,请稍后重试')

View File

@ -5,160 +5,6 @@
}
}</route>
<script lang="ts" setup>
import type { IUserResult } from '@/api/types/user'
import { getUserInfo } from '@/api/user'
import { useUserStore } from '@/store'
import { router } from '@/utils/tools'
const OSS = inject('OSS')
const navbarHeight = inject('navbarHeight')
const rightPadding = inject('capsuleOffset')
// 登录信息相关
const user = ref<IUserResult>({
id: 0,
sn: 0,
sex: '未知',
account: '',
nickname: '',
real_name: '',
avatar: '',
collect_count: 0,
coupon_count: 0,
create_time: '',
has_auth: false,
has_password: false,
member: 0,
mobile: '',
user_money: '0.00',
version: '',
})
const isLogin = ref<boolean>(false)
// 客服电话
const showServiceMobile = ref<boolean>(false)
const sheetMenu = ref<{ name: string }[]>([])
// 门店信息
const storeInfo = ref({
douyin_uid: '236598984587',
address: '上海浦东新区新金桥路58号新银东大厦 15楼F室',
business_hours: '08:00-22:00',
contact_phone: '021-8888888',
})
// 门店媒体列表(视频/图片)
const storeMediaList = ref([
{ type: 'video', url: `${OSS}images/my/store_video_thumb.jpg`, overlay: null },
{ type: 'image', url: `${OSS}images/my/store_image1.jpg`, overlay: null },
{ type: 'image', url: `${OSS}images/my/store_image2.jpg`, overlay: null },
{ type: 'image', url: `${OSS}images/my/store_image3.jpg`, overlay: null },
{ type: 'image', url: `${OSS}images/my/store_image4.jpg`, overlay: null },
{ type: 'image', url: `${OSS}images/my/store_image5.jpg`, overlay: 8 },
])
// 格式化账号显示152****3412格式
function formatAccount(account: string) {
if (!account)
return ''
if (account.length <= 7)
return account
return `${account.substring(0, 3)}****${account.substring(account.length - 4)}`
}
onShow(() => {
const userStore = useUserStore()
isLogin.value = userStore.isLoggedIn
console.log("🚀 ~ isLogin.value:", isLogin.value)
if (isLogin.value) {
// 获取用户详情信息接口
getUserInfo().then((res) => {
user.value = res
})
}
else {
Object.keys(user.value).forEach((key) => {
user.value[key] = ''
})
}
})
onLoad(() => {
uni.$on('clearUser', () => {
const userStore = useUserStore()
isLogin.value = userStore.isLoggedIn
Object.keys(user.value).forEach((key) => {
user.value[key] = ''
})
})
})
onUnload(() => {
uni.$off('clearUser')
})
const My = {
// 跳转到个人信息
handleToProfile: () => {
if (!isLogin.value) {
router.navigateTo('/pages/login/login')
} else {
router.navigateTo('/bundle/profile/profile')
}
},
// 点击显示客服电话
handleShowService: () => {
showServiceMobile.value = true
sheetMenu.value = [
{ name: '400-800-8888' },
]
},
// 选择菜单-拨打客服电话
handleSelectMenu: (item: any) => {
uni.makePhoneCall({
phoneNumber: item.item.name,
})
},
// 跳转到设置页面
handleToSettings: () => {
// TODO: 跳转到设置页面
router.navigateTo('/bundle/store/setting')
},
// 预览媒体(视频/图片)
handlePreviewMedia: (index: number) => {
const item = storeMediaList.value[index]
if (item.type === 'video') {
// TODO: 播放视频
console.log('播放视频', item.url)
}
else {
// 预览图片
const urls = storeMediaList.value
.filter(i => i.type === 'image' && !i.overlay)
.map(i => i.url)
uni.previewImage({
current: index,
urls,
})
}
},
handleToWallet: () => {
if (!isLogin.value) {
router.navigateTo('/bundle/wallet/wallet')
} else {
router.navigateTo('/pages/login/login')
}
},
}
</script>
<template>
<view>
<view class="home-bg fixed left-0 top-0 w-[100%]"
@ -217,11 +63,11 @@ const My = {
<!-- 门店信息区域 -->
<view class="store-info-card mt-28rpx bg-white py-30rpx pl-30rpx">
<view class="mb-24rpx text-32rpx text-[#303133] font-bold leading-44rpx">
门店茶址24小时智能茶室(中新店)地址
{{ storeInfo.name }}
</view>
<view class="mb-16rpx flex items-center text-24rpx text-[#606266] leading-40rpx">
<text class="w-140rpx">抖音uid:</text>
<text class="flex-1 text-[#000]">{{ storeInfo.douyin_uid || '236598984587' }}</text>
<text class="w-140rpx" v-if="storeInfo.dy_uid">抖音uid:</text>
<text class="flex-1 text-[#000]">{{ storeInfo.dy_uid || '236598984587' }}</text>
</view>
<view class="mb-16rpx flex items-center text-24rpx text-[#606266] leading-40rpx">
<text class="w-140rpx">门店地址:</text>
@ -230,7 +76,7 @@ const My = {
<view class="relative mb-16rpx flex items-center">
<view class="flex items-center text-24rpx text-[#606266] leading-40rpx">
<text class="w-140rpx">营业时间:</text>
<text class="flex-1 text-[#000]">{{ storeInfo.business_hours || '08:00-22:00' }}</text>
<text class="flex-1 text-[#000]">{{ `${storeInfo.start_time }-${storeInfo.end_time }` || '08:00-22:00' }}</text>
</view>
<view class="modify-btn absolute right-0 flex items-center px-20rpx py-8rpx"
:style="{ backgroundImage: `url('${OSS}images/store/my/image3.png')` }"
@ -239,7 +85,7 @@ const My = {
<text class="text-24rpx text-[#fff]">修改</text>
</view>
</view>
<view class="flex items-center text-24rpx text-[#606266] leading-40rpx">
<view class="flex items-center text-24rpx text-[#606266] leading-40rpx" @click="My.handleCall(storeInfo.contact_phone)">
<text class="w-140rpx">联系电话:</text>
<text class="flex-1 text-[#000]">{{ storeInfo.contact_phone || '021-8888888' }}</text>
</view>
@ -248,71 +94,246 @@ const My = {
<!-- 门店视频/图片区域 -->
<view class="bg-white px-30rpx">
<view class="mb-24rpx text-32rpx text-[#303133] font-bold leading-44rpx">
门店视频/图片
<!-- 门店视频/图片 -->
门店图片
</view>
<view class="grid grid-cols-3 gap-16rpx">
<view v-for="(item, index) in storeMediaList" :key="index"
<view v-for="(item, index) in storeInfo.image_arr" :key="index"
class="relative aspect-square w-full overflow-hidden rounded-8rpx"
@click="My.handlePreviewMedia(index)">
<wd-img width="100%" height="100%" :src="item.url" mode="aspectFill" />
<!-- 视频播放图标 -->
<view v-if="item.type === 'video'" class="absolute inset-0 flex items-center justify-center">
<wd-img width="60rpx" height="60rpx" :src="`${OSS}images/store/my/image5.png')`" />
</view>
<!-- +8 遮罩 -->
<view v-if="item.overlay"
class="absolute inset-0 flex items-center justify-center bg-black bg-opacity-50">
<text class="text-32rpx text-[#fff] font-bold">+{{ item.overlay }}</text>
</view>
<wd-img width="100%" height="100%" :src="item" mode="aspectFill" />
<!-- 视频播放图标 -->
<!-- <view v-if="item.type === 'video'" class="absolute inset-0 flex items-center justify-center">
<wd-img width="60rpx" height="60rpx" :src="`${OSS}images/store/my/image5.png')`" />
</view> -->
<!-- 超出6张显示遮罩 -->
<view v-if="storeInfo.image_arr.length > 6"
class="absolute inset-0 flex items-center justify-center bg-black bg-opacity-50">
<text class="text-32rpx text-[#fff] font-bold">+{{ Number(storeInfo.image_arr.length - 6) }}</text>
</view>
</view>
</view>
</view>
</view>
<!-- 客服电话 -->
<wd-action-sheet v-model="showServiceMobile" :actions="sheetMenu" cancel-text="取消"
@close="showServiceMobile = false" @select="My.handleSelectMenu" />
</view>
</template>
<script lang="ts" setup>
import type { IUserResult } from '@/api/types/user'
import { getUserInfo } from '@/api/user'
import { useUserStore } from '@/store'
import { router } from '@/utils/tools'
import { getStoreDetails } from '@/api/store'
import { useStoreStore } from '@/store'
const OSS = inject('OSS')
const navbarHeight = inject('navbarHeight')
const rightPadding = inject('capsuleOffset')
const useStore = useStoreStore()
// 登录信息相关
const user = ref<IUserResult>({
id: 0,
sn: 0,
sex: '未知',
account: '',
nickname: '',
real_name: '',
avatar: '',
collect_count: 0,
coupon_count: 0,
create_time: '',
has_auth: false,
has_password: false,
member: 0,
mobile: '',
user_money: '0.00',
version: '',
})
const isLogin = ref<boolean>(false)
// 门店信息
const storeInfo = ref({
name: '',
dy_uid: '',
address: '',
business_hours: '',
contact_phone: '',
start_time: '',
end_time: '',
image_arr: []
})
// 门店媒体列表(视频/图片)
const storeMediaList = ref([
{ type: 'video', url: `${OSS}images/my/store_video_thumb.jpg`, overlay: null },
{ type: 'image', url: `${OSS}images/my/store_image1.jpg`, overlay: null },
{ type: 'image', url: `${OSS}images/my/store_image2.jpg`, overlay: null },
{ type: 'image', url: `${OSS}images/my/store_image3.jpg`, overlay: null },
{ type: 'image', url: `${OSS}images/my/store_image4.jpg`, overlay: null },
{ type: 'image', url: `${OSS}images/my/store_image5.jpg`, overlay: 8 },
])
// 格式化账号显示152****3412格式
function formatAccount(account: string) {
if (!account)
return ''
if (account.length <= 7)
return account
return `${account.substring(0, 3)}****${account.substring(account.length - 4)}`
}
onShow(() => {
const userStore = useUserStore()
isLogin.value = userStore.isLoggedIn
if (isLogin.value) {
// 获取用户详情信息接口
getUserInfo().then((res) => {
user.value = res
userStore.setUserMoney(Number(user.value.user_money))
})
}
else {
Object.keys(user.value).forEach((key) => {
user.value[key] = ''
})
}
// 获取店铺详情
My.handleGetStoreDetails()
})
onLoad(() => {
uni.$on('clearUser', () => {
const userStore = useUserStore()
isLogin.value = userStore.isLoggedIn
Object.keys(user.value).forEach((key) => {
user.value[key] = ''
})
})
})
onUnload(() => {
uni.$off('clearUser')
})
const My = {
/**
* 获取店铺详情
*/
handleGetStoreDetails: async () => {
const storeDetails = await getStoreDetails(useStore.defaultStore.id)
storeInfo.value = storeDetails.details
console.log("🚀 ~ storeInfo.value:", storeInfo.value)
},
// 跳转到个人信息
handleToProfile: () => {
if (!isLogin.value) {
router.navigateTo('/pages/login/login')
} else {
router.navigateTo('/bundle/profile/profile')
}
},
/**
* 拨打电话
*/
handleCall: (phone: string) => {
uni.makePhoneCall({
phoneNumber: phone,
})
},
// 跳转到设置页面
handleToSettings: () => {
// TODO: 跳转到设置页面
router.navigateTo('/bundle/store/setting')
},
// 预览媒体(视频/图片)
handlePreviewMedia: (index: number) => {
const item = storeMediaList.value[index]
if (item.type === 'video') {
// 播放视频
uni.previewMedia({
sources: [
{
url: item.url,
type: 'video'
}
],
current: 0
})
}
else {
// 预览图片
const urls = storeMediaList.value
.filter(i => i.type === 'image' && !i.overlay)
.map(i => i.url)
uni.previewImage({
current: index,
urls,
})
}
},
/**
* 跳转到钱包页面
*/
handleToWallet: () => {
if (!isLogin.value) {
router.navigateTo('/bundle/wallet/wallet')
} else {
router.navigateTo('/pages/login/login')
}
},
}
</script>
<style lang="scss">
page {
background: #fff;
}
page {
background: #fff;
}
.home-bg {
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: top center;
min-height: 450rpx;
}
.home-bg {
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: top center;
min-height: 450rpx;
}
.user-info-bg {
background-size: 100% auto;
background-repeat: no-repeat;
background-position: top center;
padding-top: 20rpx;
padding-bottom: 20rpx;
min-height: 200rpx;
}
.user-info-bg {
background-size: 100% auto;
background-repeat: no-repeat;
background-position: top center;
padding-top: 20rpx;
padding-bottom: 20rpx;
min-height: 200rpx;
}
.store-info-card {
position: relative;
z-index: 10;
border-radius: 32rpx 32rpx 0 0;
}
.store-info-card {
position: relative;
z-index: 10;
border-radius: 32rpx 32rpx 0 0;
}
.modify-btn {
position: absolute;
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center;
min-width: 160rpx;
height: 90rpx;
justify-content: space-around;
}
.modify-btn {
position: absolute;
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center;
min-width: 160rpx;
height: 90rpx;
justify-content: space-around;
}
.right-slot {
padding-right: v-bind(rightPadding);
}
.right-slot {
padding-right: v-bind(rightPadding);
}
</style>

View File

@ -24,6 +24,8 @@
<view class="relative h-64rpx">
<wd-img width="224rpx" height="64rpx" :src="`${OSS}images/reserve_room/reserve_room_image5.png`"/>
<view class="text-[#4C9F44] font-bold text-32rpx leading-44rpx absolute top-[50%] transform translate-y-[-50%] left-74rpx">点击开锁</view>
<!-- TODO 如果没有大门锁的话 -->
<!-- <view class="text-[#4C9F44] font-bold text-32rpx leading-44rpx absolute top-[50%] transform translate-y-[-50%] left-74rpx">暂无门锁</view> -->
</view>
</view>
</view>