This commit is contained in:
zmj 2024-05-07 19:02:46 +08:00
parent 6b3ce21739
commit f9e628043d
2 changed files with 193 additions and 156 deletions

View File

@ -1,114 +1,119 @@
{
"easycom": {
"autoscan": true,
// customhttps://ask.dcloud.net.cn/question/131175
"custom": {
"^u--(.*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue",
"^up-(.*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue",
"^u-([^-].*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue"
}
},
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages
{
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "登录",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "购物",
"disableScroll": true,
"navigationStyle": "custom"
}
},
{
"path": "pages/cart/cart",
"style": {
"navigationBarTitleText": "购物车",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/my/my",
"style": {
"navigationBarTitleText": "个人中心",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}
"easycom": {
"autoscan": true,
// customhttps://ask.dcloud.net.cn/question/131175
"custom": {
"^u--(.*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue",
"^up-(.*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue",
"^u-([^-].*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue"
}
},
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages
{
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "登录",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "购物",
"disableScroll": true,
"enablePullDownRefresh": false,
"navigationStyle": "custom",
"app-plus": {
//
"bounce": "none"
}
}
},
{
"path": "pages/cart/cart",
"style": {
"navigationBarTitleText": "购物车",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
},
{
"path": "pages/my/my",
"style": {
"navigationBarTitleText": "个人中心",
"enablePullDownRefresh": false,
"navigationStyle": "custom"
}
}
],
"subPackages": [{
"root": "pagesOrder",
"pages": [{
"path": "order/order",
"style": {
"navigationBarTitleText": "我的订单",
"enablePullDownRefresh": false
}
},
{
"path": "detail/detail",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "addressList/addressList",
"style": {
"navigationBarTitleText": "地址管理",
"enablePullDownRefresh": false
}
},
{
"path": "addressEdit/addressEdit",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "settle/settle",
"style": {
"navigationBarTitleText": "确认订单",
"enablePullDownRefresh": false
}
}
]
},
{
"root": "pageQuota",
"pages": [{
"path": "quotation/index",
"style": {
"navigationBarTitleText": "报价单",
"enablePullDownRefresh": false
}
},
{
"path": "quotation/detail",
"style": {
"navigationBarTitleText": "报价明细",
"enablePullDownRefresh": false
}
}
],
"subPackages": [{
"root": "pagesOrder",
"pages": [{
"path": "order/order",
"style": {
"navigationBarTitleText": "我的订单",
"enablePullDownRefresh": false
}
},
{
"path": "detail/detail",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "addressList/addressList",
"style": {
"navigationBarTitleText": "地址管理",
"enablePullDownRefresh": false
}
},
{
"path": "addressEdit/addressEdit",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "settle/settle",
"style": {
"navigationBarTitleText": "确认订单",
"enablePullDownRefresh": false
}
}
]
},
{
"root": "pageQuota",
"pages": [{
"path": "quotation/index",
"style": {
"navigationBarTitleText": "报价单",
"enablePullDownRefresh": false
}
},
{
"path": "quotation/detail",
"style": {
"navigationBarTitleText": "报价明细",
"enablePullDownRefresh": false
}
}
]
}
]
}
],
],
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#fff",
"backgroundColor": "#fff"
}
"globalStyle": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#fff",
"backgroundColor": "#fff"
}
}

View File

