This commit is contained in:
砂糖
2026-02-07 18:01:13 +08:00
commit 8015759c65
2110 changed files with 269866 additions and 0 deletions

View File

@@ -0,0 +1,158 @@
<template>
<view v-if="list.length" class="service-wrapper">
<!-- 服务简述 -->
<view class="service-simple" @click="handlePopup">
<view class="s-list">
<view class="s-item" v-for="(item, index) in list" :key="index">
<text class="item-icon iconfont icon-fuwu"></text>
<text class="item-val">{{ item.name }}</text>
</view>
</view>
<!-- 扩展箭头 -->
<view class="s-arrow f-26 col-9 t-r">
<text class="iconfont icon-xiangyoujiantou"></text>
</view>
</view>
<!-- 详情内容弹窗 -->
<u-popup v-model="showPopup" mode="bottom" :closeable="true" :border-radius="26">
<view class="service-content">
<view class="title">服务</view>
<scroll-view class="content-scroll" :scroll-y="true">
<view class="s-list clearfix">
<view class="s-item" v-for="(item, index) in list" :key="index">
<text class="item-icon iconfont icon-fuwu"></text>
<view class="item-val">{{ item.name }}</view>
<view class="item-summary">{{ item.summary }}</view>
</view>
</view>
</scroll-view>
</view>
</u-popup>
</view>
</template>
<script>
import * as ServiceApi from '@/api/goods/service'
export default {
props: {
// 商品ID
goodsId: {
type: Number,
default: null
}
},
data() {
return {
// 正在加载
isLoading: true,
// 显示详情内容弹窗
showPopup: false,
// 服务列表数据
list: []
}
},
created() {
// 获取商品服务列表
this.getServiceList()
},
methods: {
// 获取商品服务列表
getServiceList() {
const app = this
app.isLoading = true
ServiceApi.list(app.goodsId)
.then(result => app.list = result.data.list)
.finally(() => app.isLoading = false)
},
// 显示弹窗
handlePopup() {
this.showPopup = !this.showPopup
}
}
}
</script>
<style lang="scss" scoped>
.service-wrapper {
min-height: 24rpx;
margin-bottom: -24rpx;
}
// 服务简述
.service-simple {
padding: 24rpx 30rpx;
display: flex;
align-items: center;
.s-list {
flex: 1;
margin-left: -15rpx;
}
.s-item {
float: left;
font-size: 26rpx;
margin: 8rpx 15rpx;
.item-icon {
color: #FA2209;
}
.item-val {
margin-left: 12rpx;
}
}
}
// 服务详细内容
.service-content {
padding: 24rpx;
.title {
font-size: 30rpx;
margin-bottom: 50rpx;
font-weight: bold;
text-align: center;
}
.content-scroll {
min-height: 400rpx;
max-height: 750rpx;
}
.s-list {
padding: 0 30rpx 0 80rpx;
}
.s-item {
position: relative;
margin-bottom: 60rpx;
.item-icon {
position: absolute;
top: 6rpx;
left: -50rpx;
color: #FA2209;
}
.item-val {
font-size: 28rpx;
}
.item-summary {
font-size: 26rpx;
margin-top: 20rpx;
color: #6d6d6d;
}
}
}
</style>

View File

