This commit is contained in:
zmj 2024-06-22 19:58:02 +08:00
commit 0a8c7b0504
1 changed files with 872 additions and 868 deletions

View File

@ -1,5 +1,5 @@
<style lang="scss" scoped>
.share-btn {
.share-btn {
display: flex;
align-items: center;
position: fixed;
@ -15,7 +15,7 @@
color: #030303;
}
}
}
}
</style>
<template>
<view class="content">
@ -23,16 +23,20 @@
<template #left>
<view class="store-info">
<view style="display: flex;font-size: 30rpx;font-weight: bold;">
<text v-if="userStore.userInfo.user_ship==1 || shareInfo.store_id"
style="max-width: 400rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{(shareInfo.real_name||( userStore.userInfo.real_name|| userStore.userInfo.nickname)) + '的供销个人门店' }}</text>
<text v-if="userStore.userInfo.user_ship == 1 || shareInfo.store_id"
style="max-width: 400rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{
(shareInfo.real_name || (
userStore.userInfo.real_name || userStore.userInfo.nickname)) + '的供销个人门店' }}</text>
<text v-else
style="max-width: 400rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{STORE_INFO.store_name}}</text>
style="max-width: 400rpx;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">{{
STORE_INFO.store_name }}</text>
<up-icon name="arrow-right"></up-icon>
</view>
</view>
</template>
</up-navbar>
<view class="share-btn" :style="{height:btns.height + 'px',top:btns.top + 'px',left:(btns.left - 40) + 'px'}">
<view class="share-btn"
:style="{ height: btns.height + 'px', top: btns.top + 'px', left: (btns.left - 40) + 'px' }">
<up-button icon="share-square" openType="share" plain size="large" loadingSize="100" />
</view>
@ -48,41 +52,41 @@
<view class="nav-item" @click="navTo('/pagesOrder/order/order?type=0')">
<image src="@/static/tab/da.png"></image>
<text>我的订单</text>
<view class="badge">{{ userStore.userInfo.no_writeoff }}</view>
<view class="badge" v-if="userStore.userInfo.no_writeoff">{{ userStore.userInfo.no_writeoff }}</view>
</view>
<view class="nav-item" @click="navTo('/pages/my/my')">
<image src="@/static/tab/ca.png"></image>
<text>个人中心</text>
</view>
</view>
<view class='headScoll' ref='headscroll' :style="{height:isScroll?'0':'200rpx'}">
<view class='headScoll' ref='headscroll' :style="{ height: isScroll ? '0' : '200rpx' }">
<scroll-view class="head-view" scroll-x @scrolltolower="getgoodClassList(0)">
<view class="list">
<view class="item" :class="{'item-active': topActive===item.id}"
<view class="item" :class="{ 'item-active': topActive === item.id }"
v-for="(item, index) in goodClassList" :key="index" @click="changeOne(item, index)">
<view class="c-img"><up-image height="100rpx" width="100rpx" :src="item.pic"></up-image></view>
<view class="c-text u-line-1">{{item.name}}</view>
<view class="c-text u-line-1">{{ item.name }}</view>
</view>
<view class="item" style="width: 80rpx;height: 20rpx;">
</view>
</view>
</scroll-view>
<view class="r-btn" @click="show=1">
<view class="r-btn" @click="show = 1">
<view></view>
<view></view>
<up-icon name="list"></up-icon>
</view>
</view>
<viewPopup nav v-if="show===1" @close="show=0">
<viewPopup nav v-if="show === 1" @close="show = 0">
<view class="cateOne">
<view class="head-title">全部分类</view>
<scroll-view scroll-y style="height: 600rpx;">
<view class="list">
<view class="item" :class="{'item-active': topActive===item.id}"
<view class="item" :class="{ 'item-active': topActive === item.id }"
v-for="(item, index) in goodClassList" :key="index" @click="changeOne(item, index)">
<view class="c-img"><up-image height="100rpx" width="100rpx" :src="item.pic"></up-image>
</view>
<view class="c-text u-line-1">{{item.name}}</view>
<view class="c-text u-line-1">{{ item.name }}</view>
</view>
</view>
</scroll-view>
@ -90,8 +94,8 @@
</viewPopup>
<view class="scroll-box">
<scroll-view class="left" scroll-y @scrolltolower="getgoodClassList(topActive)">
<view class="item u-line-1" :class="{'item-active': leftActive===item.id}"
v-for="(item, index) in goodClassTow" :key="index" @click="changeTwo(item, index)">{{item.name}}
<view class="item u-line-1" :class="{ 'item-active': leftActive === item.id }"
v-for="(item, index) in goodClassTow" :key="index" @click="changeTwo(item, index)">{{ item.name }}
</view>
<view style="width: 100%;height: 450rpx;"></view>
</scroll-view>
@ -99,63 +103,62 @@
<view class="classify">
<scroll-view style="height: 90rpx;" scroll-x @scrolltolower="getgoodClassList(leftActive)">
<view class="classify-list">
<view class="classify-list-item u-line-1" :class="{'item-active': rightActive===item.id}"
<view class="classify-list-item u-line-1" :class="{ 'item-active': rightActive === item.id }"
v-for="(item, index) in goodClassThree" :key="index" @click="changeThree(item, index)">
{{item.name}}
{{ item.name }}
</view>
<view style="width: 70rpx;flex-shrink: 0;"></view>
</view>
</scroll-view>
<view class="done" @click="show=2">
<view class="done" @click="show = 2">
<up-icon name="arrow-down"></up-icon>
</view>
<view class="order-by">
<view class="item" :class="{'order-active': where.order==''}" @click="changeOrder('')">综合</view>
<view class="item" :class="{'order-active': where.order=='desc'||where.order=='asc'}"
@click="changeOrder(where.order=='asc'?'desc':'asc')">价格</view>
<view class="item" :class="{'order-active': where.order=='sales'}"
@click="changeOrder('sales')">销量</view>
<view class="item" :class="{ 'order-active': where.order == '' }" @click="changeOrder('')">综合</view>
<view class="item" :class="{ 'order-active': where.order == 'desc' || where.order == 'asc' }"
@click="changeOrder(where.order == 'asc' ? 'desc' : 'asc')">价格</view>
<view class="item" :class="{ 'order-active': where.order == 'sales' }"
@click="changeOrder('sales')">销量
</view>
</view>
<viewPopup v-if="show===2" @close="show=0">
</view>
<viewPopup v-if="show === 2" @close="show = 0">
<view class="cateOne">
<scroll-view scroll-y style="height: 230rpx;" @scrolltolower="getgoodClassList(leftActive)">
<view class="classify-list">
<view class="classify-list-item u-line-1"
:class="{'item-active': rightActive===item.id}"
v-for="(item, index) in goodClassThree" :key="index"
@click="changeThree(item, index)">
{{item.name}}
:class="{ 'item-active': rightActive === item.id }"
v-for="(item, index) in goodClassThree" :key="index" @click="changeThree(item, index)">
{{ item.name }}
</view>
</view>
</scroll-view>
</view>
</viewPopup>
<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)">
<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"
:style="{backgroundImage: `url(${item.image}?x-oss-process=image/format,webp)`}">
:style="{ backgroundImage: `url(${item.image}?x-oss-process=image/format,webp)` }">
</view>
<view class="shop-content">
<view class="title">
<view class="name u-line-2">{{item.store_name}}</view>
<view class="name u-line-2">{{ item.store_name }}</view>
<view class="tip u-line-1">
<text>{{item.spec}}</text>
<text>{{ item.spec }}</text>
</view>
</view>
<view style="display: flex;" v-if='item.batch>0'>
<view style="color: red;">起批量: {{item.batch}}{{item.unit_name }}起卖</view>
<view style="display: flex;" v-if='item.batch > 0'>
<view style="color: red;">起批量: {{ item.batch }}{{ item.unit_name }}起卖</view>
</view>
<view style="display: flex;align-items: center;" v-if='userStore?.userInfo?.user_ship==1'>
<view style="display: flex;align-items: center;" v-if='userStore?.userInfo?.user_ship == 1'>
<text class='price' style="font-size: 24rpx;">会员价</text>
<text class="price" style="margin-right: 10rpx;">{{item.vip_price}}
<text class="price" style="margin-right: 10rpx;">{{ item.vip_price }}
</text>
<text class='price' style="font-size: 24rpx;">/{{item.unit_name}}</text>
<text class='price' style="font-size: 24rpx;">/{{ item.unit_name }}</text>
</view>
<view class="price-btn">
<view class="price" style="font-size: 24rpx;">{{item.price}}/{{item.unit_name}}</view>
<view class="price" style="font-size: 24rpx;">{{ item.price }}/{{ item.unit_name }}</view>
<view class="btn">
<u--icon name="plus-circle-fill" size="20" color="#20b128"></u--icon>
</view>
@ -170,7 +173,7 @@
<view class="price-info">
<view class="row">
<view>合计</view>
<view class="price">¥<text style="font-size: 36rpx;">{{cartInfo.total_price}}</text></view>
<view class="price">¥<text style="font-size: 36rpx;">{{ cartInfo.total_price }}</text></view>
</view>
<!-- <view class="row">
<view style="color: #777;">原价 ¥50.00</view>
@ -178,62 +181,62 @@
</view> -->
</view>
<view class="btn">
<up-button color="#20b128" :disabled="cartInfo.total_price<500" @click="settleAccounts">
{{cartInfo.total_price<500?"¥500起订":"结算" }} </up-button>
<up-button color="#20b128" :disabled="cartInfo.total_price < 500" @click="settleAccounts">
{{ cartInfo.total_price < 500 ? "¥500起订" : "结算" }} </up-button>
</view>
<view class="cart" @click="navTo('/pages/cart/cart')">
<image src="@/static/icon/cart.png"></image>
<view class="badge">{{cartInfo.count}}</view>
<view class="badge">{{ cartInfo.count }}</view>
</view>
</view>
<goodPopup ref="goodRef" :show="showGoodPopup" @close="showGoodPopup=false" @change="changeGood" />
<goodPopup ref="goodRef" :show="showGoodPopup" @close="showGoodPopup = false" @change="changeGood" />
</view>
</template>
<script setup>
import {
import {
onLoad,
onShow,
onShareAppMessage,
} from "@dcloudio/uni-app"
import {
} from "@dcloudio/uni-app"
import {
reactive,
ref,
onMounted,
} from "vue"
import {
} from "vue"
import {
goodListApi,
goodClassListApi
} from "@/api/good.js"
import {
} from "@/api/good.js"
import {
cartCreateApi,
cartChangeApi,
cartListApi
} from "@/api/cart.js";
import {
} from "@/api/cart.js";
import {
productLogApi,
userInfoApi,
getStoreInfo
} from "@/api/user.js";
import viewPopup from "@/components/viewPopup.vue"
import goodPopup from "@/components/goodPopup.vue"
import useCartStore from "@/store/cart.js"
import {
} from "@/api/user.js";
import viewPopup from "@/components/viewPopup.vue"
import goodPopup from "@/components/goodPopup.vue"
import useCartStore from "@/store/cart.js"
import {
getCurrentInstance
} from 'vue';
import {
} from 'vue';
import {
shopDetailApi
} from "@/api/multipleShop.js";
} from "@/api/multipleShop.js";
import useUserStore from "@/store/user";
const userStore = useUserStore();
const STORE_INFO = reactive({
import useUserStore from "@/store/user";
const userStore = useUserStore();
const STORE_INFO = reactive({
id: 4,
store_name: "农(特)产品直营店"
})
})
const getStoreInfoFn = () => {
const getStoreInfoFn = () => {
if (uni.getStorageSync('STORE_INFO').length) {
let data = JSON.parse(uni.getStorageSync('STORE_INFO'))
for (let key in data) {
@ -247,12 +250,12 @@
STORE_INFO[key] = data[key]
}
})
}
getStoreInfoFn()
}
getStoreInfoFn()
//
onShareAppMessage(() => {
//
onShareAppMessage(() => {
let shareStr = '?id=' + STORE_INFO.id;
if (userStore.userInfo.user_ship == 1) {
shareStr = shareStr + '&spread_uid=' + userStore.userInfo.id + '&real_name=' + (userStore.userInfo
@ -270,26 +273,26 @@
}
};
return shareInfo;
})
})
/*商品列表滚动隐藏头部导航 */
const targetHeight = ref(0)
let scoHeight = 0
const isScroll = ref(false)
let lastScollTop = 0
const hideHeadView = (e) => {
/*商品列表滚动隐藏头部导航 */
const targetHeight = ref(0)
let scoHeight = 0
const isScroll = ref(false)
let lastScollTop = 0
const hideHeadView = (e) => {
if (e.detail.scrollTop < 100) return
if (e.detail.scrollTop <= 0 || e.detail.scrollTop > targetHeight.value)
return
isScroll.value = e.detail.scrollTop > lastScollTop
lastScollTop = e.detail.scrollTop
}
}
/*商品列表滚动隐藏头部导航结束 */
const cartStore = useCartStore();
const show = ref(0);
const topActive = ref(0);
const changeOne = async (item, index) => {
/*商品列表滚动隐藏头部导航结束 */
const cartStore = useCartStore();
const show = ref(0);
const topActive = ref(0);
const changeOne = async (item, index) => {
topActive.value = item.id;
show.value = 0;
goodClassTow.value = item?.children || [];
@ -298,10 +301,10 @@
rightActive.value = goodClassThree.value[0]?.id || '';
getGoodList();
if (!item.isLoading && item.id) getgoodClassList(topActive.value, 2); // , ,
}
}
const leftActive = ref(0);
const changeTwo = (item, index) => {
const leftActive = ref(0);
const changeTwo = (item, index) => {
isScroll.value = false;
getWXDom(instance)
leftActive.value = item.id;
@ -310,16 +313,16 @@
rightActive.value = goodClassThree.value[0]?.id || '';
getGoodList();
if (!item.isLoading && item.id) getgoodClassList(leftActive.value, 3); // , ,
}
}
const rightActive = ref(0);
const changeThree = (item, index) => {
const rightActive = ref(0);
const changeThree = (item, index) => {
rightActive.value = item.id;
show.value = 0;
getGoodList();
}
}
const addCart = (product_id, cart_num) => { //
const addCart = (product_id, cart_num) => { //
cartCreateApi({
cart_num: cart_num,
is_new: 0, // 01
@ -331,33 +334,33 @@
}).catch(err => {
uni.$u.toast(err.msg || '添加失败')
})
}
}
const keyword = ref('');
const keyword = ref('');
const searchKeyword = () => {
const searchKeyword = () => {
where.value.name = keyword.value;
where.value.store_name = keyword.value;
getGoodList();
}
}
const changeOrder = (order) => {
const changeOrder = (order) => {
where.value.order = order;
getGoodList();
}
}
const where = ref({
const where = ref({
page_no: 1,
page_size: 15,
name: '',
order: '',
store_name: '',
store_id: STORE_INFO.id
})
})
const loading = ref(true);
const goodList = ref([]);
const getGoodList = (loadmore = false) => {
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 = '';
@ -382,20 +385,20 @@
// STORE_INFO.value.detailed_address = res.data.store.detailed_address;
// }
})
}
}
//
const loadMoreGood = () => {
//
const loadMoreGood = () => {
getWXDom(instance)
getGoodList(true);
}
}
const goodClassList = ref([]); //
const goodClassTow = ref([]); //
const goodClassThree = ref([]); //
const classMap = new Map();
const getgoodClassList = (pid = 0, three = 1) => {
const goodClassList = ref([]); //
const goodClassTow = ref([]); //
const goodClassThree = ref([]); //
const classMap = new Map();
const getgoodClassList = (pid = 0, three = 1) => {
let page_no = classMap.get(pid) || 1;
goodClassListApi({
pid: pid,
@ -474,9 +477,9 @@
page_no++;
classMap.set(pid, page_no);
})
}
}
const navTo = (url) => {
const navTo = (url) => {
if (!userStore.token || !userStore.userInfo.mobile) return uni.showModal({
content: '您需要先登录才可使用该功能, 是否前去登录',
success: (e) => {
@ -495,13 +498,13 @@
uni.navigateTo({
url: url
})
}
}
//
const showGoodPopup = ref(false);
const goodRef = ref(null);
const goodData = ref({});
const openGoodPopup = (item) => { // /
//
const showGoodPopup = ref(false);
const goodRef = ref(null);
const goodData = ref({});
const openGoodPopup = (item) => { // /
goodData.value = item;
goodRef.value.setData(item);
showGoodPopup.value = true;
@ -512,8 +515,8 @@
cate_id: item.cate_id,
store_id: STORE_INFO.id
});
};
const changeGood = (data) => { //
};
const changeGood = (data) => { //
showGoodPopup.value = false;
if (!userStore.token) return uni.showModal({
content: '您需要先登录才可使用该功能, 是否前去登录',
@ -532,20 +535,20 @@
});
addCart(data.product_id, data.cart_num);
}
//
const settleAccounts = () => {
}
//
const settleAccounts = () => {
uni.navigateTo({
url: '/pagesOrder/settle/settle'
})
}
}
//
const cartInfo = ref({
//
const cartInfo = ref({
total_price: '0.00',
count: 0
})
const getCartList = (res) => {
})
const getCartList = (res) => {
cartListApi({
page_no: 1,
page_size: 100,
@ -556,32 +559,32 @@
}
cartStore.setCartList(res.data?.lists.map(item => item.id))
})
}
}
//
const btns = ref({
//
const btns = ref({
height: 0,
top: 0,
bottom: 0,
left: 0
});
});
//
const shareInfo = ref({
//
const shareInfo = ref({
uid: '',
real_name: '',
store_id: ''
});
});
const getShareInfo = () => {
const getShareInfo = () => {
if (uni.getStorageSync('SHARE_INFO')) {
shareInfo.value = (uni.getStorageSync('SHARE_INFO'))
}
}
getShareInfo()
}
getShareInfo()
onLoad(async (opt) => {
onLoad(async (opt) => {
where.value.store_id = opt.id || STORE_INFO.id;
// id
if (opt.id) {
@ -603,9 +606,9 @@
//
btns.value = uni.getMenuButtonBoundingClientRect();
// #endif
})
})
onShow(() => {
onShow(() => {
//
if (userStore.token && userStore.userInfo.mobile) {
userInfoApi().then(res => {
@ -620,11 +623,11 @@
}
});
}
});
});
let instance; //
const getWXDom = () => {
let instance; //
const getWXDom = () => {
let query = uni.createSelectorQuery().in(instance).select("#drag_area");
query.fields({
size: true,
@ -635,22 +638,22 @@
targetHeight.value = data.scrollHeight - data.height
}
).exec();
}
}
onMounted(() => {
onMounted(() => {
instance = getCurrentInstance(); //
setTimeout(() => {
getWXDom(instance)
}, 500)
})
})
</script>
<style lang="scss">
.content {
.content {
background-color: #fff;
}
}
.navbar {
.navbar {
padding: 0 20rpx;
display: flex;
align-items: center;
@ -677,14 +680,15 @@
right: 0;
background-color: #FF0000;
color: #FFFFFF;
padding: 0 5rpx;
padding: 0 8rpx;
border-radius: 50rpx;
font-size: 18rpx;
}
}
}
.head-view {
}
}
.head-view {
background-color: #fff;
height: 180rpx;
width: 750rpx;
@ -734,9 +738,9 @@
}
}
}
}
}
.r-btn {
.r-btn {
position: absolute;
right: 0;
top: 0;
@ -749,9 +753,9 @@
align-items: center;
justify-content: center;
box-shadow: -10rpx 0 60rpx 1rpx rgba(0, 0, 0, 0.3);
}
}
.cateOne {
.cateOne {
background-color: #fff;
.head-title {
@ -834,9 +838,9 @@
background-color: rgba(#20b128, 0.1);
}
}
}
}
.scroll-box {
.scroll-box {
// background-color: red;
display: flex;
@ -1006,9 +1010,9 @@
}
}
}
}
}
.fiexd-btn-box {
.fiexd-btn-box {
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
height: 140rpx;
height: calc(constant(safe-area-inset-bottom) + 140rpx);
@ -1061,16 +1065,16 @@
font-size: 18rpx;
}
}
}
}
.headScoll {
.headScoll {
position: relative;
overflow: hidden;
transition: 400ms;
}
}
.store-info {
.store-info {
margin: 0 0 20rpx 20rpx;
margin-top: 20rpx;
}
}
</style>