【新增】商品详情新增sku价格区间展示,如【¥100~395】,选中单个sku后自动变更其具体价格

This commit is contained in:
大灰灰
2022-05-11 21:06:00 +08:00
parent fb60a05e02
commit 93efdd425b
4 changed files with 43 additions and 6 deletions

View File

@@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using CoreCms.Net.Model.FromBody;
using SqlSugar;
namespace CoreCms.Net.Model.Entities
@@ -108,6 +109,11 @@ namespace CoreCms.Net.Model.Entities
[SugarColumn(IsIgnore = true)]
public List<CoreCmsProducts> sku { get; set; } = new();
/// <summary>
/// 商品规格
/// </summary>
[SugarColumn(IsIgnore = true)]
public Dictionary<string, Dictionary<string, DefaultSpesDesc>> specification { get; set; } = new();
/// <summary>
/// 是否收藏
@@ -176,5 +182,19 @@ namespace CoreCms.Net.Model.Entities
[SugarColumn(IsIgnore = true)] public DateTime groupEndTime { get; set; }
[SugarColumn(IsIgnore = true)] public int groupTimestamp { get; set; }
/// <summary>
/// sku最小价格
/// </summary>
[SugarColumn(IsIgnore = true)]
public decimal minPrice { get; set; } = 0;
/// <summary>
/// sku最大价格
/// </summary>
[SugarColumn(IsIgnore = true)]
public decimal maxPrice { get; set; } = 0;
}
}

View File

@@ -538,6 +538,15 @@ namespace CoreCms.Net.Services
model.freezeStock = getProductInfo.freezeStock;
model.weight = getProductInfo.weight;
var minProduct = await _productsServices.QueryByClauseAsync(p => p.isDel == false && p.goodsId == id,
p => p.price, OrderByType.Asc);
var maxProduct = await _productsServices.QueryByClauseAsync(p => p.isDel == false && p.goodsId == id,
p => p.price, OrderByType.Desc);
model.minPrice = minProduct.price;
model.maxPrice = maxProduct.price;
//获取品牌
var brand = await _brandServices.QueryByIdAsync(model.brandId);
model.brand = brand;

View File

@@ -1,6 +1,5 @@
<template>
<view class="coreshop-padding-bottom-10">
<view>dsdsads</view>
<view class="select-item" v-for="(item, index) in specList" :key="index">
<view class="coreshop-text-black coreshop-margin-10 coreshop-solid-bottom coreshop-padding-bottom-10">{{ index }}</view>
<view class="select-btn">
@@ -30,8 +29,6 @@
// #ifdef H5 || APP-PLUS
this.specList = JSON.parse(this.spesData);
// #endif
console.log(this.spesData);
console.log(this.specList);
},
watch: {
spesData: function (val) {

View File

@@ -13,9 +13,10 @@
<!--幻灯片-->
<u-swiper height="calc(750rpx * 6 / 6)" radius="0" :list="goodsInfo.album" :autoplay="autoplay" indicator indicatorMode="line" circular @click="clickImg"></u-swiper>
<!--限时秒杀-->
<view class="coreshop-limited-seckill-box coreshop-bg-red">
<text class="coreshop-text-price coreshop-font-20">{{ product.price || '0.00' }}</text>
<view class="coreshop-font-xs coreshop-cost-price-num price-4">
<view class="coreshop-limited-seckill-box coreshop-bg-red coreshop-flex coreshop-justify-start">
<!--<text class="coreshop-text-price coreshop-font-20">{{ product.price || '0.00' }}</text>-->
<text class="coreshop-text-price coreshop-font-20">{{ priceSection }}</text>
<view class="coreshop-font-xs price-4 coreshop-margin-left-20">
<view v-if="pointSwitch==1 && pointExchangeModel==2 && pointShowExchangePrice==1 && product.pointsDeduction > 0">
<view class="coreshop-padding-bottom-5 coreshop-font-14">
兑换价{{pointDiscountedProportion * product.pointsDeduction }}{{ pointShowName}}+{{ product.price - product.pointsDeduction}}
@@ -426,6 +427,7 @@
goodsInfo: {}, // 商品详情
cartNums: 0, // 购物车数量
product: {}, // 货品详情
priceSection:'',
shopRecommendData: [], // 本店推荐数据
otherRecommendData: [], // 其他数据
goodsParams: [], // 商品参数信息
@@ -607,6 +609,13 @@
let products = res.data.product;
_this.goodsInfo = info;
//价格区间
if (res.data.minPrice != res.data.maxPrice) {
this.priceSection = res.data.minPrice + '~' + res.data.maxPrice;
} else {
this.priceSection = products.price;
}
if (_this.goodsInfo.album) {
var albums = [];
for (var i = 0; i < _this.goodsInfo.album.length; i++) {
@@ -745,6 +754,8 @@
// 切换规格判断可购买数量
this.buyNum = res.data.stock >= this.minBuyNum ? this.minBuyNum : res.data.stock;
this.product = this.spesClassHandle(res.data);
this.priceSection = this.product.price;
}
});
uni.showLoading({