@ -95,8 +95,10 @@
</scroll-view>
</view>
</viewPopup>
<scroll-view class="list" scroll-y @scrolltolower="loadMoreGood" @scroll='hideHeadView'>
<view class="shop-item" v-for="(item, index) in goodList" :key="item.id" @click="openGoodPopup(item)">
<scroll-view class="list" id='drag_area' style="overscroll-behavior: none;" @scroll="hideHeadView"
scroll-y @scrolltolower="loadMoreGood">
<view class="shop-item" v-for="(item, index) in goodList" :key="item.id"
@click="openGoodPopup(item)">
<view class="shop-img">
<up-image width="160rpx" height="160rpx" :src="item.imgs"></up-image>
</view>
@ -152,7 +154,8 @@
} from "@dcloudio/uni-app"
import {
reactive,
ref
ref,
onMounted
} from "vue"
import {
goodListApi,
@ -166,13 +169,21 @@
import viewPopup from "@/components/viewPopup.vue"
import goodPopup from "@/components/goodPopup.vue"
import useCartStore from "@/store/cart.js"
import {
getCurrentInstance
} from 'vue';
/*商品列表滚动隐藏头部导航 */
const instance = getCurrentInstance(); //
const targetHeight = ref(0)
const isScroll = ref(false)
let lastScollTop = 0
const hideHeadView = (e) => {
if (e.detail.scrollTop <= 0 || e.detail.scrollTop >= targetHeight.value) return
num.value = e.detail.scrollTop
isScroll.value = e.detail.scrollTop > lastScollTop
lastScollTop = e.detail.scrollTop
}
/*商品列表滚动隐藏头部导航结束 */
const test = () => {
@ -182,9 +193,7 @@
}
const cartStore = useCartStore();
const show = ref(0);
const topActive = ref(0);
const changeOne = (item, index) => {
console.log('选择', item, index);
@ -222,10 +231,10 @@
goods_id: id
}).then(res => {
getCartList();
}).catch(err=>{
console.log(err);
uni.$u.toast('添加失败')
})
}).catch(err => {
console.log(err);
uni.$u.toast('添加失败')
})
}
const keyword = ref('');
@ -235,54 +244,54 @@
getGoodList();
}
const changeOrder = (order) => {
console.log('排序', order);
where.value.order = order;
getGoodList();
}
const changeOrder = (order) => {
console.log('排序', order);
where.value.order = order;
getGoodList();
}
const where = ref({
page_no: 1,
page_size: 25,
name: '',
order: ''
})
const loading = ref(true);
const goodList = ref([]);
const getGoodList = (loadmore = false) => {
loading.value = true;
let class_id = rightActive.value || leftActive.value || topActive.value || '';
let class_all = '';
// ,
if(rightActive.value=='') class_all = leftActive.value;
if(leftActive.value=='') class_all = topActive.value;
if(topActive.value=='') class_all = '';
if(class_all) class_id = ""; //
if (loadmore) where.value.page_no++;
else where.value.page_no=1;
goodListApi({
...where.value,
class_all: class_all,
class: class_id
}).then(res => {
if (loadmore) goodList.value.push(...res.data.lists);
else goodList.value = res.data.lists;
})
}
const where = ref({
page_no: 1,
page_size: 25,
name: '',
order: ''
})
const loading = ref(true);
const goodList = ref([]);
const getGoodList = (loadmore = false) => {
loading.value = true;
let class_id = rightActive.value || leftActive.value || topActive.value || '';
let class_all = '';
// ,
if (rightActive.value == '') class_all = leftActive.value;
if (leftActive.value == '') class_all = topActive.value;
if (topActive.value == '') class_all = '';
if (class_all) class_id = ""; //
if (loadmore) where.value.page_no++;
else where.value.page_no = 1;
goodListApi({
...where.value,
class_all: class_all,
class: class_id
}).then(res => {
if (loadmore) goodList.value.push(...res.data.lists);
else goodList.value = res.data.lists;
})
}
//
const loadMoreGood = () => {
console.log('触底了');
getGoodList(true);
}
//
const loadMoreGood = () => {
console.log('触底了');
getGoodList(true);
}
const goodClassList = ref([]); //
const goodClassTow = ref([]); //
const goodClassThree = ref([]); //
const getgoodClassList = () => {
goodClassListApi({
page_size: 1000
}).then(res => {
page_size: 1000
}).then(res => {
res.data?.lists?.unshift({
id: "",
name: "全部",
@ -363,10 +372,33 @@
onLoad(() => {
getgoodClassList();
getGoodList();
})
onShow(() => {
getCartList();
})
onMounted(() => {
const instance = getCurrentInstance(); //
const getWXDom = () => {
let query = uni.createSelectorQuery().in(instance).select("#drag_area");
query
.fields({
size: true,
scrollOffset: true,
},
(data) => {
targetHeight.value = data.scrollHeight - data.height
}
)
.exec();
}
setTimeout(() => {
getWXDom()
}, 100)
})
</script>
<style lang="scss">