Commit 2f598938 by zhangquan

测试按钮

1 parent 0723f461
<!-- 秒杀活动 -->
<template>
<div class="ctnr">
<div class="main">
<h2 class="title">商品详情</h2>
<div class="info">
<div class="pic-wrap">
<!-- <img :src="mainUrlInfo.imgUrl" alt=""> -->
<el-image v-if="goodsInfo.imageResponses && goodsInfo.imageResponses.length" class="mian-pic" :src="goodsInfo.imageResponses[curImgIdx].imgUrl" :preview-src-list="previewImgList">
</el-image>
<div v-if="goodsInfo.imageResponses && goodsInfo.imageResponses.length" class="other-pic">
<img v-for="(item,index) in goodsInfo.imageResponses" :key="index" :class="['pic-item',{'curActiveImg' : curImgIdx == index}]" :src="item.imgUrl" alt="" @click="curImgIdx=index">
</div>
</div>
<div class="info-wrap">
<p class="info-title">{{goodsInfo.brandName}} {{ goodsInfo.goodsSkuName }} {{ goodsInfo.goodsSkuTitle }}</p>
<p class="classify">分类:{{goodsInfo.firstCategoryName}}/{{goodsInfo.secondCategoryName}}/{{goodsInfo.lastCategoryName}}</p>
<div class="sale-price">
<div class="set-price">
<label for="">销售价</label>
<div v-if="!editing" class="edit">
<span class="price">¥{{ salePrice }}</span>
<img :src="require('@/assets/images/edit.png')" alt="" @click="editPrice">
</div>
<el-input v-else v-focus clearable v-model="salePrice" onkeyup="value = value ? value.replace(/^0\d/g, '0').replace(/[^\d.]/g, '').replace(/^\./g, '').replace(/\.{2,}/g, '').replace('.', '$#$')
.replace(/\./g, '').replace('$#$', '.').replace(/^(-)*(\d+)\.(\d\d).*$/, '$1$2.$3') : value" type="text" @blur="setPriceFn"></el-input>
</div>
<span class="buy-num">起购数量:{{goodsInfo.startQty}}件</span>
</div>
<ul class="attr-list">
<li v-for="item in attrList" :key="item.key">
<span class="attr-label">{{ item.label }}</span>
<span class="attr-key"><span v-if="item.key == 'sellPrice' || item.key == 'marketPrice'">¥</span>{{ goodsInfo[item.key] || '--' }}</span>
</li>
<li v-if=" goodsInfo.specificationResponses && goodsInfo.specificationResponses[0] && goodsInfo.specificationResponses[0].specName">
<span class="attr-label">{{ goodsInfo.specificationResponses[0].specName }}</span>
<span class="attr-key">{{ goodsInfo.specificationResponses[0].specValue || '--' }}</span>
</li>
</ul>
<div class="operate-btn">
<el-button type="primary" v-if="goodsInfo.goodsPosition==1" @click="handleSale">上架销售</el-button>
<el-button type="primary" v-if="goodsInfo.goodsPosition==2" plain @click="handleOff">下架至仓库</el-button>
<el-button type="primary" v-if="goodsInfo.goodsPosition==1" plain @click="handleRemove">移出仓库</el-button>
</div>
</div>
</div>
</div>
<div class="detail">
<div class="global-title-wrap">
<span :class="['title', {'curTitleCla': curTitle==1}]" @click="changeCurTitle(1)">图文介绍</span>
<span :class="['title', {'curTitleCla': curTitle==2}]" @click="changeCurTitle(2)">产品参数</span>
</div>
<div class="detail-table">
<div class="rich-text" v-if="curTitle==1" v-html="goodsInfo.goodsDescribe"></div>
<div class="grid" v-if="curTitle==2">
<template v-for="(item,index) in goodsInfo.attributeResponses">
<div class="gird-item" v-if="item.attributeName" :key="index">
<span class="label">{{item.attributeName}}</span>
<span class="value">{{item.attributeValueName || '--'}}</span>
</div>
</template>
<div v-if="!(goodsInfo.attributeResponses && goodsInfo.attributeResponses.length)">
暂无产品参数
</div>
</div>
</div>
</div>
</div>
</template>
<script>
const attrList = [
// {
// label:'商品特点',
// key: 'goodsCharacteristic'
// },
{
label:'供货价',
key: 'sellPrice'
},
{
label:'市场价',
key: 'marketPrice'
},
{
label:'库存',
key: 'goodsStock'
},
// {
// label:'品牌',
// key: 'gongPrice2'
// },
// {
// label:'颜色',
// key: 'gongPrice1'
// },
]
export default {
name: 'warehouseIndex',
data() {
return {
attrList,
salePrice: '',
curImgIdx: 0,
curTitle: 1,
goodsInfo: {},
editing: false
}
},
computed:{
previewImgList(){
return this.goodsInfo?.imageResponses.map(item => item.imgUrl) || []
}
},
components: {
},
created() {
this.getDetailById()
},
directives: {
// focus指令名称
focus: {
inserted(el) {
el.querySelector('input').focus()
},
},
},
mounted() {
},
methods: {
editPrice(){
this.editing = true
},
getDetailById(){
const { id } = this.$route.params
const loading = this.$loading({
lock: true,
text: 'Loading',
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.3)'
})
this.$apis.platformGoods.goodsDetailApi({id}).then(res =>{
loading.close()
if(res?.id){
this.goodsInfo = res
this.salePrice = res.salePrice
}
}).catch(err=>{
loading.close()
console.log(err)
})
},
setPriceFn(e){
if(!(+e.target.value)){
this.salePrice = this.goodsInfo.salePrice
this.$message.error('请输入大于0的金额')
return
}
let params = {
modifyPriceRequestList: [{
id: this.goodsInfo.id,
salePrice: e.target.value
}],
}
this.$apis.platformGoods.modifyPriceApi(params).then(res=>{
if(res){
this.$message.success('操作成功')
}
this.editing = false
this.getDetailById()
})
},
handleSale(){
this.operateFn('batchSaleApi', '上架销售')
},
handleOff(){
this.operateFn('batchOffApi', '下架至仓库')
},
handleRemove(){
this.operateFn('batchRemoveApi', '移出仓库')
},
operateFn(Api, operate){
let tip = `确定把该商品${operate}吗?`
this.$confirm(tip, '提示', {
type: 'warning',
callback: action => {
if(action=='confirm'){
this.$apis.platformGoods[Api]({ids: [this.goodsInfo.id]}).then(res=>{
if(res){
this.$message.success(`${operate}成功`)
if(Api=='batchRemoveApi') {
this.$router.push({ path: `/goodsWarehouse/warehouse`})
return
}
this.getDetailById()
}
})
}
}
})
},
changeCurTitle(type){
this.curTitle = type
}
}
}
</script>
<style scoped lang="scss">
.ctnr{
.main{
background-color: #fff;
.title{
height: 56px;
font-size: 16px;
color: #333;
font-weight: 600;
border-bottom: 1px solid #EEEDFF;
line-height: 56px;
padding: 0 20px;
}
.info{
display: flex;
padding: 20px;
.pic-wrap{
width: 362px;
flex-shrink: 0;
.mian-pic{
object-fit: contain;
width: 362px;
height: 362px;
}
.other-pic{
margin-top: 12px;
width: 362px;
padding-bottom: 5px;
overflow-x: auto;
display: flex;
flex-wrap: nowrap;
.pic-item{
width: 66px;
height: 66px;
margin-right: 8px;
&:last-child{
margin-right: 0;
}
}
.curActiveImg{
border: 1px solid #5850FF;
}
}
}
.info-wrap{
padding: 10px 0 10px 20px;
flex: 1;
.info-title{
line-height: 28px;
font-family: PingFangSC-Medium;
font-weight: 600;
font-size: 20px;
color: #333333;
}
.classify{
margin: 8px 0 20px;
height: 20px;
font-size: 14px;
color: #999999;
}
.sale-price{
width: 100%;
height: 64px;
line-height: 64px;
padding: 0 20px;
box-sizing: border-box;
background: #F4F6FC;
display: flex;
justify-content: space-between;
.set-price{
display: flex;
.edit{
display: flex;
align-items: center;
img{
width: 20px;
height: 20px;
vertical-align: middle;
margin-left: 16px;
cursor: pointer;
}
.price{
font-weight: 500;
font-size: 28px;
color: #EB4E4E;
}
}
label{
white-space: nowrap;
margin-right: 16px;
width: 56px;
flex-shrink: 0;
}
}
.buy-num{
font-weight: 400;
font-size: 14px;
color: #666666;
}
}
.attr-list{
list-style: none;
line-height: 20px;
font-size: 14px;
color: #666666;
padding: 20px;
li{
margin-bottom: 10px;
&:last-child{
margin: 0;
}
.attr-label{
font-weight: 400;
display: inline-block;
width: 70px;
margin-right: 16px;
}
.attr-key{
color: #333333;
}
}
}
.operate-btn{
margin-left: 20px;
.el-button {
width: 160px;
}
}
}
}
}
.detail{
background-color: #fff;
margin-top: 16px;
border-radius: 4px 0 0 0;
.detail-table{
padding: 20px;
/deep/ .rich-text{
img{
// width: 362px;
// height: 362px;
// object-fit: contain;
}
}
.grid{
display: grid;
grid-template-columns: 500px 500px;
.gird-item{
display: flex;
.label, .value{
display: inline-block;
border: 1px solid #E5E5E5;
height: 36px;
line-height: 36px;
font-size: 14px;
color: #333333;
padding: 0 12px;
margin-right:-1px;
margin-bottom:-1px;
}
.label{
width: 118px;
background: #F4F6FC;
}
.value{
width: 100%;
}
}
}
}
}
}
</style>
\ No newline at end of file
......@@ -330,7 +330,7 @@ export default {
})
},
goDetaillPage(item){
this.$router.push({ path: `/goodsWarehouse/detail/${item.id}`})
this.$router.push({ path: `/goodsWarehouse/wDetail/${item.id}`})
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!