|
|
@@ -5,7 +5,7 @@
|
|
|
<view class="module-com">
|
|
|
<view class="commodity-view">
|
|
|
<view class="commodity-list">
|
|
|
- <view class="commodity-item" v-for="(item, index) in list" :key="index">
|
|
|
+ <view class="commodity-item" :class="{'limit-exceed-item': item._limitExceeded}" v-for="(item, index) in list" :key="index">
|
|
|
<image class="item-icon" :src="item.cover" />
|
|
|
<view class="item-info">
|
|
|
<view class="info-line">
|
|
|
@@ -23,6 +23,7 @@
|
|
|
<text>{{`${item.bigCount}`}}{{item.bigUnit}}</text>
|
|
|
</text>
|
|
|
</view>
|
|
|
+ <text v-if="item._limitExceeded" class="limit-exceed-tip">限购 {{ limitExceedLimitBuy }},超出 {{ limitExceedNum }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -334,7 +335,10 @@ export default {
|
|
|
validAddress:false,
|
|
|
hbData:[], // 可用红包数据
|
|
|
selectedHbId: null, // 选中的红包ID
|
|
|
- selectedHb: null // 选中的红包对象
|
|
|
+ selectedHb: null, // 选中的红包对象
|
|
|
+ limitExceedProductId:'',
|
|
|
+ limitExceedLimitBuy:'',
|
|
|
+ limitExceedNum:''
|
|
|
};
|
|
|
},
|
|
|
onLoad(){
|
|
|
@@ -357,6 +361,7 @@ export default {
|
|
|
mergedMap[key].smallCount = mergedMap[key].smallCount + item.smallCount;
|
|
|
} else {
|
|
|
mergedMap[key] = this.$util.copyObject(item);
|
|
|
+ mergedMap[key]._limitExceeded = false
|
|
|
list.push(mergedMap[key]);
|
|
|
}
|
|
|
}
|
|
|
@@ -738,7 +743,6 @@ export default {
|
|
|
console.log('selectDelivery -- isFreeDelivery: ',isFreeDelivery)
|
|
|
},
|
|
|
confirmForm(){
|
|
|
-
|
|
|
let hdId = this.option.hdId ? this.option.hdId : 0
|
|
|
let account = this.option.account ? this.option.account : 0
|
|
|
if(Number(hdId)<=0 || Number(account)<=0){
|
|
|
@@ -817,14 +821,36 @@ export default {
|
|
|
buyItem(params).then(res => {
|
|
|
uni.hideLoading()
|
|
|
if(res.code && res.code == 1){
|
|
|
+ this.clearLimitExceededMark()
|
|
|
+ this.limitExceedProductId = ''
|
|
|
+ this.limitExceedLimitBuy = ''
|
|
|
+ this.limitExceedNum = ''
|
|
|
let account = this.option.account ? this.option.account : 0
|
|
|
let getPayType = res.data.getPayType?res.data.getPayType:0
|
|
|
let totalPrice = res.data.totalPrice?res.data.totalPrice:0
|
|
|
let orderSn = res.data.orderSn?res.data.orderSn:''
|
|
|
let id = res.data.id ? res.data.id : 0
|
|
|
this.$util.pageTo({url:"/pages/callback/pay?account="+account+'&id='+id+'&hdId='+hdId+'&pageStatus=1&getPayType='+getPayType+'&totalPrice='+totalPrice+'&orderSn='+orderSn,type:2})
|
|
|
+ }else if(res.code == -1 && res.data && String(res.data.productId || '') !== ''){
|
|
|
+ this.limitExceedProductId = res.data.productId ? String(res.data.productId) : ''
|
|
|
+ this.limitExceedLimitBuy = res.data.limitBuy ? String(res.data.limitBuy) : '0'
|
|
|
+ this.limitExceedNum = res.data.exceed ? String(res.data.exceed) : '0'
|
|
|
+ this.markLimitExceededItem(this.limitExceedProductId)
|
|
|
+ this.$msg(res.msg || '累计已超出限购数')
|
|
|
+ return false
|
|
|
+ }else{
|
|
|
+ this.clearLimitExceededMark()
|
|
|
+ this.limitExceedProductId = ''
|
|
|
+ this.limitExceedLimitBuy = ''
|
|
|
+ this.limitExceedNum = ''
|
|
|
+ if(res.msg){
|
|
|
+ this.$msg(res.msg)
|
|
|
+ }
|
|
|
}
|
|
|
this.removeMemory()
|
|
|
+ }).catch(err => {
|
|
|
+ uni.hideLoading()
|
|
|
+ this.$msg(err.msg)
|
|
|
})
|
|
|
},
|
|
|
modifyItem() {
|
|
|
@@ -832,6 +858,31 @@ export default {
|
|
|
let hdId = this.option.hdId ? this.option.hdId : 0
|
|
|
this.$util.pageTo({url:'/pages/item/item?account='+account+'&hdId='+hdId,type:2})
|
|
|
},
|
|
|
+ markLimitExceededItem(productId){
|
|
|
+ if(!productId || !Array.isArray(this.list) || this.list.length <= 0){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const targetId = String(productId)
|
|
|
+ this.list.forEach((item, index) => {
|
|
|
+ const matched = String(item.id) === targetId
|
|
|
+ this.$set(this.list[index], '_limitExceeded', matched)
|
|
|
+ })
|
|
|
+ this.$forceUpdate()
|
|
|
+ },
|
|
|
+ clearLimitExceededMark(){
|
|
|
+ if(!Array.isArray(this.list) || this.list.length <= 0){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.list.forEach((item, index) => {
|
|
|
+ this.$set(this.list[index], '_limitExceeded', false)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ isLimitExceededItem(item){
|
|
|
+ if(!item || !this.limitExceedProductId){
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ return String(item.id) === String(this.limitExceedProductId)
|
|
|
+ },
|
|
|
getHbData(){
|
|
|
getAvailableHb({shopId:this.shopInfo.id}).then(res=>{
|
|
|
if(res.code == 1){
|
|
|
@@ -1024,17 +1075,30 @@ export default {
|
|
|
.commodity-item {
|
|
|
display: flex;
|
|
|
margin-bottom: 20upx;
|
|
|
+ &.limit-exceed-item {
|
|
|
+ border: 2upx solid #ff4d4f;
|
|
|
+ border-radius: 12upx;
|
|
|
+ padding: 12upx;
|
|
|
+ box-sizing: border-box;
|
|
|
+ }
|
|
|
.item-icon {
|
|
|
flex-shrink: 0;
|
|
|
width: 140upx;
|
|
|
height: 140upx;
|
|
|
}
|
|
|
.item-info {
|
|
|
+ position: relative;
|
|
|
display: flex;
|
|
|
flex-direction: column;
|
|
|
justify-content: center;
|
|
|
flex: 1;
|
|
|
margin-left: 20upx;
|
|
|
+ .limit-exceed-tip {
|
|
|
+ margin-top: 10upx;
|
|
|
+ color: #ff4d4f;
|
|
|
+ font-size: 24upx;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
.info-line {
|
|
|
margin-bottom: 20upx;
|
|
|
display: flex;
|