2024-12-18 15:46:27 +08:00
|
|
|
<script setup>
|
|
|
|
/**
|
|
|
|
* 商城
|
|
|
|
*/
|
|
|
|
import {
|
|
|
|
ref,
|
|
|
|
reactive,
|
2025-04-27 21:40:25 +08:00
|
|
|
getCurrentInstance,
|
|
|
|
computed,
|
|
|
|
nextTick
|
2024-12-18 15:46:27 +08:00
|
|
|
} from 'vue'
|
|
|
|
import {
|
|
|
|
onReachBottom,
|
|
|
|
onPullDownRefresh,
|
|
|
|
onShow,
|
|
|
|
onLoad,
|
2024-12-27 15:03:48 +08:00
|
|
|
onReady,
|
2024-12-18 15:46:27 +08:00
|
|
|
} from '@dcloudio/uni-app';
|
2025-04-27 21:40:25 +08:00
|
|
|
// 状态栏
|
|
|
|
import statusBar from '@/components/header/statusBar.vue'
|
2024-12-27 15:03:48 +08:00
|
|
|
// 工具库
|
|
|
|
import util from '@/common/js/util.js'
|
|
|
|
//
|
|
|
|
import api from '@/api/index.js'
|
2025-04-27 21:40:25 +08:00
|
|
|
// 商城首页
|
|
|
|
import shopIndex from '@/pages/shop/components/shopIndex.vue'
|
|
|
|
// 线下店铺
|
|
|
|
import offlineIndex from './components/offlineIndex.vue';
|
2024-12-27 15:03:48 +08:00
|
|
|
//
|
|
|
|
import footerMneu from '@/components/footerMenu/footerMenu'
|
2024-12-18 15:46:27 +08:00
|
|
|
|
2024-12-27 15:03:48 +08:00
|
|
|
const {
|
|
|
|
proxy
|
|
|
|
} = getCurrentInstance()
|
2024-12-18 15:46:27 +08:00
|
|
|
// 分类
|
2025-04-27 21:40:25 +08:00
|
|
|
const navList = reactive([{
|
|
|
|
key: 'shop',
|
|
|
|
name: '商城',
|
|
|
|
load: false,
|
|
|
|
domRef: 'shopIndexRef',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'offline',
|
|
|
|
name: '线下店铺',
|
|
|
|
load: false,
|
|
|
|
domRef: 'offlineIndexRef',
|
|
|
|
}
|
|
|
|
])
|
2024-12-18 15:46:27 +08:00
|
|
|
// 分类下标
|
2025-04-27 21:40:25 +08:00
|
|
|
const navIndex = ref('')
|
|
|
|
// 当前导航项
|
|
|
|
const navCurrent = computed(() => navList[navIndex.value] || {})
|
2024-12-18 15:46:27 +08:00
|
|
|
|
|
|
|
onLoad(() => {
|
2025-04-27 21:40:25 +08:00
|
|
|
handleNavIndex(1)
|
2024-12-18 15:46:27 +08:00
|
|
|
})
|
2024-12-27 15:03:48 +08:00
|
|
|
|
|
|
|
onReady(() => {
|
2025-04-27 21:40:25 +08:00
|
|
|
// proxy.$refs.product.getList()
|
2024-12-27 15:03:48 +08:00
|
|
|
})
|
|
|
|
|
2024-12-18 15:46:27 +08:00
|
|
|
onReachBottom(() => {
|
2025-02-06 23:34:13 +08:00
|
|
|
// 重载列表
|
2025-04-27 21:40:25 +08:00
|
|
|
// proxy.$refs.product.getMoreList()
|
2024-12-18 15:46:27 +08:00
|
|
|
})
|
2024-12-27 15:03:48 +08:00
|
|
|
|
2024-12-18 15:46:27 +08:00
|
|
|
onPullDownRefresh(() => {
|
2025-02-06 23:34:13 +08:00
|
|
|
// 重载列表
|
2025-04-27 21:40:25 +08:00
|
|
|
// proxy.$refs.product.refreshList()
|
2024-12-18 15:46:27 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
onShow(() => {
|
|
|
|
// 触发自定义tabbar函数
|
|
|
|
uni.$emit('changeMine', 'shop')
|
|
|
|
})
|
|
|
|
|
2025-04-27 21:40:25 +08:00
|
|
|
// 切换导航
|
|
|
|
function handleNavIndex(index) {
|
|
|
|
if (navIndex.value === index) return
|
|
|
|
navIndex.value = index
|
|
|
|
navCurrent.value.load = true
|
2025-04-14 09:01:03 +08:00
|
|
|
|
2025-04-27 21:40:25 +08:00
|
|
|
nextTick(() => {
|
|
|
|
if (navCurrent.value.domRef) proxy.$refs[navCurrent.value.domRef].init()
|
2025-04-14 09:01:03 +08:00
|
|
|
})
|
|
|
|
}
|
2024-12-18 15:46:27 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2025-04-16 09:24:09 +08:00
|
|
|
<view class="app">
|
2025-04-27 21:40:25 +08:00
|
|
|
<!-- 菜单首页 -->
|
|
|
|
<view class="navBox bfff">
|
|
|
|
<statusBar />
|
|
|
|
|
|
|
|
<view class="nav">
|
|
|
|
<view class="item fmid f1" :class="{'active': index === navIndex}" v-for="(item,index) in navList"
|
|
|
|
:key="index" @click="handleNavIndex(index)">
|
|
|
|
<view class="">{{item.name}}</view>
|
2025-04-16 09:24:09 +08:00
|
|
|
</view>
|
2025-04-08 21:54:02 +08:00
|
|
|
</view>
|
|
|
|
</view>
|
2024-12-18 15:46:27 +08:00
|
|
|
|
2025-04-27 21:40:25 +08:00
|
|
|
<template v-if="navList[0].load">
|
|
|
|
<view v-show="navCurrent.key == 'shop'">
|
|
|
|
<!-- 商城首页 -->
|
|
|
|
<shopIndex ref="shopIndexRef" />
|
2024-12-18 15:46:27 +08:00
|
|
|
</view>
|
2025-04-27 21:40:25 +08:00
|
|
|
</template>
|
2024-12-18 15:46:27 +08:00
|
|
|
|
2025-04-27 21:40:25 +08:00
|
|
|
<template v-if="navList[1].load">
|
|
|
|
<view v-show="navCurrent.key == 'offline'">
|
|
|
|
<!-- 商城首页 -->
|
|
|
|
<offlineIndex ref="offlineIndexRef" />
|
2025-04-16 09:24:09 +08:00
|
|
|
</view>
|
2025-04-27 21:40:25 +08:00
|
|
|
</template>
|
2024-12-18 15:46:27 +08:00
|
|
|
</view>
|
|
|
|
|
|
|
|
<!-- 底部导航 -->
|
|
|
|
<footerMenu ref="footerMneuRef" page="shop" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2025-04-27 21:40:25 +08:00
|
|
|
// 顶部导航
|
|
|
|
.nav {
|
2025-04-16 09:24:09 +08:00
|
|
|
display: flex;
|
|
|
|
|
2025-04-27 21:40:25 +08:00
|
|
|
//
|
2025-04-16 09:24:09 +08:00
|
|
|
.item {
|
2025-04-27 21:40:25 +08:00
|
|
|
color: #3d3d3d;
|
|
|
|
font-size: 36rpx;
|
|
|
|
height: 100rpx;
|
|
|
|
transition: .3s;
|
|
|
|
|
|
|
|
//
|
|
|
|
&.active {
|
|
|
|
font-weight: bold;
|
|
|
|
color: #000;
|
2024-12-18 15:46:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|