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>