@@ -0,0 +1,203 @@
<template>
<goods-sku-popup :value="value" @input="onChangeValue" border-radius="20" :custom-action="findGoodsInfo"
:mode="skuMode" :defaultPrice="goods.price" :defaultStock="goods.stock" :maskCloseAble="true"
@open="openSkuPopup" @close="closeSkuPopup" @add-cart="addCart" @buy-now="buyNow" />
</template>
<script>
import { setCartTotalNum } from '@/utils/app'
import * as CartApi from '@/api/cart'
import * as GoodsApi from '@/api/goods'
import GoodsSkuPopup from '@/components/goods-sku-popup'
let goodsInfo;
export default {
components: {
GoodsSkuPopup
},
model: {
prop: 'value',
event: 'input'
},
props: {
// true 组件显示 false 组件隐藏
value: {
Type: Boolean,
default: false
},
// 模式 1:都显示 2:只显示购物车 3:只显示立即购买
skuMode: {
type: Number,
default: 1
},
// 商品详情信息
goods: {
type: Object,
default: {}
}
},
data() {
return {}
},
created() {
const app = this
const { goods } = app
goodsInfo = {
_id: goods.goodsId,
name: goods.name,
goods_thumb: goods.logo,
sku_list: app.getSkuList(),
spec_list: app.getSpecList()
}
},
methods: {
// 监听组件显示隐藏
onChangeValue(val) {
this.$emit('input', val)
},
/**
* 获取商品信息
* 这里可以看到每次打开SKU都会去重新请求商品信息,为的是每次打开SKU组件可以实时看到剩余库存
*/
findGoodsInfo() {
return new Promise((resolve, reject) => {
resolve(goodsInfo)
})
},
// 整理商品SKU列表
getSkuList() {
const app = this
const { goods: { name, logo, skuList } } = app
const skuData = []
if (skuList) {
skuList.forEach(item => {
skuData.push({
_id: item.id,
sku_id: item.skuId,
goods_id: item.goodsId,
name: name,
image: item.logo ? item.logo : logo,
price: item.price,
stock: item.stock,
spec_value_ids: item.specIds,
sku_name_arr: app.getSkuNameArr(item.specIds)
})
})
}
return skuData
},
// 获取sku记录的规格值列表
getSkuNameArr(specValueIds) {
const app = this
const defaultData = ['默认']
const skuNameArr = []
if (specValueIds != "" && specValueIds.length > 0) {
specValueIds.forEach((valueId, specId) => {
const specValueName = app.getSpecValueName(valueId, specId)
skuNameArr.push(specValueName)
})
}
const result = skuNameArr.length ? skuNameArr : defaultData
return result
},
// 获取指定的规格值名称
getSpecValueName(valueId, specId) {
const app = this
const { goods: { specList } } = app
if (specList.length > 0) {
const res = specList[specId].valueList.find(specValue => {
return specValue.specValueId == valueId
})
if (res) {
return res.specValue
} else {
return ""
}
} else {
return ""
}
},
// 整理规格数据
getSpecList() {
const { goods: { specList } } = this;
const defaultData = [{ name: '默认', list: [{ name: '默认' }] }];
const specData = [];
if (specList.length > 0) {
specList.forEach(group => {
const children = [];
group.valueList.forEach(specValue => {
children.push({ name: specValue.specValue });
})
specData.push({
name: group.name,
list: children
})
})
}
return specData.length > 0 ? specData : defaultData
},
// sku组件 开始-----------------------------------------------------------
openSkuPopup() {
// console.log("监听 - 打开sku组件")
},
closeSkuPopup() {
// console.log("监听 - 关闭sku组件")
},
// 加入购物车按钮
addCart(selectShop) {
const app = this
console.log(selectShop)
const { goods_id, sku_id, buy_num } = selectShop
CartApi.save(goods_id, '+', sku_id, buy_num)
.then(result => {
// 隐藏当前弹窗
app.onChangeValue(false);
// 购物车商品总数量
const cartTotal = result.data ? result.data.cartTotal : 0;
// 缓存购物车数量
setCartTotalNum(cartTotal);
// 传递给父级
app.$emit('addCart', cartTotal);
})
},
// 立即购买
buyNow(selectShop) {
// 跳转到订单结算页
this.$navTo('pages/settlement/goods', {
mode: 'buyNow',
goodsId: selectShop.goods_id,
skuId: selectShop.sku_id,
buyNum: selectShop.buy_num
})
// 隐藏当前弹窗
this.onChangeValue(false)
}
}
}
</script>
<style lang="scss" scoped>
</style>

View File

