Files
pj_h5_cloud/src/pages/tabbar/coopMerchant.vue
T
2025-08-18 16:16:23 +08:00

141 lines
4.3 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { ref, reactive } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { merchantApi } from "@@/api"
import { hooks, router } from "@@/index"
import { filePath } from "@@/utils/file"
import zTabs from "@@/components/other/z-tabs/z-tabs.vue"
const pageRef = ref<any>(null)
const state = reactive<any>({
pa: {
pagesize: 10,
type: "2",
name: "",
catgoryId: null,
},
tabs: [{ id: null, name: "全部", disabled: false }],
})
const pageHook = hooks.usePage(pageRef, merchantApi.page, null, "data.records")
const query = (page: number, pagesize: number) => {
pageHook.startPage(page, pagesize, false, state.pa)
}
onLoad(async () => {
const app = getApp()
app._initTabbar()
try {
const res: any = await merchantApi.selectCatgory({})
if (res.code == 0) {
state.tabs = state.tabs.concat(res.data)
} else {
state.tabs = [{ id: null, name: "全部", disabled: false }]
}
} catch (error: any) {
uni.showToast({ title: error, icon: "none" })
}
})
onShow(() => {
pageRef.value && pageRef.value.reload(false)
})
const search = () => {
pageRef.value && pageRef.value.reload(true)
}
const doTab = (e: any) => {
const target = state.tabs[e]
state.pa.catgoryId = target.id
pageRef.value.reload(true)
}
const toDetail = async (v: any) => {
const isLogin = await hooks.useCheckLogin()
if (isLogin) {
if (v.supType && v.supType == "10") return router.jump("/pages/shop/brandDetail", { parentId: v.id })
if (v.supType && v.supType == "20") return router.jump("/pages/shop/detail", { id: v.id })
uni.showToast({ title: "合作商家类型未知", icon: "none" })
}
}
</script>
<template>
<crud-layout bg="/static/page/blue-bg.png">
<z-paging
ref="pageRef"
height="100%"
:fixed="false"
v-model="pageHook.list"
:default-page-size="10"
safe-area-inset-bottom
:loading-more-enabled="true"
:show-scrollbar="false"
@query="query"
:auto-clean-list-when-reload="false"
:auto-scroll-to-top-when-reload="false"
@scroll="pageHook.scroll"
>
<template #top>
<view class="h-30rpx" />
<view class="flex w-full">
<tm-input
class="flex-1"
v-model="state.pa.name"
type="text"
height="66"
minHeight="66"
fontSize="28"
:showClear="true"
:focus="false"
placeholder="请输入商家名称"
style="border: 2rpx solid #0779fd; border-radius: 14rpx"
:focus-highlight="false"
color="#ECF4F9"
>
<template v-slot:rightIcon>
<tm-button class="mr-1 py-3" size="xs" @click="search">搜索</tm-button>
</template>
</tm-input>
</view>
<view class="bg-white rounded-16rpx px-20rpx my-20rpx">
<z-tabs :list="state.tabs" @change="doTab" />
</view>
</template>
<view class="flex-row card p-20rpx m-b-20rpx" v-for="(v, i) in pageHook.list" :key="i" @tap="toDetail(v)">
<image class="w-180rpx h-180rpx rounded-12rpx my-auto" :src="filePath(v.logoPic)" mode="aspectFill" />
<view class="flex-1 flex-col m-l-20rpx">
<view class="sub-text-34">
<text class="mr-2">{{ v.name }}</text>
<!-- <tm-tag v-if="v.supType == '10' && Number(v.mchCount) > 0" size="xs" skin="thin">共{{ v.mchCount }}家</tm-tag> -->
</view>
<view class="m-t-10rpx">
<view class="flex justify-between items-center">
<view>
<view v-if="v.phone" class="flex items-center">
<image class="w-24rpx h-24rpx" src="@/static/page/phone.svg" />
<view class="second-text-28 ml-1">{{ v.phone }}</view>
</view>
</view>
<tm-tag size="xs">{{ v.deptName.length > 5 ? v.deptName.substring(0, 5) + "..." : v.deptName }}</tm-tag>
</view>
<view class="second-text-24">
<view v-if="v.jobTime != ',,'" class="second-text-28">营业时间:</view>
<view>{{ v.jobTime?.split(",")[0] ? "早:" + v.jobTime?.split(",")[0] : "" }}</view>
<view>{{ v.jobTime?.split(",")[1] ? "中:" + v.jobTime?.split(",")[1] : "" }}</view>
<view>{{ v.jobTime?.split(",")[2] ? "晚:" + v.jobTime?.split(",")[2] : "" }}</view>
</view>
<view v-if="v.addressDes" class="second-text-28">
<image class="w-24rpx h-24rpx" src="@/static/page/address.svg" />
<text class="ml-1">地址:</text>
<text class="m-l-10rpx">{{ v.addressDes }}</text>
</view>
</view>
</view>
</view>
</z-paging>
</crud-layout>
</template>