This commit is contained in:
2026-01-05 12:47:14 +08:00
commit 1fc846fae3
1614 changed files with 162035 additions and 0 deletions

579
pages/mall/houseDetail.vue Normal file
View File

@@ -0,0 +1,579 @@
<template>
<view class="content">
<nut-watermark v-if="detail.shelves_status?.value === 10" class="mark1" :z-index="1"
content="此商品已下架"></nut-watermark>
<nut-watermark v-if="detail.shelves_status?.value === 30" class="mark1" :z-index="1"
content="此商品已售出"></nut-watermark>
<nut-watermark v-if="detail.is_locked" class="mark1" :z-index="1" content="此商品被锁单"></nut-watermark>
<swiper class="swiper" circular indicator-dots autoplay>
<swiper-item @click="showGoodsImages(idx)" v-for="(item,idx) in detail.image" :key="idx">
<image :src="item.file_path" mode="aspectFill"></image>
</swiper-item>
</swiper>
<view class='goods_info'>
<nut-cell-group>
<view class="price">
<text class="unit"></text>
<text class="value">{{getPrice(detail)}}</text>
</view>
</nut-cell-group>
<nut-cell-group>
<view class="name">
<view class="top">
<view class="tag">
<text>{{detail.degree?.degree_name}}</text>
</view>
<text class="title">{{detail.goods_name}}</text>
</view>
<view>
<text class="info">{{detail.content}}</text>
</view>
</view>
</nut-cell-group>
<view class="service">
<view class="info">
<text class="title">服务</text>
<text class="value">{{detail.service_txt}}</text>
</view>
</view>
<nut-cell-group title="验机报告">
<nut-collapse v-model="activeNames" @change="onChange">
<nut-collapse-item :name="1" icon="rect-down">
<template v-slot:title>
瑕疵项
</template>
<template v-slot:value>
<view class="count-item">
<nut-icon name="tips" size="12"
custom-color='#ff3535'></nut-icon><text>{{detail.report_tags?.bad_count}}</text>
</view>
</template>
<view class="report-inner">
<view class="report-item" v-for="(item,idx) in detail?.report_tags?.bad" :key="idx">
<view class="report-item-name">{{item.name}}</view>
<view class="report-item-content">
<view class="report-item-content-item" v-for="(iitem,iidx) in item.value_list"
:key="iidx">
<nut-icon name="tips" size="12" custom-color="#ff3535"></nut-icon>
<text>{{iitem.name}}</text>
</view>
</view>
</view>
</view>
</nut-collapse-item>
<nut-collapse-item :name="2" icon="rect-down">
<template v-slot:title>
正常项
</template>
<template v-slot:value>
<view class="count-item">
<nut-icon name="success" size="12" custom-color="#5dcc30"></nut-icon>
<text>{{detail.report_tags?.ok_count}}</text>
</view>
</template>
<view class="report-inner">
<view class="report-item" v-for="(item,idx) in detail?.report_tags?.ok" :key="idx">
<view class="report-item-name">{{item.name}}</view>
<view class="report-item-content">
<view class="report-item-content-item" v-for="(iitem,iidx) in item.value_list"
:key="iidx">
<nut-icon name="success" size="12" custom-color="#5dcc30"></nut-icon>
<text>{{iitem.name}}</text>
</view>
</view>
</view>
</view>
</nut-collapse-item>
</nut-collapse>
</nut-cell-group>
</view>
<view class="bottom-action">
<view class="bottom-action-icon">
<button plain open-type="contact" style="border:none;border-width: 0;" class="bottom-action-icon-item">
<nut-icon name='service'></nut-icon>
<text>客服</text>
</button>
</view>
<!-- detail.goods_status?.value === 10 && -->
<view class="bottom-action-btn"
v-if="detail.shelves_status?.value === 20 && !goods_cart_ids.includes(detail.goods_id) ">
<!-- @click="navigateTo('/pages/order/housePreview?ids=' + detail.goods_id+'&from=item')" -->
<nut-button type="primary" v-if="!audit" @click="buyNow(detail.goods_id)">立即购买</nut-button>
</view>
<!-- detail.goods_status?.value === 10 && -->
<!-- <view class="bottom-action-btn"
v-else-if="detail.shelves_status?.value === 20 && goods_cart_ids.includes(detail.goods_id) && user_goods_cart_ids.includes(detail.goods_id)">
<nut-button plain>已在购物车</nut-button>
</view> -->
<view class="bottom-action-btn" v-else>
<nut-button plain v-if="!audit">已锁定</nut-button>
</view>
</view>
</view>
</template>
<script setup>
import {
reactive,
ref
} from 'vue';
import {
navigateTo,
switchTab,
goToLoginPage
} from '@/utils/helper';
import {
onShareAppMessage,
onShareTimeline,
onLoad
} from '@dcloudio/uni-app'
import {
houseFetchCartGoodsIds,
houseFetchGoodsDetail
} from '@/api/house_goods';
import {
// fetchOrderbuyNow,
houseFetchCheckGoods
} from '@/api/house_order';
import {
fetchGetConfig,
fetchGetPriceRules,
} from '@/api/config';
// 审核模式
const audit = ref(true);
// 是否开启整仓调价
const isWarehouse = ref(false)
// 单个商品规则列表
const singleRule = ref([])
// 价格区间规则列表
const rangeRule = ref([])
// 整仓规则
const warehouseRule = reactive({
val: 0,
val_type: 1,
})
// 获取全部调价规则
const GetPriceRules = () => {
fetchGetPriceRules().then(res => {
console.log('res', res);
// 区间调价
rangeRule.value = res?.range ?? [];
// 单机调价
singleRule.value = res?.single ?? [];
// 整仓调价
Object.assign(warehouseRule, res?.warehouse?.[0] ?? {
val: 0,
val_type: 1,
})
})
}
// 获取价格
const getPrice = (goods) => {
// 判断是否开启整仓调价
if (isWarehouse.value) {
console.log("开启整仓调价");
// 查找单机器加价规则
const list = singleRule.value || singleRule; // 兼容 ref 和 reactive
// 根据 product_id == goods_id 找对应规则
const rule = list.find(item => item.product_id === goods.goods_id);
if (rule) {
// 存在单机加价规则
const basePrice = Number(goods.goods_price);
const val = Number(rule.val);
let finalPrice = basePrice;
// val_type 处理
if (rule.val_type == 1) {
finalPrice = basePrice + val; // 固定加价
} else if (rule.val_type == 2) {
finalPrice = basePrice + (basePrice * val / 100); // 按百分比加
}
return finalPrice.toFixed(2); // 保留两位小数
} else {
// 不存在则使用整仓加价
const basePrice = Number(goods.goods_price);
const val = Number(warehouseRule.val);
let finalPrice = basePrice;
// val_type 处理
if (warehouseRule.val_type == 1) {
finalPrice = basePrice + val; // 固定加价
} else if (warehouseRule.val_type == 2) {
finalPrice = basePrice + (basePrice * val / 100); // 按百分比加
}
return finalPrice.toFixed(2); // 保留两位小数
}
} else {
console.log("未开启整仓调价");
// 查找单机器加价规则
const singleRuleList = singleRule.value || singleRule; // 兼容 ref 和 reactive
// 根据 product_id == goods_id 找对应规则
const oneRule = singleRuleList.find(item => item.product_id === goods.goods_id);
if (oneRule) {
// 存在单机加价规则
const basePrice = Number(goods.goods_price);
const val = Number(oneRule.val);
let finalPrice = basePrice;
// val_type 处理
if (oneRule.val_type == 1) {
finalPrice = basePrice + val; // 固定加价
} else if (oneRule.val_type == 2) {
finalPrice = basePrice + (basePrice * val / 100); // 按百分比加
}
return finalPrice.toFixed(2); // 保留两位小数
} else {
// 不存在则使用区间加价
const basePrice = Number(goods.goods_price)
// // 查找区间加价规则
const rangeRulelist = rangeRule.value || rangeRule; // 兼容 ref 和 reactive
const quRule = rangeRulelist.find(item => {
const min = Number(item.min_price)
const max = Number(item.max_price)
return basePrice >= min && basePrice < max
}) || null
if (quRule) {
// 存在区间加价
const val = Number(quRule.val);
let finalPrice = basePrice;
// val_type 处理
if (quRule.val_type == 1) {
finalPrice = basePrice + val; // 固定加价
} else if (quRule.val_type == 2) {
finalPrice = basePrice + (basePrice * val / 100); // 按百分比加
}
return finalPrice.toFixed(2); // 保留两位小数
} else {
// 不存在区间加价
return basePrice
}
}
}
}
const id = ref(0)
const detail = reactive({})
// 用户购物车商品列表
const user_goods_cart_ids = ref([]);
// 全部购物车商品列表
const goods_cart_ids = ref([]);
// 立即购买
const buyNow = (goodsId) => {
let token = uni.getStorageSync('token')
if (token) {
// 检测是否可以购买
houseFetchCheckGoods({
goods_id: goodsId,
}).then(res => {
console.log(res);
console.log("已经登陆");
uni.navigateTo({
url: `/pages/order/housePreview?ids=${goodsId}&from=item`
})
});
} else {
goToLoginPage(); // 未登陆
}
}
// 获取配置
const getConfig = () => {
fetchGetConfig().then(res => {
console.log('getConfig=====>', res)
audit.value = res.appConfig.is_audit == 1
isWarehouse.value = res.appConfig.is_warehouse == 1
})
}
onLoad(options => {
console.log('init');
// 获取配置
getConfig()
GetPriceRules()
// 获取商品详情
id.value = options.id
houseFetchGoodsDetail(id.value).then(res => {
Object.assign(detail, res)
})
// 获取购买记录
houseFetchCartGoodsIds().then(res => {
console.log(res);
user_goods_cart_ids.value = res.user_cart_goods_ids;
goods_cart_ids.value = res.cart_goods_ids;
})
})
// 分享给朋友圈
onShareTimeline((res) => {
return {
title: detail.goods_name,
path: '/pages/mall/houseDetail?id=' + detail.goods_id,
imageUrl: detail.image[0].file_path
};
})
// 分享
onShareAppMessage((res) => {
return {
title: detail.goods_name,
path: '/pages/mall/houseDetail?id=' + detail.goods_id,
imageUrl: detail.image[0].file_path
}
})
const activeNames = ref([1, 2]);
const onChange = (modelValue, currName, status) => {
// currName: 当前操作的 collapse-item 的 name
// status: true 打开 false 关闭
console.log(modelValue, currName, status);
}
// 显示图片
const showGoodsImages = (index) => {
uni.previewImage({
current: index, // 指定当前显示的图片索引
urls: detail.image.map(e => {
return e.file_path
}),
});
}
</script>
<style scoped lang="scss">
.bottom-action {
position: fixed;
bottom: 0;
left: 0;
height: 50px;
background: #fff;
width: calc(100% - 20px);
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 auto;
padding: 5px 10px;
.bottom-action-icon {
align-items: center;
display: flex;
justify-content: center;
.bottom-action-icon-item {
align-items: center;
display: flex;
flex-direction: column;
justify-content: center;
text {
color: rgba(0, 0, 0, .5);
font-size: 11px;
}
}
}
.bottom-action-btn {
-ms-flex-align: center;
-ms-flex-pack: end;
-webkit-align-items: center;
align-items: center;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
gap: 5px;
-webkit-justify-content: flex-end;
justify-content: flex-end;
}
}
.content {
display: flex;
flex-direction: column;
/* align-items: center; */
// justify-content: center;
background-color: #f2f3f5;
height: calc(100% - 50px);
--nut-cell-group-title-color: #000;
--nut-collapse-item-padding: 10px 10px 10px 10px;
--nut-collapse-wrapper-content-padding: 10px 10px 10px 10px;
--nut-collapse-item-color: #000;
padding-bottom: 50px;
}
.report-inner {
display: flex;
flex-direction: column;
gap: 5px;
.report-item {
.report-item-name {
color: rgba(0, 0, 0, .9);
font-weight: 700;
}
.report-item-content {
display: flex;
flex-wrap: wrap;
.report-item-content-item {
padding-top: 2px;
padding-bottom: 2px;
width: 50%;
display: flex;
align-items: center;
}
}
}
}
.count-item {
display: flex;
justify-content: center;
align-items: center;
gap: 2px;
}
.swiper {
width: 100%;
height: 414px;
image {
width: 100%;
height: 100%;
}
}
.goods_info {
padding: 5px;
color: #000;
.price {
border-radius: 5px;
padding: 10px;
background: #fff;
.unit {
font-size: 12px;
}
.value {
font-size: 24px;
}
}
.name {
border-radius: 5px;
padding: 10px;
background: #fff;
display: flex;
gap: 5px;
flex-direction: column;
.top {
display: flex;
gap: 5px;
.tag {
background: #000;
padding: 1px 2px;
justify-content: center;
align-items: center;
display: flex;
border-radius: 2px;
text {
font-size: 10px;
color: #fff;
}
}
.title {
font-size: 16px;
}
}
.info {
color: rgba(0, 0, 0, .7);
font-size: 13px;
}
}
.service {
border-radius: 5px;
padding: 10px;
background: #fff;
display: flex;
align-items: center;
justify-content: space-between;
.info {
display: flex;
flex-direction: column;
justify-content: center;
gap: 5px;
.title {
font-size: 16px;
}
.value {
color: rgba(0, 0, 0, .7);
font-size: 13px;
}
}
.right_icon {
background-color: currentColor;
mask: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPjxwYXRoIGZpbGw9IiMxQTFBMUEiIGQ9Ik0zNTMuODMgMTU4LjE3YTQyLjY3IDQyLjY3IDAgMSAxIDYwLjM0LTYwLjM0bDM4NCAzODRhNDIuNjcgNDIuNjcgMCAwIDEgMCA2MC4zNmwtMzg0IDM4NGE0Mi42NyA0Mi42NyAwIDEgMS02MC4zNC02MC4zNkw3MDcuNjcgNTEyeiIvPjwvc3ZnPg==') 0 0/100% 100% no-repeat;
width: 12px;
height: 12px;
}
}
.report {
border-radius: 5px;
padding: 1px;
background: #fff;
}
}
</style>