@@ -0,0 +1,88 @@
<template>
<!-- 商品图片 -->
<view class="images-swiper">
<swiper class="swiper-box" :autoplay="autoplay" :duration="duration" :indicator-dots="indicatorDots"
:interval="interval" :circular="true" @change="setCurrent">
<swiper-item v-for="(item, index) in images" :key="index" @click="onPreviewImages(index)">
<image class="slide-image" mode="aspectFill" :src="item"></image>
</swiper-item>
</swiper>
<view class="banner-num">
<text>{{ currentIndex }}</text>
<text>/</text>
<text>{{ images.length }}</text>
</view>
</view>
</template>
<script>
export default {
props: {
images: {
type: Array,
default: []
}
},
data() {
return {
indicatorDots: true, // 是否显示面板指示点
autoplay: true, // 是否自动切换
interval: 3000, // 自动切换时间间隔
duration: 800, // 滑动动画时长
currentIndex: 1 // 轮播图指针
}
},
methods: {
// 设置轮播图当前指针 数字
setCurrent(e) {
const app = this
app.currentIndex = e.detail.current + 1
},
// 浏览商品图片
onPreviewImages(index) {
const app = this
const imageUrls = []
app.images.forEach(item => {
imageUrls.push(item);
});
uni.previewImage({
current: imageUrls[index],
urls: imageUrls
})
}
}
}
</script>
<style lang="scss" scoped>
// swiper组件
.swiper-box {
width: 100%;
height: 100vw;
.slide-image {
width: 100%;
height: 100%;
margin: 0rpx;
padding: 0rpx;
display: block;
border-radius: 1rpx;
}
}
/* banner计数 */
.banner-num {
position: absolute;
right: 30rpx;
margin-top: -70rpx;
padding: 2rpx 18rpx;
background: rgba(0, 0, 0, 0.363);
border-radius: 50rpx;
color: #fff;
font-size: 26rpx;
}
</style>

View File

