Compare commits
2 Commits
af10285e87
...
08fbd02dca
Author | SHA1 | Date |
---|---|---|
zmj | 08fbd02dca | |
zmj | f9e628043d |
107
pages.json
107
pages.json
|
@ -1,46 +1,51 @@
|
||||||
{
|
{
|
||||||
"easycom": {
|
"easycom": {
|
||||||
"autoscan": true,
|
"autoscan": true,
|
||||||
// 注意一定要放在custom里,否则无效,https://ask.dcloud.net.cn/question/131175
|
// 注意一定要放在custom里,否则无效,https://ask.dcloud.net.cn/question/131175
|
||||||
"custom": {
|
"custom": {
|
||||||
"^u--(.*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue",
|
"^u--(.*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue",
|
||||||
"^up-(.*)": "@/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"
|
"^u-([^-].*)": "@/uni_modules/uview-plus/components/u-$1/u-$1.vue"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
|
||||||
{
|
{
|
||||||
"path": "pages/login/login",
|
"path": "pages/login/login",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "登录",
|
"navigationBarTitleText": "登录",
|
||||||
"enablePullDownRefresh": false,
|
"enablePullDownRefresh": false,
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "购物",
|
"navigationBarTitleText": "购物",
|
||||||
"disableScroll": true,
|
"disableScroll": true,
|
||||||
"navigationStyle": "custom"
|
"enablePullDownRefresh": false,
|
||||||
}
|
"navigationStyle": "custom",
|
||||||
},
|
"app-plus": {
|
||||||
{
|
// 将回弹属性关掉
|
||||||
"path": "pages/cart/cart",
|
"bounce": "none"
|
||||||
"style": {
|
}
|
||||||
"navigationBarTitleText": "购物车",
|
}
|
||||||
"enablePullDownRefresh": false,
|
},
|
||||||
"navigationStyle": "custom"
|
{
|
||||||
}
|
"path": "pages/cart/cart",
|
||||||
},
|
"style": {
|
||||||
{
|
"navigationBarTitleText": "购物车",
|
||||||
"path": "pages/my/my",
|
"enablePullDownRefresh": false,
|
||||||
"style": {
|
"navigationStyle": "custom"
|
||||||
"navigationBarTitleText": "个人中心",
|
}
|
||||||
"enablePullDownRefresh": false,
|
},
|
||||||
"navigationStyle": "custom"
|
{
|
||||||
}
|
"path": "pages/my/my",
|
||||||
}
|
"style": {
|
||||||
|
"navigationBarTitleText": "个人中心",
|
||||||
|
"enablePullDownRefresh": false,
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
],
|
],
|
||||||
"subPackages": [{
|
"subPackages": [{
|
||||||
|
@ -100,16 +105,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
"globalStyle": {
|
"globalStyle": {
|
||||||
"navigationBarTextStyle": "black",
|
"navigationBarTextStyle": "black",
|
||||||
"navigationBarTitleText": "",
|
"navigationBarTitleText": "",
|
||||||
"navigationBarBackgroundColor": "#fff",
|
"navigationBarBackgroundColor": "#fff",
|
||||||
"backgroundColor": "#fff"
|
"backgroundColor": "#fff"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -95,10 +95,12 @@
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
</viewPopup>
|
</viewPopup>
|
||||||
<scroll-view class="list" scroll-y @scrolltolower="loadMoreGood" @scroll='hideHeadView'>
|
<scroll-view class="list" id='drag_area' style="overscroll-behavior: none;" @scroll="hideHeadView"
|
||||||
<view class="shop-item" v-for="(item, index) in goodList" :key="item.id" @click="openGoodPopup(item)">
|
scroll-y @scrolltolower="loadMoreGood">
|
||||||
|
<view class="shop-item" v-for="(item, index) in goodList" :key="item.id"
|
||||||
|
@click="openGoodPopup(item)">
|
||||||
<view class="shop-img">
|
<view class="shop-img">
|
||||||
<up-image width="160rpx" height="160rpx" :src="item.imgs"></up-image>
|
<up-image width="120rpx" height="120rpx" :src="item.imgs"></up-image>
|
||||||
</view>
|
</view>
|
||||||
<view class="shop-content">
|
<view class="shop-content">
|
||||||
<view class="title">
|
<view class="title">
|
||||||
|
@ -152,7 +154,8 @@
|
||||||
} from "@dcloudio/uni-app"
|
} from "@dcloudio/uni-app"
|
||||||
import {
|
import {
|
||||||
reactive,
|
reactive,
|
||||||
ref
|
ref,
|
||||||
|
onMounted
|
||||||
} from "vue"
|
} from "vue"
|
||||||
import {
|
import {
|
||||||
goodListApi,
|
goodListApi,
|
||||||
|
@ -166,13 +169,21 @@
|
||||||
import viewPopup from "@/components/viewPopup.vue"
|
import viewPopup from "@/components/viewPopup.vue"
|
||||||
import goodPopup from "@/components/goodPopup.vue"
|
import goodPopup from "@/components/goodPopup.vue"
|
||||||
import useCartStore from "@/store/cart.js"
|
import useCartStore from "@/store/cart.js"
|
||||||
|
import {
|
||||||
|
getCurrentInstance
|
||||||
|
} from 'vue';
|
||||||
|
|
||||||
/*商品列表滚动隐藏头部导航 */
|
/*商品列表滚动隐藏头部导航 */
|
||||||
|
const instance = getCurrentInstance(); // 获取组件实例
|
||||||
|
const targetHeight = ref(0)
|
||||||
const isScroll = ref(false)
|
const isScroll = ref(false)
|
||||||
let lastScollTop = 0
|
let lastScollTop = 0
|
||||||
const hideHeadView = (e) => {
|
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
|
isScroll.value = e.detail.scrollTop > lastScollTop
|
||||||
lastScollTop = e.detail.scrollTop
|
lastScollTop = e.detail.scrollTop
|
||||||
|
|
||||||
}
|
}
|
||||||
/*商品列表滚动隐藏头部导航结束 */
|
/*商品列表滚动隐藏头部导航结束 */
|
||||||
const test = () => {
|
const test = () => {
|
||||||
|
@ -182,9 +193,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const cartStore = useCartStore();
|
const cartStore = useCartStore();
|
||||||
|
|
||||||
const show = ref(0);
|
const show = ref(0);
|
||||||
|
|
||||||
const topActive = ref(0);
|
const topActive = ref(0);
|
||||||
const changeOne = (item, index) => {
|
const changeOne = (item, index) => {
|
||||||
console.log('选择', item, index);
|
console.log('选择', item, index);
|
||||||
|
@ -222,10 +231,10 @@
|
||||||
goods_id: id
|
goods_id: id
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
getCartList();
|
getCartList();
|
||||||
}).catch(err=>{
|
}).catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
uni.$u.toast('添加失败')
|
uni.$u.toast('添加失败')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const keyword = ref('');
|
const keyword = ref('');
|
||||||
|
@ -235,54 +244,54 @@
|
||||||
getGoodList();
|
getGoodList();
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeOrder = (order) => {
|
const changeOrder = (order) => {
|
||||||
console.log('排序', order);
|
console.log('排序', order);
|
||||||
where.value.order = order;
|
where.value.order = order;
|
||||||
getGoodList();
|
getGoodList();
|
||||||
}
|
}
|
||||||
|
|
||||||
const where = ref({
|
const where = ref({
|
||||||
page_no: 1,
|
page_no: 1,
|
||||||
page_size: 25,
|
page_size: 25,
|
||||||
name: '',
|
name: '',
|
||||||
order: ''
|
order: ''
|
||||||
})
|
})
|
||||||
const loading = ref(true);
|
const loading = ref(true);
|
||||||
const goodList = ref([]);
|
const goodList = ref([]);
|
||||||
const getGoodList = (loadmore = false) => {
|
const getGoodList = (loadmore = false) => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
let class_id = rightActive.value || leftActive.value || topActive.value || '';
|
let class_id = rightActive.value || leftActive.value || topActive.value || '';
|
||||||
let class_all = '';
|
let class_all = '';
|
||||||
// 若分类没有选中时,则直接查询上一级分类
|
// 若分类没有选中时,则直接查询上一级分类
|
||||||
if(rightActive.value=='') class_all = leftActive.value;
|
if (rightActive.value == '') class_all = leftActive.value;
|
||||||
if(leftActive.value=='') class_all = topActive.value;
|
if (leftActive.value == '') class_all = topActive.value;
|
||||||
if(topActive.value=='') class_all = '';
|
if (topActive.value == '') class_all = '';
|
||||||
if(class_all) class_id = ""; //只能带其中一个
|
if (class_all) class_id = ""; //只能带其中一个
|
||||||
if (loadmore) where.value.page_no++;
|
if (loadmore) where.value.page_no++;
|
||||||
else where.value.page_no=1;
|
else where.value.page_no = 1;
|
||||||
goodListApi({
|
goodListApi({
|
||||||
...where.value,
|
...where.value,
|
||||||
class_all: class_all,
|
class_all: class_all,
|
||||||
class: class_id
|
class: class_id
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (loadmore) goodList.value.push(...res.data.lists);
|
if (loadmore) goodList.value.push(...res.data.lists);
|
||||||
else goodList.value = res.data.lists;
|
else goodList.value = res.data.lists;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 商品列表触底
|
// 商品列表触底
|
||||||
const loadMoreGood = () => {
|
const loadMoreGood = () => {
|
||||||
console.log('触底了');
|
console.log('触底了');
|
||||||
getGoodList(true);
|
getGoodList(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const goodClassList = ref([]); // 一级分类
|
const goodClassList = ref([]); // 一级分类
|
||||||
const goodClassTow = ref([]); // 二级分类
|
const goodClassTow = ref([]); // 二级分类
|
||||||
const goodClassThree = ref([]); // 三级分类
|
const goodClassThree = ref([]); // 三级分类
|
||||||
const getgoodClassList = () => {
|
const getgoodClassList = () => {
|
||||||
goodClassListApi({
|
goodClassListApi({
|
||||||
page_size: 1000
|
page_size: 1000
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
res.data?.lists?.unshift({
|
res.data?.lists?.unshift({
|
||||||
id: "",
|
id: "",
|
||||||
name: "全部",
|
name: "全部",
|
||||||
|
@ -363,10 +372,33 @@
|
||||||
onLoad(() => {
|
onLoad(() => {
|
||||||
getgoodClassList();
|
getgoodClassList();
|
||||||
getGoodList();
|
getGoodList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
getCartList();
|
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>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@ -666,8 +698,8 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
.shop-img {
|
.shop-img {
|
||||||
height: 160rpx;
|
height: 120rpx;
|
||||||
width: 160rpx;
|
width: 120rpx;
|
||||||
margin-right: 20rpx;
|
margin-right: 20rpx;
|
||||||
border-radius: 14rpx;
|
border-radius: 14rpx;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
@ -687,7 +719,7 @@
|
||||||
.tip {
|
.tip {
|
||||||
color: #999;
|
color: #999;
|
||||||
font-size: 24rpx;
|
font-size: 24rpx;
|
||||||
margin: 12rpx 0;
|
margin: 2rpx 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue