You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong_qianduan/pages/shopList/shopPage.vue

772 lines
17 KiB

8 months ago
<template>
6 months ago
<view class="shop">
<view class="navbarContent">
<u-navbar :is-back="false" :background="background" :border-bottom="false">
<uni-icons type="left" size="24" color="#fff" class="back" @click="back"></uni-icons>
8 months ago
<view class="search-box">
<view @click="search" class="search-model"></view>
<u-search shape="round" :disabled="true" placeholder="搜索本品牌商品" bg-color="#ffffff"
:show-action="false"></u-search>
</view>
6 months ago
</u-navbar>
</view>
8 months ago
<view class="page">
<view class="shop-tip">
6 months ago
<image :src="storeInfo.logoImage ? storeInfo.logoImage.preview_url : ''" mode="aspectFill" class="logo">
</image>
6 months ago
<text>{{ storeInfo.store_name }}</text>
8 months ago
<view class="tip">
<image src="/static/shop/t1.png" mode="aspectFill"></image>
100%正品
</view>
<view class="tip">
<image src="/static/shop/t2.png" mode="aspectFill"></image>
天天有特价
</view>
<view class="tip">
<image src="/static/shop/t3.png" mode="aspectFill"></image>
退货无忧
</view>
</view>
<view class="shop-info">
6 months ago
<image :src="shopDetail.logoImage && shopDetail.logoImage[0].external_url" mode="aspectFill"
class="logo"></image>
8 months ago
<view class="info-box">
7 months ago
<view class="name">{{ shopDetail.shop_name }}</view>
8 months ago
<view class="intro">
7 months ago
<text class="label">{{ shopDetail.shop_label }}</text>
<view v-if="shopDetail.is_show_license == 1" @click="toCer">
<image src="/static/cer.png" mode="aspectFill"></image>
6 months ago
证照
</view>
8 months ago
</view>
</view>
7 months ago
<button open-type="share" class="share-btn">
<image src="@/static/share.png" mode="aspectFill"></image>
分享
</button>
8 months ago
</view>
6 months ago
<view class="shop-goods">
<!-- <view v-if="goodsCate.filter(v => v.category_id === firstCate)[0].children.length > 0" class="second-cate">
<scroll-view class="second-cate-tabs" scroll-x>
7 months ago
<view v-for="(item, index) in goodsCate.filter(v => v.category_id === firstCate)[0].children" :key="index" class="cate-item" :class="{active: secondCate === item.category_id}" @click="secondCate = item.category_id">
{{ item.name }}
</view>
</scroll-view>
6 months ago
</view> -->
<view class="goods-content">
<view class="first-cate">
<scroll-view class="first-cate-tabs" scroll-y>
6 months ago
<view v-for="(item, index) in goodsCate" :key="index" class="cate-item" :class="{
5 months ago
active: firstCate === item.category_id,
prev: goodsCate[index + 1] && goodsCate[index + 1].category_id === firstCate,
next: goodsCate[index - 1] && goodsCate[index - 1].category_id === firstCate,
}" @click="firstCate = item.category_id;secondCate = '';">
{{ item.name }}
</view>
</scroll-view>
</view>
<view class="content">
<view class="filter-box">
6 months ago
<view v-for="(item, index) in filterList" :key="index" class="filter-item"
:class="{ active: activeFilter === item.value}" @click="changeFilter(item.value)">
7 months ago
{{ item.name }}
6 months ago
<text v-if="item.value === 'price'" class="down"
:class="{ on: activeFilter === 'price' && filterDirection === 'DESC'}"
style="top: 22rpx;"></text>
<text v-if="item.value === 'price'" class="up"
:class="{ on: activeFilter === 'price' && filterDirection === 'ASC'}"></text>
</view>
</view>
<view class="goods-list">
6 months ago
<view v-for="(item, index) in goods" :key="index" class="good"
@click="onGoodDetail(item.goods_id)">
7 months ago
<image :src="item.goods_image" mode="aspectFill"></image>
<view class="name">{{ item.goods_name }}</view>
<view class="price">
6 months ago
<text
class="now-price">¥{{ item.goods_price_min>0?Number(item.goods_price_min):0.00 }}</text>
<text v-if="item.line_price_min > 0"
class="origin-price">¥{{ item.line_price_min>0?Number(item.line_price_min):'' }}</text>
</view>
</view>
</view>
<view v-if="goods.length && !loading" class="finished">{{ loadTitle }}</view>
<view v-if="finished && !goods.length" class="empty">
6 months ago
<image mode="aspectFill" src="@/static/empty.png" alt="暂无商品" />
<view>暂无商品</view>
</view>
</view>
</view>
</view>
6 months ago
<view class="toCart" @click.stop="toCart">
<image src="@/static/shop/cart.png"></image>
7 months ago
</view>
<view class="toTop" v-if="isTop" @click="openScrollTo()">
<image :src="$picUrl+'/static/toTop.png?=1'"></image>
</view>
8 months ago
</view>
6 months ago
</view>
8 months ago
</template>
<script>
import styleColor from '../styleColor';
import * as Api from '@/api/shop/index';
7 months ago
import * as cstegory from '@/api/category'
import * as GoodsApi from '@/api/goods'
6 months ago
import {
debounce
} from 'lodash';
export default {
data() {
return {
background: {
background: 'url(https://www.royaum.com.cn/static/shop/shop-page-bg.png) center top no-repeat',
backgroundSize: '100% auto',
},
id: '',
8 months ago
scrollTop: 0,
7 months ago
shopDetail: {},
goodsCate: [],
7 months ago
firstCate: '',
secondCate: '',
7 months ago
activeFilter: 'all',
filterDirection: 'ASC',
6 months ago
filterList: [{
name: '综合',
value: 'all'
},
{
name: '价格',
value: 'price'
},
6 months ago
// { name: '折扣', value: 'discount' },
6 months ago
{
name: '销量',
value: 'sales'
}
],
isTop: false,
page: 1,
limit: 10,
loadTitle: '',
loading: false,
finished: true,
7 months ago
goods: []
6 months ago
};
},
6 months ago
computed: {
storeInfo() {
return JSON.parse(uni.getStorageSync('storeInfo') || '{}');
},
// styleIndex() {
// const index = uni.getStorageSync('styleIndex') || '';
// return index;
// },
// navBgColor() {
// return this.styleIndex ? (styleColor.shopNavBgColor[this.styleIndex - 1] || '#FFA3B2') : '#FFA3B2'
// }
},
7 months ago
watch: {
7 months ago
firstCate() {
this.goods = [];
this.page = 1;
this.loading = false;
this.finished = false;
this.getGoodsList();
},
7 months ago
secondCate() {
this.goods = [];
this.page = 1;
this.loading = false;
this.finished = false;
this.getGoodsList();
},
},
onPageScroll(e) {
if (e.scrollTop <= 200) { // 当滚动到顶部且向下滑动时为true
this.isTop = false
} else {
this.isTop = true
8 months ago
}
},
6 months ago
onLoad({
id
}) {
this.id = id;
this.getShopDetail()
7 months ago
this.getGoodsTypeList();
},
onReachBottom() {
6 months ago
this.getGoodsList();
8 months ago
},
6 months ago
methods: {
8 months ago
back() {
6 months ago
let pages = getCurrentPages();
if (pages.length > 1) {
uni.navigateBack();
} else {
uni.reLaunch({
url: "/pages/index/index"
})
}
8 months ago
},
search() {
// 跳转商品搜索
uni.navigateTo({
7 months ago
url: `/pages/search/index?merchantId=${this.id}`
8 months ago
})
},
changeFilter(item) {
if (item !== this.activeFilter) {
this.activeFilter = item;
this.filterDirection = 'ASC';
7 months ago
} else if (item === 'price') {
this.filterDirection = this.filterDirection === 'ASC' ? 'DESC' : 'ASC';
}
7 months ago
this.goods = [];
this.page = 1;
this.loading = false;
this.finished = false;
this.getGoodsList();
},
openScrollTo() {
uni.pageScrollTo({
scrollTop: 0
})
},
toCer() {
uni.navigateTo({
url: `/pages/shopList/certificate?id=${this.id}`,
});
},
async getShopDetail() {
Api.getShopDetail({
6 months ago
id: this.id
})
.then(result => {
console.log(result);
7 months ago
this.shopDetail = result.data.detail;
})
.finally(() => this.loading = false)
},
7 months ago
getGoodsTypeList() {
const that = this;
return new Promise((resolve, reject) => {
6 months ago
cstegory.getShopCategory({
7 months ago
merchantId: this.id
7 months ago
})
.then(res => {
// 合并新数据
6 months ago
if (res.data.list.length > 0) {
let all = {
category_id: 0,
name: '全部'
}
res.data.list.unshift(all)
that.goodsCate = res.data.list;
that.firstCate = res.data.list[0].category_id;
}
7 months ago
})
.catch(reject)
})
},
/**
* 获取商品列表
* @param {number} pageNo 页码
*/
7 months ago
getGoodsList: debounce(function() {
7 months ago
if (this.loading || this.finished) {
6 months ago
return;
7 months ago
}
this.loadTitle = "";
const param = {
sortType: this.activeFilter,
7 months ago
sortPrice: this.filterDirection === 'DESC' ? 1 : 0,
5 months ago
categoryId: this.firstCate > 0 ? this.firstCate : '',
7 months ago
merchantId: this.id,
7 months ago
page: this.page++,
}
GoodsApi.list(param)
.then(result => {
// 合并新数据
const data = result.data.list.data;
console.log(data);
this.goods = this.goods.concat(data);
this.finished = data.length < 10;
6 months ago
this.loadTitle = this.finished ? "我是有底线的哦~" : "上拉加载更多";
7 months ago
})
7 months ago
}, 500),
7 months ago
toCart() {
6 months ago
uni.reLaunch({
7 months ago
url: '/pages/cart/index'
})
},
7 months ago
// 跳转商品详情页
onGoodDetail(goodsId) {
this.$navTo('pages/goods/detail', {
goodsId
})
},
7 months ago
/**
* 分享当前页面
*/
onShareAppMessage() {
6 months ago
const app = this
// 构建页面参数
const params = app.$getShareUrlParams({
id: app.id
});
return {
title: app.shopDetail.shop_name,
path: "/pages/shopList/shopPage?" + params
}
7 months ago
},
6 months ago
7 months ago
/**
* 分享到朋友圈
* 本接口为 Beta 版本暂只在 Android 平台支持详见分享到朋友圈 (Beta)
*/
onShareTimeline() {
6 months ago
const app = this
// 构建页面参数
const params = app.$getShareUrlParams({
id: app.id
});
return {
title: app.shopDetail.shop_name,
path: "/pages/shopList/shopPage?" + params
}
7 months ago
}
8 months ago
}
6 months ago
};
8 months ago
</script>
<style lang="scss" scoped>
6 months ago
.shop {
height: 100vh;
display: flex;
flex-direction: column;
6 months ago
background: url(https://www.royaum.com.cn/static/shop/shop-page-bg.png) center top no-repeat;
background-size: 100% auto;
.navbarContent {
8 months ago
display: flex;
6 months ago
justify-content: flex-start;
8 months ago
align-items: center;
6 months ago
.back {
margin-right: 24rpx;
margin-left: 12rpx;
8 months ago
}
6 months ago
.search-box {
position: relative;
.search-model {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 100;
}
6 months ago
}
6 months ago
&::v-deep .u-navbar-inner {
position: relative;
margin-right: 0 !important;
6 months ago
display: flex;
6 months ago
.search-box {
width: 442rpx;
8 months ago
}
}
}
6 months ago
.page {
flex: 1;
8 months ago
display: flex;
6 months ago
flex-direction: column;
padding-top: 30rpx;
.shop-tip {
padding: 0 24rpx;
display: flex;
align-items: center;
>text {
font-size: 24rpx;
8 months ago
color: #fff;
6 months ago
margin-right: auto;
}
.logo {
width: 50rpx;
height: 50rpx;
margin-right: 10rpx;
8 months ago
}
6 months ago
.tip {
font-size: 22rpx;
color: #fff;
margin-left: 20rpx;
display: flex;
align-items: center;
6 months ago
image {
width: 26rpx;
height: 26rpx;
margin-right: 8rpx;
}
}
}
6 months ago
.shop-info {
7 months ago
display: flex;
align-items: center;
6 months ago
margin-top: 30rpx;
padding: 0 24rpx;
6 months ago
.logo {
width: 90rpx;
height: 90rpx;
border-radius: 10rpx;
margin-right: 10rpx;
}
.info-box {
flex: 1;
.name {
font-size: 30rpx;
color: #fff;
margin-bottom: 18rpx;
}
.intro {
display: flex;
align-items: center;
.label {
height: 36rpx;
background: #F34A40;
6 months ago
border-radius: 4rpx;
padding: 0 7rpx;
line-height: 36rpx;
text-align: center;
font-size: 24rpx;
color: #fff;
6 months ago
margin-right: 20rpx;
}
>view {
width: 90rpx;
height: 36rpx;
background: rgba(0, 0, 0, 0.2);
border-radius: 4rpx;
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: 24rpx;
>image {
width: 21rpx;
height: 20rpx;
margin-right: 7rpx;
}
}
}
}
6 months ago
.share-btn {
width: 130rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 20rpx;
color: #fff;
background: #F34A40;
border-radius: 30rpx;
padding: 0;
>image {
width: 26rpx;
height: 22rpx;
margin-right: 12rpx;
}
}
}
6 months ago
.shop-goods {
flex: 1;
display: flex;
6 months ago
flex-direction: column;
margin-top: 30rpx;
background: #F0F4F3;
border-radius: 20rpx 20rpx 0 0;
// padding-top: 24rpx;
.second-cate {
padding: 0 24rpx;
margin-bottom: 24rpx;
.second-cate-tabs {
height: 80rpx;
align-items: center;
white-space: nowrap;
width: 100%;
overflow-x: auto;
overflow-y: hidden;
.cate-item {
6 months ago
display: inline-block;
height: 80rpx;
padding: 0 26rpx;
background: #FFFFFF;
border-radius: 10rpx;
line-height: 80rpx;
margin-right: 20rpx;
color: #333333;
font-size: 28rpx;
&:last-child {
margin-right: 0;
6 months ago
}
6 months ago
&.active {
6 months ago
background: #F34A40;
color: #fff;
}
}
}
}
6 months ago
.goods-content {
flex: 1;
display: flex;
6 months ago
.first-cate {
height: 100%;
5 months ago
width: 120rpx;
6 months ago
.first-cate-tabs {
overflow-x: hidden;
overflow-y: auto;
background: #fff;
.cate-item {
width: 100%;
5 months ago
padding: 20rpx 25rpx;
6 months ago
color: #999999;
font-size: 24rpx;
position: relative;
background: #F0F4F3;
5 months ago
text-align: center;
word-wrap: break-word;
6 months ago
&.prev {
border-radius: 0 0 30rpx 0;
}
&.next {
border-radius: 0 30rpx 0 0;
}
6 months ago
&.active {
background: transparent;
&::before {
content: '';
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 0;
width: 4rpx;
5 months ago
height: calc(100% - 40rpx);
6 months ago
background: #F34A40;
}
}
}
}
}
6 months ago
.content {
background: #fff;
height: 100%;
width: calc(100% - 108rpx);
display: flex;
6 months ago
flex-direction: column;
.filter-box {
height: 88rpx;
padding: 0 40rpx;
display: flex;
justify-content: space-between;
align-items: center;
.filter-item {
color: #333;
font-size: 28rpx;
position: relative;
display: flex;
justify-content: center;
&.active {
color: #F34A40;
}
text {
width: 0;
height: 0;
border: 10rpx solid;
border-color: #000 transparent transparent transparent;
vertical-align: top;
position: absolute;
left: 60rpx;
top: 15rpx;
&.up {
border-color: transparent transparent #000 transparent;
top: -1rpx;
&.on {
border-color: transparent transparent #F34A40 transparent;
}
}
&.down.on {
border-color: #F34A40 transparent transparent transparent;
}
}
}
6 months ago
}
.goods-list {
padding: 0 20rpx;
overflow-x: hidden;
overflow-y: auto;
display: flex;
flex-wrap: wrap;
.good {
width: 290rpx;
height: 422rpx;
background: #FFFFFF;
border-radius: 10rpx;
border: 1px solid #EAEAEA;
margin-right: 22rpx;
margin-bottom: 20rpx;
border-radius: 10rpx;
border: 1px solid #EAEAEA;
&:nth-child(2n) {
margin-right: 0;
}
>image {
width: 100%;
height: 287rpx;
}
6 months ago
.name {
color: #333333;
font-size: 26rpx;
margin: 30rpx 0 24rpx;
line-height: 26rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 0 24rpx;
}
.price {
padding: 0 24rpx;
.now-price {
color: #E53623;
font-size: 34rpx;
}
.origin-price {
text-decoration: line-through;
color: #999999;
font-size: 24rpx;
margin-left: 10;
}
}
}
}
6 months ago
.finished,
.loading {
font-size: 28rpx;
line-height: 100rpx;
text-align: center;
color: #bbb;
}
.empty {
margin-top: 100rpx;
font-size: 28rpx;
text-align: center;
color: #bbb;
}
.empty image {
display: block;
width: 306rpx;
height: 200rpx;
margin: 0 auto 20rpx;
pointer-events: none;
}
8 months ago
}
}
}
6 months ago
.toCart {
position: fixed;
bottom: 170rpx;
right: 26rpx;
width: 100rpx;
height: 100rpx;
border-radius: 50%;
opacity: 1;
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
image {
width: 100%;
height: 100%;
}
7 months ago
}
6 months ago
.toTop {
position: fixed;
bottom: 65rpx;
right: 26rpx;
width: 100rpx;
height: 100rpx;
border-radius: 50%;
opacity: 1;
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
image {
width: 100%;
height: 100%;
}
}
}
6 months ago
8 months ago
}
6 months ago
</style>