@@ -0,0 +1,232 @@
.container {
padding-bottom: 112rpx;
}
/* 商品信息 */
.goods-info {
background: #fff;
padding: 25rpx 30rpx;
}
.info-item__top {
min-height: 40rpx;
margin-bottom: 20rpx;
}
.info-item__top .active-tag {
width: 108rpx;
color: #fff;
background: #fe293f;
padding: 3rpx 5rpx;
border-radius: 15rpx;
font-size: 24rpx;
text-align: center;
margin-right: 15rpx;
}
.floor-price__samll {
font-size: 26rpx;
line-height: 1;
color: #FA2209;
}
/* 商品价 */
.floor-price {
color: #FA2209;
margin-right: 15rpx;
font-size: 38rpx;
line-height: 1;
margin-bottom: -2rpx;
}
.original-price {
font-size: 24rpx;
line-height: 1;
text-decoration: line-through;
color: #959595;
}
.goods-sales {
font-size: 24rpx;
color: #959595;
}
.info-item__name .goods-name {
font-size: 28rpx;
}
/* 商品分享 */
.goods-share__line {
border-left: 1rpx solid #f4f4f4;
height: 60rpx;
margin: 0 30rpx;
}
.goods-share .share-btn {
line-height: normal;
padding: 0;
background: none;
border-radius: 0;
box-shadow: none;
font-size: 8pt;
border: none;
color: #191919;
}
.goods-share .share-btn::after {
border: none;
}
.goods-share .share__icon {
font-size: 40rpx;
margin-bottom: 5rpx;
}
/* 商品卖点 */
.info-item_selling-point {
margin-top: 8rpx;
font-size: 24rpx;
color: #808080;
}
// 选择商品规格
.goods-choice {
padding: 26rpx 30rpx;
font-size: 28rpx;
.spec-list {
display: flex;
align-items: center;
.spec-name {
margin-right: 10rpx;
}
}
}
/* 商品详情 */
.goods-content .item-title {
padding: 20rpx;
font-size: 30rpx;
}
.goods-content .goods-content-detail {
padding: 20rpx;
min-height: 400rpx;
}
/* 底部操作栏 */
.footer-fixed {
position: fixed;
bottom: var(--window-bottom);
left: 0;
right: 0;
display: flex;
height: 180rpx;
z-index: 11;
box-shadow: 0 -4rpx 40rpx 0 rgba(144, 52, 52, 0.1);
background: #fff;
}
.footer-container {
width: 100%;
display: flex;
margin-bottom: 40rpx;
}
// 快捷菜单
.foo-item-fast {
box-sizing: border-box;
width: 256rpx;
line-height: 1;
display: flex;
justify-content: center;
align-items: center;
.fast-item {
position: relative;
padding: 4rpx 10rpx;
line-height: 1;
// text-align: center;
.fast-icon {
margin-bottom: 6rpx;
}
&--home {
margin-right: 30rpx;
}
&--cart {
.fast-icon { padding-left: 3px; }
}
// 角标
.fast-badge {
display: inline-block;
box-sizing: border-box;
min-width: 46rpx;
padding: 5rpx;
color: #fff;
font-weight: 500;
font-size: 22rpx;
font-family: -apple-system-font, Helvetica Neue, Arial, sans-serif;
line-height: 36rpx;
text-align: center;
background-color: #fa5151;
border: 1px solid #fff;
border-radius: 999px;
}
.fast-badge--fixed {
position: absolute;
top: 0;
right: 0;
transform-origin: 100%
}
.fast-icon {
font-size: 46rpx;
}
.fast-text {
font-size: 24rpx;
}
}
}
// 操作按钮
.foo-item-btn {
flex: 1;
.btn-wrapper {
height: 100%;
display: flex;
align-items: center;
}
.btn-item {
flex: 1;
font-size: 28rpx;
height: 90rpx;
line-height: 90rpx;
margin-right: 5rpx;
text-align: center;
color: #fff;
border-radius: 8rpx;
}
// 立即购买按钮
.btn-item-main {
background: linear-gradient(to right, #f9211c, #ff6335);
}
// 购物车按钮
.btn-item-deputy {
background: linear-gradient(to right, $fuint-theme, $fuint-theme);
}
}

View File

@@ -0,0 +1,277 @@
<template>
<view v-show="!isLoading" class="container">
<!-- 商品图片轮播 -->
<SlideImage v-if="!isLoading" :images="goods.images" />
<!-- 商品信息 -->
<view v-if="!isLoading" class="goods-info m-top20">
<!-- 价格销量 -->
<view class="info-item info-item__top dis-flex flex-x-between flex-y-end">
<view class="block-left dis-flex flex-y-end">
<!-- 商品售价 -->
<text class="floor-price__samll"></text>
<text class="floor-price">{{ goods.price }}</text>
<!-- 划线价 -->
<text class="original-price">{{ goods.linePrice }}</text>
</view>
<view class="block-right dis-flex">
<!-- 销量 -->
<view class="goods-sales">
<text>已销售{{ goods.initSale }}</text>
</view>
</view>
</view>
<!-- 标题分享 -->
<view class="info-item info-item__name dis-flex flex-y-center">
<view class="goods-name flex-box">
<text class="twolist-hidden">{{ goods.name }}</text>
</view>
<!-- #ifdef MP-WEIXIN -->
<view class="goods-share__line"></view>
<view class="goods-share">
<button class="share-btn dis-flex flex-dir-column" open-type="share">
<text class="share__icon iconfont icon-fenxiang-post"></text>
<text class="f-24">分享</text>
</button>
</view>
<!-- #endif -->
</view>
<!-- 商品卖点 -->
<view v-if="goods.salePoint" class="info-item info-item_selling-point">
<text>{{ goods.salePoint }}</text>
</view>
</view>
<!-- 选择商品规格 -->
<view v-if="goods.isSingleSpec == 'N'" class="goods-choice m-top20 b-f" @click="onShowSkuPopup(3)">
<view class="spec-list">
<view class="flex-box">
<text class="col-8">选择</text>
<text class="spec-name" v-for="(item, index) in goods.specList" :key="index">{{ item.name }}</text>
</view>
<view class="f-26 col-9 t-r">
<text class="iconfont icon-xiangyoujiantou"></text>
</view>
</view>
</view>
<!-- 商品SKU弹窗 -->
<SkuPopup v-if="!isLoading" v-model="showSkuPopup" :skuMode="skuMode" :goods="goods" @addCart="onAddCart"/>
<!-- 商品描述 -->
<view v-if="!isLoading" class="goods-content m-top20">
<view class="item-title b-f">
<text>商品详情</text>
</view>
<block v-if="goods.description != ''">
<view class="goods-content-detail b-f">
<jyf-parser :html="goods.description"></jyf-parser>
</view>
</block>
<empty v-else tips="亲,暂无商品描述" />
</view>
<!-- 底部选项卡 -->
<view class="footer-fixed">
<view class="footer-container">
<!-- 导航图标 -->
<view class="foo-item-fast">
<!-- 首页 -->
<view class="fast-item fast-item--home" @click="onTargetHome">
<view class="fast-icon">
<text class="iconfont icon-shouye"></text>
</view>
<view class="fast-text">
<text>首页</text>
</view>
</view>
<!-- 购物车-->
<view class="fast-item fast-item--cart" @click="onTargetCart">
<view v-if="cartTotal > 0" class="fast-badge fast-badge--fixed">{{ cartTotal > 99 ? '99+' : cartTotal }}</view>
<view class="fast-icon">
<text class="iconfont icon-gouwuche"></text>
</view>
<view class="fast-text">
<text>购物车</text>
</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="foo-item-btn">
<view class="btn-wrapper">
<view class="btn-item btn-item-deputy" @click="onShowSkuPopup(2)">
<text>加入购物车</text>
</view>
<view class="btn-item btn-item-main" @click="onShowSkuPopup(3)">
<text>立即购买</text>
</view>
</view>
</view>
</view>
</view>
<!-- 快捷导航 -->
<shortcut bottom="200rpx" />
</view>
</template>
<script>
import { setCartTabBadge, setCartTotalNum } from '@/utils/app'
import * as GoodsApi from '@/api/goods'
import * as CartApi from '@/api/cart'
import jyfParser from '@/components/jyf-parser/jyf-parser'
import Shortcut from '@/components/shortcut'
import SlideImage from './components/SlideImage'
import SkuPopup from './components/SkuPopup'
export default {
components: {
jyfParser,
Shortcut,
SlideImage,
SkuPopup,
},
data() {
return {
// 正在加载
isLoading: true,
// 当前商品ID
goodsId: null,
// 商品详情
goods: {},
// 购物车总数量
cartTotal: 0,
// 显示/隐藏SKU弹窗
showSkuPopup: false,
// 模式 1:都显示 2:只显示购物车 3:只显示立即购买
skuMode: 1
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 商品ID
this.goodsId = parseInt(options.goodsId)
// 加载页面数据
this.onRefreshPage()
},
methods: {
// 刷新页面数据
onRefreshPage() {
const app = this
app.isLoading = true
Promise.all([app.getGoodsDetail(), app.getCartTotal()])
.finally(() => app.isLoading = false)
},
// 获取商品信息
getGoodsDetail() {
const app = this
return new Promise((resolve, reject) => {
GoodsApi.detail(app.goodsId)
.then(result => {
const goodsData = result.data;
if (goodsData.skuList) {
goodsData.skuList.forEach(function(sku, index) {
goodsData.skuList[index].specIds = sku.specIds.split('-');
goodsData.skuList[index].skuId = sku.id;
})
}
app.goods = goodsData;
app.skuMode = 3;
resolve(result);
})
.catch(err => reject(err))
})
},
// 获取购物车总数量
getCartTotal() {
const app = this
return new Promise((resolve, reject) => {
CartApi.list()
.then(result => {
app.cartTotal = result.data.totalNum;
setCartTotalNum(app.cartTotal);
setCartTabBadge();
resolve(result);
})
.catch(err => reject(err));
})
},
// 更新购物车数量
onAddCart() {
this.$toast("添加购物车成功");
this.getCartTotal();
},
/**
* 显示/隐藏SKU弹窗
* @param {skuMode} 模式 1:都显示 2:只显示购物车 3:只显示立即购买
*/
onShowSkuPopup(skuMode = 1) {
this.skuMode = skuMode;
this.showSkuPopup = !this.showSkuPopup;
},
// 跳转到首页
onTargetHome(e) {
this.$navTo('pages/index/index');
},
// 跳转到购物车页
onTargetCart() {
this.$navTo('pages/cart/index')
}
},
/**
* 分享当前页面
*/
onShareAppMessage() {
const app = this
// 构建页面参数
const params = app.$getShareUrlParams({
goodsId: app.goodsId,
})
return {
title: app.goods.name,
imageUrl: app.goods.images[0],
path: `/pages/goods/detail?${params}`
}
},
/**
* 分享到朋友圈
* 本接口为 Beta 版本,暂只在 Android 平台支持,详见分享到朋友圈 (Beta)
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
*/
onShareTimeline() {
const app = this
// 构建页面参数
const params = app.$getShareUrlParams({
goodsId: app.goodsId,
})
return {
title: app.goods.name,
imageUrl: app.goods.images[0],
path: `/pages/goods/detail?${params}`
}
}
}
</script>
<style>
page {
background: #fafafa;
}
</style>
<style lang="scss" scoped>
@import "./detail.scss";
</style>

View File

@@ -0,0 +1,492 @@
<template>
<mescroll-body ref="mescrollRef" :sticky="true" @init="mescrollInit" :down="{ native: true }" @down="downCallback"
:up="upOption" @up="upCallback">
<!-- 页面头部 -->
<view class="header">
<search class="search" :tips="options.search ? options.search : '搜索商品'" @event="handleSearch" />
</view>
<!-- 排序标签 -->
<view class="store-sort">
<view class="sort-item" :class="{ active: sortType === 'all' }" @click="handleSortType('all')">
<text>综合</text>
</view>
<view class="sort-item" :class="{ active: sortType === 'sales' }" @click="handleSortType('sales')">
<text>销量</text>
</view>
<view class="sort-item sort-item-price" :class="{ active: sortType === 'price' }" @click="handleSortType('price')">
<text>价格</text>
<view class="price-arrow">
<view class="icon up" :class="{ active: sortType === 'price' && !sortPrice }">
<text class="iconfont icon-arrow-up"></text>
</view>
<view class="icon down" :class="{ active: sortType === 'price' && sortPrice }">
<text class="iconfont icon-arrow-down"></text> </view>
</view>
</view>
</view>
<!-- 商品列表 -->
<view class="goods-list clearfix" v-if="list.content" :class="['column-1']">
<view class="goods-item" v-for="(item, index) in list.content" :key="index" @click="onTargetDetail(item.id, item.type)">
<!-- 单列显示 -->
<view v-if="showView" class="dis-flex">
<!-- 商品图片 -->
<view class="goods-item_left">
<image class="image" :src="item.logo"></image>
</view>
<view class="goods-item_right">
<!-- 商品名称 -->
<view class="goods-name twolist-hidden">
<text>{{ item.name }}</text>
</view>
<view class="goods-item_desc">
<!-- 商品卖点 -->
<view class="desc-selling_point dis-flex">
<text class="onelist-hidden">{{ item.salepoint }}</text>
</view>
<view class="coupon-attr">
<view class="attr-l">
<!-- 销量 -->
<view class="desc-goods_sales dis-flex">
<text>已售{{ item.initSale }}</text>
</view>
<!-- 价格 -->
<view class="desc_footer">
<text class="price_x">¥{{ item.price }}</text>
<text class="price_y col-9" v-if="item.linePrice > 0">¥{{ item.linePrice }}</text>
</view>
</view>
<view class="attr-r">
<!--购买按钮-->
<view class="receive">
<text>去购买</text>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</mescroll-body>
</template>
<script>
import MescrollBody from '@/components/mescroll-uni/mescroll-body.vue'
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins'
import * as GoodsApi from '@/api/goods'
import { getEmptyPaginateObj, getMoreListData } from '@/utils/app'
import Search from '@/components/search'
const pageSize = 15
const showViewKey = 'GoodsList-ShowView';
export default {
components: {
MescrollBody,
Search
},
mixins: [MescrollMixin],
data() {
return {
isLoading: false,
showView: true, // 列表显示方式 (true列表、false平铺)
sortType: 'all', // 排序类型
sortPrice: false, // 价格排序 (true高到低 false低到高)
options: {}, // 当前页面参数
list: getEmptyPaginateObj(), // 商品列表数据
// 上拉加载配置
upOption: {
// 首次自动执行
auto: true,
// 每页数据的数量; 默认10
page: { size: pageSize },
// 数量要大于4条才显示无更多数据
noMoreSize: 4,
}
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 记录options
this.options = options;
// 设置默认列表显示方式
this.setShowView();
},
methods: {
/**
* 上拉加载的回调 (页面初始化时也会执行一次)
* 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10
* @param {Object} page
*/
upCallback(page) {
const app = this
// 设置列表数据
app.getGoodsList(page.num)
.then(list => {
const curPageLen = list.content ? list.content.length : 0;
const totalSize = list.totalElements;
app.mescroll.endBySize(curPageLen, totalSize);
})
.catch(() => app.mescroll.endErr())
},
// 设置默认列表显示方式
setShowView() {
this.showView = uni.getStorageSync(showViewKey) || true
},
// 点击跳转到首页
onTargetIndex() {
this.$navTo('pages/index/index');
},
/**
* 获取商品列表
* @param {number} pageNo 页码
*/
getGoodsList(pageNo = 1) {
const app = this
console.log(app.options)
const param = {
sortType: app.sortType,
sortPrice: Number(app.sortPrice),
cateId: app.options.categoryId || 0,
name: app.options.search || '',
page: pageNo
}
return new Promise((resolve, reject) => {
GoodsApi.search(param)
.then(result => {
// 合并新数据
const newList = result.data;
app.list.content = getMoreListData(newList, app.list, pageNo)
resolve(newList)
})
.catch(reject)
})
},
// 切换排序方式
handleSortType(newSortType) {
const app = this
const newSortPrice = newSortType === 'price' ? !app.sortPrice : true
app.sortType = newSortType
app.sortPrice = newSortPrice
// 刷新列表数据
app.list = getEmptyPaginateObj()
app.mescroll.resetUpScroll()
},
// 切换列表显示方式
handleShowView() {
const app = this
app.showView = !app.showView
uni.setStorageSync(showViewKey, app.showView)
},
// 跳转商品详情页
onTargetDetail(goodsId, type) {
this.$navTo(`pages/goods/detail`, { goodsId })
},
//商品搜索
handleSearch() {
const searchPageUrl = 'pages/search/index'
// 判断来源页面
let pages = getCurrentPages()
if (pages.length > 1 &&
pages[pages.length - 2].route === searchPageUrl) {
uni.navigateBack()
return
}
// 跳转到卡券搜索页
this.$navTo(searchPageUrl)
}
},
/**
* 设置分享内容
*/
onShareAppMessage() {
// 构建分享参数
return {
title: "全部分类",
path: "/pages/category/index?" + this.$getShareUrlParams()
}
},
/**
* 分享到朋友圈
* 本接口为 Beta 版本,暂只在 Android 平台支持,详见分享到朋友圈 (Beta)
* https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
*/
onShareTimeline() {
// 构建分享参数
return {
title: "全部分类",
path: "/pages/category/index?" + this.$getShareUrlParams()
}
}
}
</script>
<style lang="scss" scoped>
// 页面头部
.header {
display: block;
align-items: center;
background-color: #fff;
height: 103rpx;
// 搜索框
.search {
flex: 1;
}
// 切换显示方式
.show-view {
width: 60rpx;
height: 60rpx;
line-height: 60rpx;
font-size: 36rpx;
color: #505050;
}
}
// 空数据按钮
.empty-ipt {
width: 220rpx;
margin: 20rpx auto;
font-size: 28rpx;
height: 64rpx;
line-height: 64rpx;
text-align: center;
color: #fff;
border-radius: 5rpx;
background: linear-gradient(to right, $fuint-theme, $fuint-theme);
}
// 排序组件
.store-sort {
position: sticky;
top: var(--window-top);
display: flex;
padding: 20rpx 0;
font-size: 28rpx;
background: #fff;
color: #000;
z-index: 99;
.sort-item {
flex-basis: 33.3333%;
display: flex;
justify-content: center;
align-items: center;
height: 50rpx;
&.active {
color: #e49a3d;
}
}
.sort-item-price .price-arrow {
margin-left: 20rpx;
font-size: 24rpx;
color: #000;
.icon {
&.active {
color: #e49a3d;
}
&.up {
margin-bottom: -16rpx;
}
&.down {
margin-top: -16rpx;
}
}
}
}
// 商品列表
.goods-list {
padding: 4rpx;
box-sizing: border-box;
}
// 单列显示
.goods-list.column-1 {
.goods-item {
width: 100%;
height: 280rpx;
margin-bottom: 12rpx;
padding: 20rpx;
box-sizing: border-box;
background: #fff;
line-height: 1.6;
&:last-child {
margin-bottom: 0;
}
}
.goods-item_left {
display: flex;
width: 300rpx;
background: #fff;
align-items: center;
.image {
display: block;
width: 220rpx;
height: 200rpx;
border-radius: 10rpx;
}
}
.goods-item_right {
position: relative;
// width: 450rpx;
flex: 1;
.goods-name {
margin-top: 10rpx;
height: 64rpx;
line-height: 1.3;
white-space: normal;
color: #484848;
font-size: 26rpx;
}
}
.goods-item_desc {
margin-top: 8rpx;
.coupon-attr {
.attr-l {
float:left;
width: 60%;
}
.attr-r {
margin-top:20rpx;
float:left;
}
}
}
.desc-selling_point {
width: 400rpx;
font-size: 24rpx;
color: #e49a3d;
}
.receive {
color: #FFFFFF;
float: right;
margin-right: 20rpx;
border: solid 1rpx $fuint-theme;
background: $fuint-theme;
padding: 8rpx 20rpx 8rpx 20rpx;
border-radius: 5rpx;
display: block;
&.state {
border: none;
color: #cccccc;
background: #F5F5F5;
}
}
.desc-goods_sales {
color: #999;
font-size: 24rpx;
}
.desc_footer {
font-size: 24rpx;
.price_x {
margin-right: 16rpx;
color: #f03c3c;
font-size: 30rpx;
}
.price_y {
text-decoration: line-through;
}
}
}
// 平铺显示
.goods-list.column-2 {
.goods-item {
width: 50%;
}
}
.goods-item {
float: left;
box-sizing: border-box;
padding: 6rpx;
.goods-image {
position: relative;
width: 100%;
height: 0;
padding-bottom: 100%;
overflow: hidden;
background: #fff;
&:after {
content: '';
display: block;
margin-top: 100%;
}
.image {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
-o-object-fit: cover;
object-fit: cover;
}
}
.detail {
padding: 8rpx;
background: #fff;
.goods-name {
height: 64rpx;
line-height: 32rpx;
white-space: normal;
color: #484848;
font-size: 26rpx;
}
.detail-price {
.goods-price {
margin-right: 8rpx;
}
.line-price {
text-decoration: line-through;
}
}
}
}
</style>