Commit 8234ec4f by yancanhua

fix: 轮询出价前端开发

1 parent 16644dfc
......@@ -69,9 +69,10 @@ export default class RoundBidPopup extends Vue {
}
setTimeoutSecond() {
if (this.nextAucVehData.remainSecond) {
if (this.nextAucVehData.remainSecond && Number(this.nextAucVehData.remainSecond) > 0) {
setTimeout(() => {
this.nextAucVehData.remainSecond = Number(this.nextAucVehData.remainSecond) - 1;
//取整数部分
this.nextAucVehData.remainSecond = Math.floor(Number(this.nextAucVehData.remainSecond)) - 1;
this.setTimeoutSecond();
}, 1000);
} else {
......
......@@ -61,8 +61,10 @@
</view>
<view class="upBox_add">
<view class="upBox_second">{{ pageData.remainSecond }}秒</view>
<view class="border_solid">
<view class="border_but" @click="handleAddBid()">{{ addPrice ? '+' : '' }}{{ addPrice }}</view>
<view @click="handleAddBid()" class="progress-circle-up" style="--progress: {{ progressValue }}%">
<view class="progress-inner-up">
<text class="progress-value" style="font-size: 12px;">+{{ addPrice }}</text>
</view>
</view>
</view>
</view>
......@@ -95,9 +97,9 @@
</view>
<view class="downBox_right">
<view class="downBox_second">{{ pageData.remainSecond }}秒</view>
<view class="downBox_border_solid">
<view class="downBox_border_but" @click="handleAddBid()">
{{ addPrice ? '+' : '' }}{{ addPrice }}
<view @click="handleAddBid()" class="progress-circle" style="--progress: {{ progressValue }}%">
<view class="progress-inner">
<text class="progress-value">+{{ addPrice }}</text>
</view>
</view>
</view>
......@@ -116,7 +118,10 @@
<view class="downBox_custom_hand">
<view class="downBox_custom_input">
<view class="downBox_custom_unit">¥</view>
<van-field :value="customBid" style="height: 36px;" placeholder="最低100" />
<view style="margin-top: 4px;">
<uni-easyinput v-model="customBid" type="number" :inputBorder="false" maxlength="6"
:clearable="false" placeholder="最低100"></uni-easyinput>
</view>
</view>
<view class="downBox_custom_but" @click="handleCustomBidConfirm()">确认</view>
</view>
......@@ -188,12 +193,9 @@ export default class roundBidBottom extends Vue {
@Prop({ type: Object, required: true })
auctionVehicle: any;
//页面状态 认证 COMMON 充值 NOTOPUP 等待开始 PREVIEW 进行中 AUCTIONING 结束 END 结束自动跳转 JUMP
pageState = 'COMMON';
endState = '1'; // 1 未成交 2 已中拍 3 未中拍
//页面显示数据
pageData = {
accountBidPrice: 0, // 用户出价 价格
......@@ -206,19 +208,16 @@ export default class roundBidBottom extends Vue {
reservePriceType: 0,
bidPriceType: 0,
};
foldState = 'UP'; //展开 UP 收起 DOWN
addPrice = '100';//加价金额
remainingTime = '5';//剩余时间
isShowCustom = false; //是否显示自定义输入框
customBid = ''; //自定义出价
resultPrice = 0; // 最终成交价
orderId = '';
progressValue = 0; // 进度值
isAudio = false; // 是否是语音出价
//自定义金额
operationButList = [{ value: '100', }, { value: '300', }, { value: '500', }, { value: '1000', }, { value: '自定义', }];
......@@ -303,6 +302,7 @@ export default class roundBidBottom extends Vue {
//价格改变重新获取佣金
if (this.pageData.price != data.price) {
this.realCalcCommissionPriceData();
this.handleAudio();
}
this.pageData = { ...this.pageData, ...data, remainSecond: Math.floor(data.remainSecond || 0) };
......@@ -313,7 +313,9 @@ export default class roundBidBottom extends Vue {
//拍卖结束后获取下一辆车及拍卖状态
if (this.pageData.over) {
this.pageState = 'END';
this.getAccountBidResultData();
setTimeout(() => {
this.getAccountBidResultData();
}, 1000);
}
// 获取当前路由地址
......@@ -325,14 +327,22 @@ export default class roundBidBottom extends Vue {
this.getBidRemainSecData();
}, 1000);
}
this.calcProgress();
});
}
//计算进度
calcProgress() {
const aucvehDuration = JSON.parse(this.auctionVehicle?.auction?.extraJson || '{}')?.aucvehDuration || 0;
const progress = (this.pageData.remainSecond || 0) / Number(aucvehDuration || 0);
this.progressValue = Math.floor(progress * 100);
}
//获取拍卖佣金
realCalcCommissionPriceData() {
AuctionOrderController.realCalcCommissionPrice(this.axios, { aucvehId: this.auctionVehicle.aucvehId }).then(res => {
const data = res.data?.data || {};
this.pageData.commissionPrice = (Number(data.commissionPrice || 0)) / 10000;
this.pageData.commissionPrice = Number(data.commissionPrice || 0);
});
}
......@@ -345,7 +355,6 @@ export default class roundBidBottom extends Vue {
BidController.addBid(this.axios, bidRequest).then(res => {
setTimeout(() => {
uni.showToast({ title: '出价成功', icon: 'success' });
this.handleAudio();
}, 300);
}).finally(() => {
uni.hideLoading();
......@@ -353,14 +362,19 @@ export default class roundBidBottom extends Vue {
}
handleAudio() {
console.log('播放音频');
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = 'https://img02.glsx.com.cn/aus/images/roundBid/notice.mp3';
innerAudioContext.onEnded(() => {
innerAudioContext.destroy();
console.log('音频播放完成');
});
const that = this;
if (!that.isAudio) {
console.log('播放音频isAudio', that.isAudio);
that.isAudio = true;
const innerAudioContext = uni.createInnerAudioContext();
innerAudioContext.autoplay = true;
innerAudioContext.src = 'https://img02.glsx.com.cn/aus/images/roundBid/notice.mp3';
innerAudioContext.onEnded(() => {
innerAudioContext.destroy();
that.isAudio = false;
console.log('音频播放完成isAudio', that.isAudio);
});
}
}
//获取拍卖结果
......@@ -371,27 +385,19 @@ export default class roundBidBottom extends Vue {
this.resultPrice = (Number(data.price || 0)) / 10000;
if (this.endState != '2') {
this.getNextAucVehData();
if(this.pageState == 'END'){
this.noticeBidEnd();
}
}
});
}
//获取拍卖订单号
noticeBidEnd() {
//签署购车合同
signContract() {
AuctionOrderController.getAuctionOrderByVehicleId(this.axios, this.auctionVehicle.vehicle.vehicleId).then(res => {
if (res.data > 0) {
this.orderId = res.data;
if (res.data > 0 && res.data) {
uni.navigateTo({ url: '/module/order/contract/ContractPage?orderId=' + res.data });
}
});
}
//签署购车合同
signContract() {
uni.navigateTo({ url: '/module/order/contract/ContractPage?orderId=' + this.orderId });
}
//获取下一辆车
getNextAucVehData() {
AuctionOrderController.getNextAucVeh(this.axios, { aucvehId: this.auctionVehicle.aucvehId }).then(res => {
......@@ -414,7 +420,6 @@ export default class roundBidBottom extends Vue {
this.isShowCustom = false;
this.handleAddBid();
} else {
// this.addPrice = '';
this.customBid = '';
this.isShowCustom = true;
}
......@@ -423,25 +428,32 @@ export default class roundBidBottom extends Vue {
//自定义确认出价
handleCustomBidConfirm() {
if (!this.customBid) {
uni.showToast({ title: '请输入自定义加价金额', icon: 'none' })
} else {
// this.addPrice = this.customBid;
this.handleAddBid();
return uni.showToast({ title: '请输入自定义加价金额', icon: 'none' })
}
// 校验自定义加价金额是否为数字
if (isNaN(Number(this.customBid))) {
return uni.showToast({ title: '请输入正确的加价金额', icon: 'none' })
}
// 校验自定义加价金额是否符合规则
if (Number(this.customBid) < 100) {
return uni.showToast({ title: '自定义加价金额不能小于100', icon: 'none' })
}
//校验加价金额必须是100的倍数
if (Number(this.customBid) % 100 != 0) {
return uni.showToast({ title: '自定义加价金额必须是100的倍数', icon: 'none' })
}
const bidPrice = Number(this.pageData.price || 0) + Number(this.customBid);
const bidRequest = { aucvehId: this.auctionVehicle.aucvehId, bidPrice: bidPrice };
uni.showLoading({ title: '正在提交竞价信息...', mask: true });
BidController.addBid(this.axios, bidRequest).then(res => {
setTimeout(() => {
uni.showToast({ title: '出价成功', icon: 'success' });
}, 300);
}).finally(() => {
uni.hideLoading();
});
}
//自定义金额输入框
// handleCustomBidInput(value: any) {
// let numStr = String(value?.detail?.value || '').replace(/\D/g, '');
// let num = parseInt(numStr, 10);
// if (num > 0) {
// num = Math.floor(num / 100) * 100;
// if (num < 100) num = 100;
// this.customBid = num.toString();
// } else {
// this.customBid = '100';
// }
// }
}
</script>
......@@ -664,35 +676,6 @@ export default class roundBidBottom extends Vue {
font-family: "D-DIN-PRO";
}
.border_solid {
width: 58px;
height: 58px;
float: left;
border: 3px solid #e3ebf4;
background: #f4f8ff;
border-radius: 50%;
margin-top: 8px;
margin-left: 8px;
margin-bottom: 8px;
}
.border_but {
width: 48px;
height: 48px;
float: left;
margin: 5px;
line-height: 48px;
text-align: center;
background: linear-gradient(148.6deg, #7aa3fe 0%, #185efe 100%);
box-shadow: 0 2px 4px 0 #8ab5e640;
border-radius: 50%;
color: #ffffff;
font-size: 14px;
font-weight: 700;
font-family: "D DIN PRO";
cursor: pointer;
}
.downBox {
width: 100%;
min-height: 80px;
......@@ -734,33 +717,6 @@ export default class roundBidBottom extends Vue {
margin-right: 4px;
}
.downBox_border_solid {
width: 100px;
height: 100px;
float: left;
border: 4px solid #e3ebf4;
background: #f4f8ff;
border-radius: 50%;
margin-right: 40px;
margin-top: 16px;
}
.downBox_border_but {
width: 76px;
height: 76px;
float: left;
margin: 12px;
line-height: 76px;
text-align: center;
background: linear-gradient(148.6deg, #7aa3fe 0%, #185efe 100%);
box-shadow: 0 2px 4px 0 #8ab5e640;
border-radius: 50%;
color: #ffffff;
font-size: 18px;
font-weight: 500;
font-family: "D DIN PRO";
}
.downBox_list {
width: 100%;
height: 20px;
......@@ -945,4 +901,64 @@ export default class roundBidBottom extends Vue {
.color3 {
color: #F15662 !important;
}
.progress-circle {
width: 108px;
height: 108px;
border-radius: 50%;
background: conic-gradient(#185efe 0% var(--progress), #e3ebf4 var(--progress) 100%);
display: flex;
align-items: center;
justify-content: center;
position: relative;
float: left;
margin-right: 40px;
margin-top: 16px;
}
.progress-inner {
width: 76px;
height: 76px;
background: linear-gradient(148.6deg, #7aa3fe 0%, #185efe 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
border: 10px solid #ffffff;
}
.progress-circle-up {
width: 58px;
height: 58px;
border-radius: 50%;
background: conic-gradient(#185efe 0% var(--progress), #e3ebf4 var(--progress) 100%);
display: flex;
align-items: center;
justify-content: center;
position: relative;
float: left;
margin-top: 8px;
margin-left: 8px;
margin-bottom: 8px;
}
.progress-inner-up {
width: 48px;
height: 48px;
background: linear-gradient(148.6deg, #7aa3fe 0%, #185efe 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
border: 5px solid #ffffff;
}
.progress-value {
width: 100%;
text-align: center;
color: #ffffff;
font-size: 18px;
font-weight: 500;
font-family: "D DIN PRO";
}
</style>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!