【新增】普通商品详情新增显示代理商价格体系,只有登陆后的代理商才会显示。

This commit is contained in:
大灰灰
2022-11-12 23:52:35 +08:00
parent 38f702d960
commit ef30d77af2
5 changed files with 136 additions and 3 deletions

View File

@@ -124,6 +124,59 @@
</view>
</view>
<!--代理价格体系-->
<view class="coreshop-margin-left-8 coreshop-margin-right-8 coreshop-margin-top-12 coreshop-padding-8 coreshop-border-radius-9 coreshop-bg-white" v-if="userAgentGrade && userAgent">
<view class="coreshop-flex coreshop-flex-wrap coreshop-font-sm coreshop-flex-direction-row">
<view class="coreshop-basis-4">
<text class="coreshop-text-black coreshop-font-weight-bold coreshop-font-15">代理价格</text>
</view>
<view class="coreshop-basis-6">
<view class="coreshop-float-right">
您的等级{{userAgentGrade.name}}
</view>
</view>
</view>
<view v-if="agentProducts.length">
<view class="goods-agent-box">
<view class="goods-agent-line">
<view class="name coreshop-line-height-34">
<text>货品名称</text>
</view>
<view class="productPrice coreshop-line-height-34">
<text>销售价</text>
</view>
<view class="agentGradePrice coreshop-line-height-34">
<text>代理价</text>
</view>
<view class="profit coreshop-line-height-34">
<text>利润</text>
</view>
</view>
<view class="goods-agent-line" v-for="(item, index) in agentProducts" :key="index">
<view class="name coreshop-line-height-24 coreshop-padding-4">
<text>{{item.name}}</text>
</view>
<view class="productPrice coreshop-display-flex coreshop-align-center coreshop-justify-center">
<text>{{item.productPrice}}</text>
</view>
<view class="agentGradePrice coreshop-display-flex coreshop-align-center coreshop-justify-center">
<text>{{item.agentGradePrice}}</text>
</view>
<view class="profit coreshop-display-flex coreshop-align-center coreshop-justify-center">
<text>{{ parseFloat(item.productPrice-item.agentGradePrice).toFixed(2)}}</text>
</view>
</view>
</view>
<view class="coreshop-font-12 coreshop-line-height-34">
此利润不为最终用户下单后利润因为订单可能存在优惠
</view>
</view>
<view class="coreshop-margin-top-8" v-else>
<text class="coreshop-text-gray coreshop-font-12">该商品暂未录入商品池价格</text>
</view>
</view>
<!--评论-->
<view class="coreshop-margin-left-8 coreshop-margin-right-8 coreshop-margin-top-12 coreshop-padding-8 coreshop-border-radius-9 coreshop-bg-white">
<view class="coreshop-flex coreshop-flex-wrap coreshop-font-sm coreshop-flex-direction-row">
@@ -439,6 +492,9 @@
service: [],
},
autoplay: true,
userAgent: {},
userAgentGrade: {},
agentProducts: []
}
},
onLoad(options) {
@@ -662,7 +718,24 @@
_this.product = res.data.product;
_this.goodsInfo = info;
_this.goodsSkuInfo = res.data.skuList;
if (res.otherData.agentProducts) {
for (var i = 0; i < res.otherData.agentProducts.length; i++) {
for (var j = 0; j < res.data.skuList.sku_list.length; j++) {
if (res.data.skuList.sku_list[j]._id == res.otherData.agentProducts[i].productId) {
res.otherData.agentProducts[i].name = res.data.skuList.sku_list[j].sku_name_arr[0];
break;
}
}
}
console.log(res.otherData.agentProducts);
_this.agentProducts = res.otherData.agentProducts;
}
if (res.otherData.userAgentGrade) {
_this.userAgentGrade = res.otherData.userAgentGrade;
}
if (res.otherData.userAgent) {
_this.userAgent = res.otherData.userAgent;
}
//价格区间
if (res.data.minPrice != res.data.maxPrice) {

View File

@@ -359,6 +359,11 @@ view, text { box-sizing: border-box; }
.coreshop-min-height-#{$i} { min-height: $i + px; }
}
// 定义字体(px)单位
@for $i from 0 through 100 {
.coreshop-line-height-#{$i} { line-height: $i + px; }
}
// 定义flex等分
@for $i from 0 through 12 {
.coreshop-flex-#{$i} { flex: $i; }

View File

@@ -688,6 +688,18 @@ u-icon { line-height: 0; }
.goods-param-line .name { background: #f3f3f3; border-right: 0.5px solid #c3c3c3; color: #616161; font-size: 12px; height: 34px; line-height: 34px; text-align: center; width: 95px; }
.goods-param-line .value { color: #2f2f2f; font-size: 12px; padding-left: 12px; width: 215px; }
/*代理价格表格*/
.goods-agent-box { border: 0.5px solid #c3c3c3; border-radius: 0px; margin-top: 12rpx; }
.goods-agent-line { border-bottom: 0.5px solid #c3c3c3; display: flex;
.name { background: #f3f3f3; border-right: 0.5px solid #c3c3c3; color: #616161; font-size: 12px; text-align: center; width: 216px; }
.productPrice { color: #2f2f2f; border-right: 0.5px solid #c3c3c3; font-size: 12px; width: 50px; text-align: center; }
.agentGradePrice { color: #2f2f2f; border-right: 0.5px solid #c3c3c3; font-size: 12px; width: 50px; text-align: center; }
.profit { color: #2f2f2f; font-size: 12px; width: 50px; text-align: center; }
}
.goods-agent-line:last-child { border-bottom: 0; }
.line-70 { background: #c3c3c3; height: 1px; margin-top: 3px; width: 34.5px; }
/*购买按钮*/

View File

@@ -688,6 +688,18 @@ u-icon { line-height: 0; }
.goods-param-line .name { background: #f3f3f3; border-right: 0.5px solid #c3c3c3; color: #616161; font-size: 12px; height: 34px; line-height: 34px; text-align: center; width: 95px; }
.goods-param-line .value { color: #2f2f2f; font-size: 12px; padding-left: 12px; width: 215px; }
/*代理价格表格*/
.goods-agent-box { border: 0.5px solid #c3c3c3; border-radius: 0px; margin-top: 12rpx; }
.goods-agent-line { border-bottom: 0.5px solid #c3c3c3; display: flex;
.name { background: #f3f3f3; border-right: 0.5px solid #c3c3c3; color: #616161; font-size: 12px; text-align: center; width: 216px;}
.productPrice { color: #2f2f2f; border-right: 0.5px solid #c3c3c3; font-size: 12px; width: 50px; text-align: center; }
.agentGradePrice { color: #2f2f2f; border-right: 0.5px solid #c3c3c3; font-size: 12px; width: 50px; text-align: center; }
.profit { color: #2f2f2f; font-size: 12px; width: 50px; text-align: center; }
}
.goods-agent-line:last-child { border-bottom: 0; }
.line-70 { background: #c3c3c3; height: 1px; margin-top: 3px; width: 34.5px; }
/*购买按钮*/

View File

@@ -31,6 +31,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using SqlSugar;
namespace CoreCms.Net.Web.WebApi.Controllers
@@ -55,6 +56,9 @@ namespace CoreCms.Net.Web.WebApi.Controllers
private ICoreCmsGoodsParamsServices _goodsParamsServices;
private ICoreCmsGoodsCollectionServices _goodsCollectionServices;
private ICoreCmsUserServices _userServices;
private ICoreCmsAgentServices _agentServices;
private ICoreCmsAgentProductsServices _agentProductsServices;
private ICoreCmsAgentGradeServices _agentGradeServices;
/// <summary>
/// 构造函数
@@ -71,7 +75,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
, ICoreCmsGoodsParamsServices goodsParamsServices
, ICoreCmsGoodsCollectionServices goodsCollectionServices
, ICoreCmsUserServices userServices
)
, ICoreCmsAgentServices agentServices, ICoreCmsAgentProductsServices agentProductsServices, ICoreCmsAgentGradeServices agentGradeServices)
{
_mapper = mapper;
_user = user;
@@ -85,7 +89,9 @@ namespace CoreCms.Net.Web.WebApi.Controllers
_goodsParamsServices = goodsParamsServices;
_goodsCollectionServices = goodsCollectionServices;
_userServices = userServices;
_agentServices = agentServices;
_agentProductsServices = agentProductsServices;
_agentGradeServices = agentGradeServices;
}
//公共接口====================================================================================================
@@ -484,6 +490,14 @@ namespace CoreCms.Net.Web.WebApi.Controllers
{
userId = _user.ID;
}
var user = await _userServices.QueryByClauseAsync(p => p.id == _user.ID);
if (user == null)
{
jm.msg = "用户信息获取失败";
return jm;
}
var model = await _goodsServices.GetGoodsDetail(entity.id, userId, false, "goods", 0, entity.data.ObjectToBool());
if (model == null)
@@ -491,6 +505,23 @@ namespace CoreCms.Net.Web.WebApi.Controllers
jm.msg = "商品获取失败";
return jm;
}
var userAgent = await _agentServices.QueryByClauseAsync(p => p.userId == user.id);
var agentProducts = new List<CoreCmsAgentProducts>();
var userAgentGrade = new CoreCmsAgentGrade();
if (userAgent != null)
{
agentProducts = await _agentProductsServices.QueryListByClauseAsync(p => p.goodId == model.id && p.isDel == false && p.agentGradeId == userAgent.gradeId);
userAgentGrade = await _agentGradeServices.QueryByClauseAsync(p => p.id == userAgent.gradeId, true, true);
}
jm.otherData = new
{
userAgent,
userAgentGrade,
agentProducts
};
await _goodsServices.UpdateAsync(p => new CoreCmsGoods() { viewCount = p.viewCount + 1 },
p => p.id == entity.id);