1271 lines
33 KiB
Vue
1271 lines
33 KiB
Vue
<template>
|
||
<view class="content">
|
||
<backIcon></backIcon>
|
||
<!-- 轮播图 -->
|
||
<u-swiper
|
||
:list="bannerImgList"
|
||
:height="isWidth"
|
||
circular
|
||
:autoplay="false"
|
||
indicator
|
||
indicatorMode="dot"
|
||
></u-swiper>
|
||
<view class="contxt">
|
||
<view v-if="goodDetail.preSaleStatus == 1">
|
||
<view class="sTop">
|
||
<view class="sTop_l">
|
||
<view class="f1">
|
||
{{ goodDetail.goodsPrice | toThousandthAndKeepDecimal }}
|
||
</view>
|
||
<view class="disFlex1">
|
||
<img src="@/static/images/clock.png" alt="" />
|
||
<view class="f2">{{ '预计发货' }}</view>
|
||
</view>
|
||
</view>
|
||
<view class="sTop_l">
|
||
<view class="f2" v-if="specialArea != 18 && specialArea != 13"
|
||
>业绩:{{ goodDetail.goodsAchive | toThousandthAndKeepDecimal }}
|
||
</view>
|
||
<view class="f3">
|
||
<view>{{ '剩余时间' }}:{{ countDown }}</view>
|
||
<!-- <view></view> -->
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="kuang1">
|
||
<!-- <view class="disFlex" v-show="specialArea == 31">
|
||
<view class="t_hui">统一零售价:{{ goodDetail.retailPrice | numberToCurrency | isLocal }}</view>
|
||
</view> -->
|
||
<view class="disFlex">
|
||
<view class="t_hui">销量:{{ goodDetail.sales | seles }}</view>
|
||
</view>
|
||
<view class="disFlex">
|
||
<view class="bao" v-if="goodDetail.prefixLabelTarget"
|
||
>[{{ goodDetail.prefixLabelTarget.label }}]
|
||
</view>
|
||
<view class="t_hei">{{ goodDetail.waresName }}</view>
|
||
</view>
|
||
|
||
<!-- 库存进度条 - 预售状态 -->
|
||
<view
|
||
class="inventory-progress-container"
|
||
v-if="goodDetail.useRatio && goodDetail.inventory !== undefined"
|
||
>
|
||
<view class="inventory-header">
|
||
<view class="inventory-label">
|
||
<text class="inventory-status">库存剩余</text>
|
||
</view>
|
||
<view
|
||
class="inventory-percentage"
|
||
:class="getPercentageClass(goodDetail.inventory)"
|
||
>
|
||
{{ getInventoryPercentage(goodDetail.inventory) }}%
|
||
</view>
|
||
</view>
|
||
<view class="inventory-progress-bar">
|
||
<view
|
||
class="inventory-progress-fill"
|
||
:style="{
|
||
width: getInventoryPercentage(goodDetail.inventory) + '%',
|
||
}"
|
||
:class="getProgressClass(goodDetail.inventory)"
|
||
>
|
||
<!-- 添加流动光效 -->
|
||
<view
|
||
class="progress-shine"
|
||
v-if="getInventoryPercentage(goodDetail.inventory) <= 30"
|
||
></view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="kuang" v-else>
|
||
<view class="disFlex">
|
||
<view class="t_red">{{
|
||
goodDetail.goodsPrice | numberToCurrency | isLocal
|
||
}}</view>
|
||
<view
|
||
class="t_hui"
|
||
v-if="
|
||
specialArea != 18 &&
|
||
specialArea != 13 &&
|
||
specialArea != 31 &&
|
||
specialArea != 10
|
||
"
|
||
>业绩:{{ goodDetail.goodsAchive | numberToCurrency }}</view
|
||
>
|
||
<view class="t_hui" v-if="specialArea == 10"
|
||
>积分可抵扣:{{ goodDetail.deductMoney | numberToCurrency }}</view
|
||
>
|
||
<view
|
||
class="t_hui"
|
||
v-if="goodDetail.specialArea == 31 && user.isMakerSpace == 0"
|
||
>业绩:{{ goodDetail.goodsAchive | numberToCurrency }}</view
|
||
>
|
||
<view class="t_hui" v-if="specialArea == 13"
|
||
>BV:{{ goodDetail.goodsAssAchive | numberToCurrency }}</view
|
||
>
|
||
</view>
|
||
<view v-if="!goodDetail.useRatio" class="t_hui1"
|
||
>销量:{{ goodDetail.sales | seles }}</view
|
||
>
|
||
<!-- <view class="disFlex" v-show="specialArea == 31">
|
||
<view class="t_hui1">统一零售价:{{ goodDetail.retailPrice | numberToCurrency | isLocal }}</view>
|
||
</view> -->
|
||
<view class="disFlex">
|
||
<view class="bao" v-if="goodDetail.prefixLabelTarget"
|
||
>[{{ goodDetail.prefixLabelTarget.label }}]
|
||
</view>
|
||
<view class="t_hei">{{ goodDetail.waresName }}</view>
|
||
</view>
|
||
|
||
<!-- 库存进度条 -->
|
||
<view
|
||
class="inventory-progress-container"
|
||
v-if="goodDetail.useRatio && goodDetail.inventory !== undefined"
|
||
>
|
||
<view class="inventory-header">
|
||
<view class="inventory-label">
|
||
<text class="inventory-status">库存剩余</text>
|
||
</view>
|
||
<view
|
||
class="inventory-percentage"
|
||
:class="getPercentageClass(goodDetail.inventory)"
|
||
>
|
||
{{ getInventoryPercentage(goodDetail.inventory) }}%
|
||
</view>
|
||
</view>
|
||
<view class="inventory-progress-bar">
|
||
<view
|
||
class="inventory-progress-fill"
|
||
:style="{
|
||
width: getInventoryPercentage(goodDetail.inventory) + '%',
|
||
}"
|
||
:class="getProgressClass(goodDetail.inventory)"
|
||
>
|
||
<!-- 添加流动光效 -->
|
||
<view
|
||
class="progress-shine"
|
||
v-if="getInventoryPercentage(goodDetail.inventory) <= 30"
|
||
></view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="kuang t_hei">
|
||
{{ '急速下单即享优先发货' }}
|
||
</view>
|
||
<view class="kuang">
|
||
<view class="heng" @tap="selSku = true">
|
||
<view class="disFlex">
|
||
<view class="label">{{ '规格' }}</view>
|
||
<view class="label1">{{ '已选' }}: {{ skuString }}</view>
|
||
</view>
|
||
<u-icon name="arrow-right"></u-icon>
|
||
</view>
|
||
<view class="heng">
|
||
<view class="disFlex">
|
||
<view class="label">{{ '服务承诺' }}</view>
|
||
<view
|
||
class="label1"
|
||
v-for="item in goodDetail.ensureLabelList"
|
||
:key="item.pkId"
|
||
>{{ item.label }}</view
|
||
>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="bTit">
|
||
<view>{{ '商品详情' }}</view>
|
||
<view class="btm"></view>
|
||
</view>
|
||
<u-parse :content="goodDetail.details"></u-parse>
|
||
</view>
|
||
|
||
<!-- 占空 -->
|
||
<view style="height: 150rpx"></view>
|
||
<!-- 底部 -->
|
||
<view class="footer_f">
|
||
<view class="footer">
|
||
<view class="footer_l">
|
||
<view class="footer_li footer_ll" @click="toIndex">
|
||
<u-icon size="18" name="home"></u-icon>
|
||
<view>{{ '首页' }}</view>
|
||
</view>
|
||
|
||
<view
|
||
class="footer_li footer_ll"
|
||
@click="toCart"
|
||
v-if="
|
||
(specialArea == 31 && user.isMakerSpace == 0) || specialArea != 31
|
||
"
|
||
>
|
||
<u-icon size="20" name="shopping-cart"></u-icon>
|
||
<view class="qiu">{{ shopCarLength }}</view>
|
||
<view>{{ '购物车' }}</view>
|
||
</view>
|
||
</view>
|
||
<view
|
||
class="footer_r"
|
||
v-if="
|
||
(specialArea == 31 && user.isMakerSpace == 0) || specialArea != 31
|
||
"
|
||
>
|
||
<!-- <u-button type="success"
|
||
class="uBtn"
|
||
@tap="goBuy"
|
||
shape="circle"
|
||
color="linear-gradient(to right, #005BAC, #005BAC )">{{'立即购买'}} </u-button> -->
|
||
<view class="btn1" @click="addCar()">加入购物车</view>
|
||
<!-- <view class="btn2">{{'立即购买'}}</view> -->
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<!-- 选择规格 -->
|
||
<u-popup :show="selSku" mode="bottom" closeable @close="close">
|
||
<view class="pop_a">
|
||
<view class="pop_tt">
|
||
<view class="pop_t">
|
||
<img :src="imgUrlList[0]" alt="" />
|
||
<view>{{
|
||
goodDetail.goodsPrice | numberToCurrency | isLocal
|
||
}}</view>
|
||
</view>
|
||
</view>
|
||
<view class="zhan"></view>
|
||
<view class="pop">
|
||
<view
|
||
v-for="(item, index) in goodDetail.productParams"
|
||
:key="item.productId"
|
||
class="pop_c"
|
||
>
|
||
<view class="ggTit"
|
||
>{{ item.productName }}*{{ item.quantity }}</view
|
||
>
|
||
<view
|
||
v-for="(ctem, cndex) in item.waresItemsParamsList"
|
||
:key="ctem.pkSkuId"
|
||
class="pop_ci"
|
||
>
|
||
<view class="pop_cl">
|
||
<img :src="ctem.specCover" alt="" />
|
||
<view class="gui_iit">{{ ctem.specsNameDian }}</view>
|
||
</view>
|
||
<u-number-box
|
||
:min="0"
|
||
:max="ctem.maxNum"
|
||
@change="getNum(index, cndex, $event)"
|
||
v-model="ctem.quantity"
|
||
>
|
||
<view
|
||
slot="minus"
|
||
:class="ctem.quantity == 0 ? 'hui' : 'minus'"
|
||
>
|
||
<u-icon name="minus" color="#FFFFFF" size="12"></u-icon>
|
||
</view>
|
||
<text slot="input" class="input">{{ ctem.quantity }}</text>
|
||
<view slot="plus" :class="ctem.quantity == 0 ? 'hui' : 'plus'">
|
||
<u-icon name="plus" color="#FFFFFF" size="12"></u-icon>
|
||
</view>
|
||
</u-number-box>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="zhan1"></view>
|
||
<view class="pop_b">
|
||
<view class="pop_bb">
|
||
<u-button
|
||
type="success"
|
||
class="uBtn"
|
||
shape="circle"
|
||
color="linear-gradient(to right, #005BAC, #005BAC )"
|
||
@click="close"
|
||
>确认</u-button
|
||
>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</u-popup>
|
||
<selSpaceGoods ref="selSpaceGoods" @getCar="getCatLength"></selSpaceGoods>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import backIcon from '@/components/backIcon.vue'
|
||
import * as api from '@/config/goods'
|
||
import { mapGetters } from 'vuex'
|
||
import selSpaceGoods from '@/components/selSpaceGoods.vue'
|
||
export default {
|
||
components: {
|
||
backIcon,
|
||
selSpaceGoods,
|
||
},
|
||
filters: {
|
||
seles(value) {
|
||
if (value > 999) {
|
||
return 999 + '+'
|
||
} else {
|
||
return value
|
||
}
|
||
},
|
||
},
|
||
data() {
|
||
return {
|
||
waresCode: '',
|
||
specialArea: '',
|
||
goodDetail: '',
|
||
imgUrlList: [],
|
||
selSku: false,
|
||
skuString: '',
|
||
num: 1,
|
||
isWidth: 375,
|
||
pkCountry: 1,
|
||
countDown: '',
|
||
bannerImgList: [],
|
||
}
|
||
},
|
||
|
||
onLoad(options) {
|
||
this.pkCountry = uni.getStorageSync('pkCountry')
|
||
this.waresCode = options.waresCode
|
||
this.specialArea = options.specialArea
|
||
this.getDetails()
|
||
uni.getSystemInfo({
|
||
success: function (res) {
|
||
this.isWidth = res.screenWidth
|
||
},
|
||
})
|
||
},
|
||
computed: {
|
||
...mapGetters(['user', 'shopCarLength']),
|
||
// bannerImgList() {
|
||
// const list = this.imgUrlList.map(item => item)
|
||
// list.splice(1,1)
|
||
// return list
|
||
// }
|
||
},
|
||
methods: {
|
||
toIndex() {
|
||
uni.switchTab({ url: '/pages/index/index' })
|
||
},
|
||
toCart() {
|
||
uni.switchTab({ url: '/pages/shoppingCar/index' })
|
||
},
|
||
addCar() {
|
||
let sum = 0
|
||
let selSum = 0
|
||
this.goodDetail.productParams.forEach(item => {
|
||
sum += item.quantity
|
||
item.waresItemsParamsList.forEach(ctem => {
|
||
selSum += ctem.quantity
|
||
})
|
||
})
|
||
if (selSum != sum) {
|
||
uni.showToast({
|
||
title: '请添加产品',
|
||
icon: 'none',
|
||
mask: true,
|
||
})
|
||
return false
|
||
}
|
||
let carList = {
|
||
specialArea: this.goodDetail.specialArea,
|
||
number: this.num,
|
||
waresCode: this.goodDetail.waresCode,
|
||
productGroup: [],
|
||
pkCountry: this.pkCountry,
|
||
}
|
||
this.goodDetail.productParams.forEach(item => {
|
||
item.waresItemsParamsList.forEach(ctem => {
|
||
if (ctem.quantity != 0) {
|
||
carList.productGroup.push({
|
||
pkProduct: ctem.pkProduct,
|
||
pkSkuId: ctem.pkSkuId,
|
||
quantity: ctem.quantity,
|
||
})
|
||
}
|
||
})
|
||
})
|
||
if (this.goodDetail.isMakerGift == 2) {
|
||
this.$refs.selSpaceGoods.getData(carList)
|
||
} else {
|
||
api.addShopping(carList).then(res => {
|
||
if (res.code == 200) {
|
||
uni.showToast({
|
||
title: '购物车添加成功',
|
||
icon: 'success',
|
||
mask: true,
|
||
})
|
||
this.$store.dispatch('getCarLength')
|
||
}
|
||
})
|
||
}
|
||
},
|
||
getCatLength() {
|
||
this.$store.dispatch('getCarLength', this.goodDetail.specialArea)
|
||
},
|
||
close() {
|
||
this.selSku = false
|
||
},
|
||
goBuy() {
|
||
uni.navigateTo({
|
||
url:
|
||
'/pages/shareArea/orderShare?allData=' +
|
||
JSON.stringify(this.goodDetail),
|
||
})
|
||
},
|
||
getDetails() {
|
||
api
|
||
.waresDetail({
|
||
pkCountry: this.pkCountry,
|
||
specialArea: this.specialArea,
|
||
waresCode: this.waresCode,
|
||
})
|
||
.then(res => {
|
||
this.goodDetail = res.data
|
||
// let sl = this.goodDetail.sales + ''
|
||
// if (sl >= 10000) {
|
||
// sl = sl.substring(0, sl.length - 4) + '万+'
|
||
// }
|
||
// this.goodDetail.sales = sl
|
||
// this.mainImgUrl = res.data.videoUrl
|
||
this.imgUrlList = [
|
||
res.data.cover,
|
||
res.data.cover1,
|
||
res.data.cover2,
|
||
res.data.cover3,
|
||
res.data.cover4,
|
||
res.data.cover5,
|
||
res.data.cover6,
|
||
]
|
||
this.bannerImgList = [
|
||
res.data.videoUrl,
|
||
res.data.cover1,
|
||
res.data.cover2,
|
||
res.data.cover3,
|
||
res.data.cover4,
|
||
res.data.cover5,
|
||
res.data.cover6,
|
||
]
|
||
this.imgUrlList = this.imgUrlList.filter(item => item && item.trim())
|
||
this.bannerImgList = this.bannerImgList.filter(
|
||
item => item && item.trim()
|
||
)
|
||
this.goodDetail.productParams.forEach((item, index) => {
|
||
item.waresItemsParamsList.forEach((ctem, cndex) => {
|
||
ctem.quantity = 0
|
||
ctem.maxNum = 0
|
||
if (ctem.specsName.length > 15) {
|
||
ctem.specsNameDian = ctem.specsName.substring(0, 15) + '...'
|
||
} else {
|
||
ctem.specsNameDian = ctem.specsName
|
||
}
|
||
})
|
||
})
|
||
// 赋初值
|
||
this.goodDetail.productParams.forEach((item, index) => {
|
||
item.waresItemsParamsList.forEach((ctem, cndex) => {
|
||
if (cndex == 0) {
|
||
this.$set(ctem, 'quantity', item.quantity)
|
||
this.$set(ctem, 'maxNum', item.quantity)
|
||
// 初始总价格业绩
|
||
this.$set(item, 'priceTotal', ctem.priceTotal)
|
||
this.$set(item, 'vipPriceTotal', ctem.vipPriceTotal)
|
||
this.$set(item, 'retailPriceTotal', ctem.retailPriceTotal)
|
||
this.$set(item, 'achieveTotal', ctem.achieveTotal)
|
||
this.$set(item, 'assAchieveTotal', ctem.assAchieveTotal)
|
||
}
|
||
})
|
||
})
|
||
this.$set(this.goodDetail, 'goodsPrice', 0)
|
||
this.$set(this.goodDetail, 'retailPrice', 0)
|
||
this.$set(this.goodDetail, 'goodsAchive', 0)
|
||
this.$set(this.goodDetail, 'goodsAssAchive', 0)
|
||
this.goodDetail.productParams.forEach(item => {
|
||
if (this.specialArea == 31) {
|
||
if (this.user.isMakerSpace == 0) {
|
||
this.goodDetail.goodsPrice += parseFloat(item.priceTotal)
|
||
this.goodDetail.retailPrice += parseFloat(item.retailPriceTotal)
|
||
this.goodDetail.goodsAchive += parseFloat(item.achieveTotal)
|
||
|
||
this.goodDetail.goodsAssAchive += parseFloat(
|
||
item.assAchieveTotal
|
||
)
|
||
} else {
|
||
this.goodDetail.goodsPrice += parseFloat(item.vipPriceTotal)
|
||
this.goodDetail.retailPrice += parseFloat(item.retailPriceTotal)
|
||
this.goodDetail.goodsAchive += parseFloat(item.achieveTotal)
|
||
|
||
this.goodDetail.goodsAssAchive += parseFloat(
|
||
item.assAchieveTotal
|
||
)
|
||
}
|
||
} else {
|
||
this.goodDetail.goodsPrice += parseFloat(item.priceTotal)
|
||
this.goodDetail.goodsAchive += parseFloat(item.achieveTotal)
|
||
this.goodDetail.goodsAssAchive += parseFloat(item.assAchieveTotal)
|
||
}
|
||
})
|
||
this.ggString()
|
||
this.downTime()
|
||
})
|
||
},
|
||
// 拼接已选
|
||
ggString() {
|
||
this.goodDetail.productParams.forEach(item => {
|
||
item.skuString = ''
|
||
item.waresItemsParamsList.forEach((ctem, cndex) => {
|
||
if (ctem.quantity > 0) {
|
||
item.skuString += ctem.specsName + '*' + ctem.quantity
|
||
}
|
||
})
|
||
})
|
||
let skuString = ''
|
||
this.goodDetail.productParams.forEach(item => {
|
||
skuString += item.productName + item.skuString
|
||
})
|
||
if (skuString.length > 19) {
|
||
this.skuString = skuString.substring(0, 19) + '...'
|
||
} else {
|
||
this.skuString = skuString
|
||
}
|
||
},
|
||
getNum(index, cndex, { value }) {
|
||
this.goodDetail.productParams[index].waresItemsParamsList[
|
||
cndex
|
||
].quantity = value
|
||
let ggNum = 0
|
||
this.goodDetail.productParams[index].waresItemsParamsList.forEach(
|
||
(item, iindex) => {
|
||
if (iindex == cndex) {
|
||
ggNum += value
|
||
} else {
|
||
ggNum += item.quantity
|
||
}
|
||
}
|
||
)
|
||
if (this.goodDetail.productParams[index].quantity - value >= 0) {
|
||
this.goodDetail.productParams[index].waresItemsParamsList.forEach(
|
||
(stem, sndex) => {
|
||
if (sndex != cndex) {
|
||
this.$set(
|
||
stem,
|
||
'maxNum',
|
||
this.goodDetail.productParams[index].quantity -
|
||
(ggNum - stem.quantity)
|
||
)
|
||
}
|
||
}
|
||
)
|
||
}
|
||
let that = this
|
||
setTimeout(() => {
|
||
that.calPrice()
|
||
}, 50)
|
||
},
|
||
calPrice() {
|
||
if (this.user.pkCountry == 1) {
|
||
this.goodDetail.productParams.forEach(item => {
|
||
item.waresItemsParamsList.forEach(ctem => {
|
||
ctem.priceTotal = parseFloat(ctem.price) * ctem.quantity
|
||
ctem.assAchieveTotal = ctem.assAchieve * ctem.quantity
|
||
ctem.vipPriceTotal = ctem.vipPrice * ctem.quantity
|
||
ctem.retailPriceTotal = ctem.retailPrice * ctem.quantity
|
||
ctem.achieveTotal =
|
||
ctem.achieve * ctem.quantity * this.goodDetail.inExchangeRate
|
||
})
|
||
})
|
||
} else {
|
||
this.goodDetail.productParams.forEach(item => {
|
||
item.waresItemsParamsList.forEach(ctem => {
|
||
ctem.priceTotal = ctem.price * ctem.quantity
|
||
ctem.achieveTotal = ctem.achieve * ctem.quantity
|
||
ctem.assAchieveTotal = ctem.assAchieve * ctem.quantity
|
||
})
|
||
})
|
||
}
|
||
let price = 0
|
||
let vipPrice = 0
|
||
let retailPrice = 0
|
||
let achieve = 0
|
||
let assAchieve = 0
|
||
this.goodDetail.productParams.forEach(item => {
|
||
item.waresItemsParamsList.forEach(ctem => {
|
||
price += ctem.priceTotal
|
||
vipPrice += ctem.vipPriceTotal
|
||
retailPrice += ctem.retailPriceTotal
|
||
achieve += ctem.achieveTotal
|
||
assAchieve += ctem.assAchieveTotal
|
||
})
|
||
})
|
||
if (this.specialArea == 31) {
|
||
if (this.user.isMakerSpace == 0) {
|
||
this.goodDetail.goodsPrice = price.toFixed(2)
|
||
} else {
|
||
this.goodDetail.goodsPrice = vipPrice.toFixed(2)
|
||
}
|
||
} else {
|
||
this.goodDetail.goodsPrice = price.toFixed(2)
|
||
}
|
||
this.goodDetail.retailPrice = retailPrice
|
||
this.goodDetail.goodsAchive = achieve
|
||
this.goodDetail.goodsAssAchive = assAchieve
|
||
|
||
this.ggString()
|
||
},
|
||
downTime() {
|
||
let that = this
|
||
this.clockTime = setInterval(() => {
|
||
if (
|
||
that.goodDetail.deliveryTimeMs &&
|
||
that.goodDetail.deliveryTimeMs > 0
|
||
) {
|
||
that.countDown = this.getTime(this.goodDetail.deliveryTimeMs--)
|
||
} else {
|
||
that.countDown = '0天00时00分00秒'
|
||
}
|
||
}, 1000)
|
||
},
|
||
getTime(time) {
|
||
// 转换为式分秒
|
||
let d = parseInt(time / 60 / 60 / 24) //计算剩余天数\
|
||
d = d < 10 ? '0' + d : d
|
||
let h = parseInt((time / 60 / 60) % 24)
|
||
h = h < 10 ? '0' + h : h
|
||
let m = parseInt((time / 60) % 60)
|
||
m = m < 10 ? '0' + m : m
|
||
let s = parseInt(time % 60)
|
||
s = s < 10 ? '0' + s : s
|
||
// 作为返回值返回
|
||
return d + '天' + h + ':' + m + ':' + s
|
||
},
|
||
// 处理库存百分比,移除百分号并转换为数字
|
||
getInventoryPercentage(inventory) {
|
||
if (typeof inventory === 'string') {
|
||
// 移除百分号并转换为数字
|
||
const numStr = inventory.replace('%', '').trim()
|
||
const num = parseFloat(numStr)
|
||
return isNaN(num) ? 0 : Math.min(100, Math.max(0, num))
|
||
} else if (typeof inventory === 'number') {
|
||
// 如果是数字,确保在0-100范围内
|
||
return Math.min(100, Math.max(0, inventory))
|
||
}
|
||
return 0
|
||
},
|
||
// 根据库存百分比返回对应的进度条样式类
|
||
getProgressClass(inventory) {
|
||
const percentage = this.getInventoryPercentage(inventory)
|
||
if (percentage >= 80) {
|
||
return 'progress-high'
|
||
} else if (percentage >= 60) {
|
||
return 'progress-medium-high'
|
||
} else if (percentage >= 40) {
|
||
return 'progress-medium'
|
||
} else if (percentage >= 20) {
|
||
return 'progress-low'
|
||
} else {
|
||
return 'progress-critical'
|
||
}
|
||
},
|
||
// 根据库存百分比返回百分比数字的样式类
|
||
getPercentageClass(inventory) {
|
||
const percentage = this.getInventoryPercentage(inventory)
|
||
if (percentage <= 20) {
|
||
return 'percentage-critical'
|
||
} else if (percentage <= 30) {
|
||
return 'percentage-urgent'
|
||
} else {
|
||
return 'percentage-normal'
|
||
}
|
||
},
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.content {
|
||
background: #f8f8f8;
|
||
min-height: 100vh;
|
||
}
|
||
.contxt {
|
||
padding: 0 24rpx 20rpx 24rpx;
|
||
}
|
||
.kuang {
|
||
margin-top: 20rpx;
|
||
padding: 20rpx;
|
||
background: #fff;
|
||
box-shadow: 0px 2px 10px 0px rgba(204, 204, 204, 0.5);
|
||
border-radius: 10px 10px 10px 10px;
|
||
.disFlex {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
.t_red {
|
||
font-size: 16px;
|
||
font-family: Arial-Bold, Arial;
|
||
font-weight: bold;
|
||
color: #b42b2a;
|
||
// margin-right: 20px;
|
||
}
|
||
.t_hui {
|
||
font-size: 11px;
|
||
font-family: Arial-Bold, Arial;
|
||
font-weight: bold;
|
||
color: #999;
|
||
margin-left: 20rpx;
|
||
}
|
||
.t_hui1 {
|
||
font-size: 11px;
|
||
font-family: Arial-Bold, Arial;
|
||
font-weight: bold;
|
||
color: #999;
|
||
margin: 5px 0 10px 0;
|
||
}
|
||
.bao {
|
||
font-size: 13px;
|
||
color: #de0214;
|
||
font-weight: 600;
|
||
}
|
||
}
|
||
.kuang1 {
|
||
margin-top: -10rpx;
|
||
padding: 20rpx;
|
||
background: #fff;
|
||
box-shadow: 0px 2px 10px 0px rgba(204, 204, 204, 0.5);
|
||
border-radius: 10px 10px 10px 10px;
|
||
|
||
.t_red {
|
||
font-size: 16px;
|
||
font-family: Arial-Bold, Arial;
|
||
font-weight: bold;
|
||
color: #b42b2a;
|
||
// margin-right: 20px;
|
||
}
|
||
.t_hui {
|
||
font-size: 11px;
|
||
font-family: Arial-Bold, Arial;
|
||
font-weight: bold;
|
||
color: #999;
|
||
// margin-left: 20rpx;
|
||
}
|
||
.bao {
|
||
font-size: 13px;
|
||
color: #de0214;
|
||
font-weight: 600;
|
||
}
|
||
}
|
||
.t_hei {
|
||
font-size: 13px;
|
||
font-family:
|
||
PingFang SC-Semibold,
|
||
PingFang SC;
|
||
font-weight: 600;
|
||
color: #333;
|
||
}
|
||
.heng {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
font-size: 12px;
|
||
font-family:
|
||
PingFang SC-Medium,
|
||
PingFang SC;
|
||
font-weight: 500;
|
||
color: #999999;
|
||
margin-bottom: 10rpx;
|
||
}
|
||
.label {
|
||
margin-right: 40rpx;
|
||
}
|
||
.label1 {
|
||
font-size: 13px;
|
||
font-family:
|
||
PingFang SC-Semibold,
|
||
PingFang SC;
|
||
font-weight: 600;
|
||
color: #333333;
|
||
}
|
||
.bTit {
|
||
text-align: center;
|
||
margin: 30rpx 0;
|
||
font-size: 16px;
|
||
font-family:
|
||
PingFang SC-Semibold,
|
||
PingFang SC;
|
||
font-weight: 600;
|
||
color: #333333;
|
||
.btm {
|
||
width: 26px;
|
||
height: 2px;
|
||
background: #15b84b;
|
||
border-radius: 2px 2px 2px 2px;
|
||
margin: 10rpx auto;
|
||
}
|
||
}
|
||
.pop_a {
|
||
background: #f7f7f7;
|
||
max-height: 80vh;
|
||
overflow-y: auto;
|
||
}
|
||
.pop_tt {
|
||
padding: 0 10rpx;
|
||
margin: 0rpx 10rpx;
|
||
height: 172rpx;
|
||
background: #fff;
|
||
position: fixed;
|
||
width: calc(100% - 40rpx);
|
||
display: flex;
|
||
align-items: center;
|
||
z-index: 1;
|
||
.pop_t {
|
||
display: flex;
|
||
align-items: center;
|
||
img {
|
||
width: 58px;
|
||
height: 58px;
|
||
border-radius: 8px 8px 8px 8px;
|
||
margin-right: 40rpx;
|
||
}
|
||
font-size: 28px;
|
||
font-family: Arial-Bold, Arial;
|
||
font-weight: bold;
|
||
color: #b42b2a;
|
||
}
|
||
}
|
||
.zhan {
|
||
height: 172rpx;
|
||
}
|
||
.zhan1 {
|
||
height: 130rpx;
|
||
}
|
||
.pop {
|
||
padding: 10rpx 20rpx;
|
||
margin: 20rpx 10rpx;
|
||
box-shadow: 0px 2px 10px 0px rgba(204, 204, 204, 0.5);
|
||
border-radius: 8px 8px 8px 8px;
|
||
background: #fff;
|
||
.pop_c {
|
||
border-bottom: 8rpx solid rgba(0, 0, 0, 0.05);
|
||
padding: 10rpx 0 20rpx 0;
|
||
.ggTit {
|
||
font-size: 12px;
|
||
font-family:
|
||
PingFang SC-Medium,
|
||
PingFang SC;
|
||
font-weight: 500;
|
||
color: #333333;
|
||
margin: 20rpx 0;
|
||
}
|
||
.pop_ci {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
background: #eeeeee;
|
||
border-radius: 4px 4px 4px 4px;
|
||
opacity: 1;
|
||
margin-bottom: 20rpx;
|
||
padding: 4rpx 12rpx;
|
||
.pop_cl {
|
||
display: flex;
|
||
align-items: center;
|
||
.gui_iit {
|
||
margin-left: 20rpx;
|
||
}
|
||
}
|
||
}
|
||
img {
|
||
width: 48rpx;
|
||
height: 48rpx;
|
||
border-radius: 4px 4px 4px 4px;
|
||
}
|
||
}
|
||
}
|
||
::v-deep .u-popup__content__close {
|
||
z-index: 2;
|
||
}
|
||
.hui {
|
||
width: 22px;
|
||
height: 22px;
|
||
background: #dbdbdb;
|
||
border-radius: 3px 3px 3px 3px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
.minus {
|
||
width: 22px;
|
||
height: 22px;
|
||
background: rgba(176, 196, 222, 1);
|
||
border-radius: 3px 3px 3px 3px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
.plus {
|
||
width: 22px;
|
||
height: 22px;
|
||
background: #005bac;
|
||
border-radius: 3px 3px 3px 3px;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
.input {
|
||
width: 50px;
|
||
text-align: center;
|
||
background: #fff;
|
||
margin: 0 10rpx;
|
||
border-radius: 3px 3px 3px 3px;
|
||
}
|
||
.pop_b {
|
||
position: fixed;
|
||
bottom: 0;
|
||
height: 166rpx;
|
||
background: #ffffff;
|
||
width: 100%;
|
||
}
|
||
.pop_bb {
|
||
padding: 20rpx 40rpx;
|
||
}
|
||
.footer_f {
|
||
position: fixed;
|
||
bottom: 0;
|
||
width: 100%;
|
||
z-index: 10;
|
||
box-shadow: 0px -2px 20px 0px rgba(204, 204, 204, 0.5);
|
||
}
|
||
.footer {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
padding: 20rpx 24rpx 40rpx 24rpx;
|
||
background: #fff;
|
||
.footer_l {
|
||
flex: 1;
|
||
display: flex;
|
||
align-items: center;
|
||
font-size: 20rpx;
|
||
font-family: PingFang SC;
|
||
font-weight: 400;
|
||
color: #222222;
|
||
}
|
||
.footer_r {
|
||
display: flex;
|
||
.btn1 {
|
||
background: #005bac;
|
||
color: #fff;
|
||
// padding: 0rpx 33rpx 0rpx 43rpx;
|
||
border-radius: 50px;
|
||
height: 75rpx;
|
||
width: 214rpx;
|
||
line-height: 75rpx;
|
||
text-align: center;
|
||
}
|
||
.btn2 {
|
||
background: #3d3d3d;
|
||
color: #fff;
|
||
// padding: 0rpx 43rpx 0rpx 33rpx;
|
||
border-radius: 0px 50px 50px 0;
|
||
height: 75rpx;
|
||
width: 214rpx;
|
||
line-height: 75rpx;
|
||
text-align: center;
|
||
}
|
||
}
|
||
.footer_li {
|
||
// position: relative;
|
||
// text-align: center;
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
font-size: 10px;
|
||
font-family:
|
||
PingFang SC-Medium,
|
||
PingFang SC;
|
||
font-weight: 500;
|
||
color: #333333;
|
||
}
|
||
.flout {
|
||
position: absolute;
|
||
top: -4px;
|
||
right: -10px;
|
||
background: #f56c6c;
|
||
border-radius: 50%;
|
||
width: 32rpx;
|
||
height: 32rpx;
|
||
color: #fff;
|
||
text-align: center;
|
||
}
|
||
.footer_ll {
|
||
margin-right: 40rpx;
|
||
position: relative;
|
||
}
|
||
.qiu {
|
||
position: absolute;
|
||
width: 30rpx;
|
||
height: 30rpx;
|
||
background: #e03030;
|
||
border-radius: 50%;
|
||
color: #fff;
|
||
text-align: center;
|
||
line-height: 30rpx;
|
||
right: 0;
|
||
top: -10rpx;
|
||
font-size: 10px;
|
||
}
|
||
.btns {
|
||
border-radius: 18px;
|
||
border: 1px solid #fbb61e;
|
||
padding: 12rpx 0;
|
||
width: 176rpx;
|
||
text-align: center;
|
||
font-size: 12px;
|
||
font-weight: 500;
|
||
}
|
||
.btn3 {
|
||
background: rgba(255, 255, 255, 0);
|
||
color: #fbb61e;
|
||
margin-right: 20rpx;
|
||
}
|
||
.btn4 {
|
||
background: #fbb61e;
|
||
color: #fff;
|
||
}
|
||
}
|
||
.sTop {
|
||
// display: flex;
|
||
// align-items: center;
|
||
// justify-content: space-between;
|
||
background: #005bac;
|
||
padding: 10rpx 20rpx 20rpx 20rpx;
|
||
margin-top: 20rpx;
|
||
border-radius: 10px 10px 0 0;
|
||
.sTop_l {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
}
|
||
img {
|
||
width: 18px;
|
||
height: 18px;
|
||
}
|
||
.f1 {
|
||
font-size: 22px;
|
||
color: #fff;
|
||
font-weight: 600;
|
||
}
|
||
.f2 {
|
||
font-size: 12px;
|
||
color: #fff;
|
||
margin-left: 10rpx;
|
||
font-weight: 400;
|
||
}
|
||
.f3 {
|
||
font-size: 10px;
|
||
color: #fff;
|
||
font-weight: 400;
|
||
}
|
||
}
|
||
.disFlex {
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
.disFlex1 {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: flex-end;
|
||
margin-bottom: 10rpx;
|
||
}
|
||
|
||
/* 库存进度条样式 */
|
||
.inventory-progress-container {
|
||
margin-top: 20rpx;
|
||
|
||
.inventory-header {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 12rpx;
|
||
|
||
.inventory-label {
|
||
display: flex;
|
||
align-items: center;
|
||
font-size: 24rpx;
|
||
|
||
.inventory-status {
|
||
color: #333;
|
||
}
|
||
}
|
||
|
||
.inventory-percentage {
|
||
font-size: 24rpx;
|
||
font-weight: 700;
|
||
font-family:
|
||
DIN Alternate,
|
||
Arial,
|
||
sans-serif;
|
||
|
||
&.percentage-critical {
|
||
color: #ff3742;
|
||
animation: percentageBlink 1s ease-in-out infinite;
|
||
text-shadow: 0 0 10rpx rgba(255, 55, 66, 0.3);
|
||
}
|
||
|
||
&.percentage-urgent {
|
||
color: #ff5252;
|
||
animation: percentageGlow 2s ease-in-out infinite;
|
||
}
|
||
|
||
&.percentage-normal {
|
||
color: #005bac;
|
||
}
|
||
}
|
||
}
|
||
|
||
.inventory-progress-bar {
|
||
width: 100%;
|
||
height: 16rpx;
|
||
background: rgba(0, 0, 0, 0.08);
|
||
border-radius: 8rpx;
|
||
overflow: hidden;
|
||
position: relative;
|
||
box-shadow: inset 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
|
||
|
||
.inventory-progress-fill {
|
||
height: 100%;
|
||
border-radius: 8rpx;
|
||
transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
|
||
position: relative;
|
||
overflow: hidden;
|
||
|
||
/* 进度条渐变色彩 */
|
||
&.progress-critical {
|
||
background: linear-gradient(
|
||
90deg,
|
||
#ff1744 0%,
|
||
#d50000 50%,
|
||
#ff1744 100%
|
||
);
|
||
box-shadow: 0 0 20rpx rgba(255, 23, 68, 0.4);
|
||
animation: criticalPulse 1.5s ease-in-out infinite;
|
||
}
|
||
|
||
&.progress-low {
|
||
background: linear-gradient(
|
||
90deg,
|
||
#ff5722 0%,
|
||
#e64a19 50%,
|
||
#ff5722 100%
|
||
);
|
||
box-shadow: 0 0 15rpx rgba(255, 87, 34, 0.3);
|
||
}
|
||
|
||
&.progress-medium {
|
||
background: linear-gradient(
|
||
90deg,
|
||
#ff9800 0%,
|
||
#f57c00 50%,
|
||
#ff9800 100%
|
||
);
|
||
box-shadow: 0 0 10rpx rgba(255, 152, 0, 0.2);
|
||
}
|
||
|
||
&.progress-medium-high {
|
||
background: linear-gradient(
|
||
90deg,
|
||
#2196f3 0%,
|
||
#1976d2 50%,
|
||
#2196f3 100%
|
||
);
|
||
box-shadow: 0 0 8rpx rgba(33, 150, 243, 0.2);
|
||
}
|
||
|
||
&.progress-high {
|
||
background: linear-gradient(
|
||
90deg,
|
||
#4caf50 0%,
|
||
#388e3c 25%,
|
||
#005bac 75%,
|
||
#003d82 100%
|
||
);
|
||
box-shadow: 0 0 8rpx rgba(0, 91, 172, 0.2);
|
||
}
|
||
|
||
/* 流动光效 */
|
||
.progress-shine {
|
||
position: absolute;
|
||
top: 0;
|
||
left: -100%;
|
||
width: 100%;
|
||
height: 100%;
|
||
background: linear-gradient(
|
||
90deg,
|
||
transparent 0%,
|
||
rgba(255, 255, 255, 0.8) 50%,
|
||
transparent 100%
|
||
);
|
||
animation: shineFlow 2s ease-in-out infinite;
|
||
}
|
||
|
||
/* 高光效果 */
|
||
&::after {
|
||
content: '';
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
right: 0;
|
||
height: 60%;
|
||
background: linear-gradient(
|
||
to bottom,
|
||
rgba(255, 255, 255, 0.4) 0%,
|
||
rgba(255, 255, 255, 0.1) 50%,
|
||
transparent 100%
|
||
);
|
||
border-radius: 8rpx 8rpx 0 0;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/* 动画定义 */
|
||
@keyframes percentageBlink {
|
||
0%,
|
||
100% {
|
||
opacity: 1;
|
||
}
|
||
50% {
|
||
opacity: 0.7;
|
||
}
|
||
}
|
||
|
||
@keyframes percentageGlow {
|
||
0%,
|
||
100% {
|
||
text-shadow: 0 0 5rpx rgba(255, 82, 82, 0.3);
|
||
}
|
||
50% {
|
||
text-shadow: 0 0 15rpx rgba(255, 82, 82, 0.6);
|
||
}
|
||
}
|
||
|
||
@keyframes criticalPulse {
|
||
0%,
|
||
100% {
|
||
box-shadow: 0 0 20rpx rgba(255, 23, 68, 0.4);
|
||
}
|
||
50% {
|
||
box-shadow: 0 0 30rpx rgba(255, 23, 68, 0.7);
|
||
}
|
||
}
|
||
|
||
@keyframes shineFlow {
|
||
0% {
|
||
left: -100%;
|
||
}
|
||
100% {
|
||
left: 100%;
|
||
}
|
||
}
|
||
</style>
|