You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
191 lines
5.3 KiB
191 lines
5.3 KiB
6 months ago
|
<template>
|
||
|
<div v-if="goodsinfo.orderMode != 2" class="submit-tow" @click.stop="markup()">请求涨价</div>
|
||
|
<div
|
||
|
v-if="goodsinfo.orderMode == 2"
|
||
|
class="submit"
|
||
|
@click.stop="instantlyQuote(goodsinfo.otPrice, goodsinfo.orderNo)"
|
||
|
>
|
||
|
立即报价
|
||
|
</div>
|
||
|
<div v-else class="submit" @click.stop="submitEvent(goodsinfo.otPrice)">立即接单</div>
|
||
|
<!-- <div class="submit-tow" @click="markup()">请求涨价</div>
|
||
|
<div class="submit" @click.stop="instantlyQuote(goodsInfo.otPrice, goodsInfo.orderNo)">立即报价</div>
|
||
|
<div class="submit" @click.stop="submitEvent(goodsInfo.otPrice)">立即接单</div> -->
|
||
|
</template>
|
||
|
|
||
|
<script lang="ts" setup>
|
||
|
import { onMounted, reactive, ref, toRefs, watch, defineProps, onActivated } from 'vue'
|
||
|
import { useUserStore } from '@/stores/user'
|
||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
|
import { merchantOffers, verifyOffers,takeOrdersNow } from '@/server/orderApi'
|
||
|
const userStore = useUserStore()
|
||
|
// goodsInfo 'orderMode','orderNo'
|
||
|
const props = defineProps(['goodsinfo'])
|
||
|
// const orderMode = props.goodsInfo.orderMode
|
||
|
const goodsinfo = <any>ref({})
|
||
|
goodsinfo.value = props.goodsinfo
|
||
|
onMounted(() => {
|
||
|
goodsinfo.value = props.goodsinfo
|
||
|
console.log(userStore.$state.userInfos)
|
||
|
})
|
||
|
const instantlyQuote = async (monry: any, orderNo: any) => {
|
||
|
ElMessageBox.prompt('请输入金额', '报价', {
|
||
|
confirmButtonText: '确认',
|
||
|
cancelButtonText: '取消',
|
||
|
inputPattern: /^(?!$)(?=^[0-9]{1,6}$)(?!^0+$)^[1-9][0-9]{0,4}$|100000$/,
|
||
|
inputErrorMessage: '请输入正确的金额',
|
||
|
})
|
||
|
.then(({ value }) => {
|
||
|
if (value <= monry) {
|
||
|
return ElMessage({
|
||
|
type: 'error',
|
||
|
message: `涨价金额不能小于当前金额`,
|
||
|
})
|
||
|
}
|
||
|
const data: any = {
|
||
|
merId: userStore.$state.userInfos.merchantId,
|
||
|
offerAmount: value,
|
||
|
orderNo: orderNo,
|
||
|
}
|
||
|
console.log(data)
|
||
|
verifyOffersEvent(orderNo, userStore.$state.userInfos.merchantId)
|
||
|
.then((res: any) => {
|
||
|
console.log(res)
|
||
|
merchantOffers(data)
|
||
|
ElMessage({
|
||
|
type: 'success',
|
||
|
message: `请求成功`,
|
||
|
})
|
||
|
})
|
||
|
.catch((error: any) => {
|
||
|
ElMessage({
|
||
|
type: 'error',
|
||
|
message: `重复报价`,
|
||
|
})
|
||
|
console.log(error)
|
||
|
return
|
||
|
})
|
||
|
})
|
||
|
.catch(() => {
|
||
|
// ElMessage({
|
||
|
// type: 'info',
|
||
|
// message: 'Input canceled',
|
||
|
// })
|
||
|
})
|
||
|
}
|
||
|
const markup = () => {
|
||
|
console.log(props)
|
||
|
|
||
|
ElMessageBox.prompt('请输入金额', 'Tip', {
|
||
|
confirmButtonText: '确认',
|
||
|
cancelButtonText: '取消',
|
||
|
inputPattern: /^(?!$)(?=^[0-9]{1,6}$)(?!^0+$)^[1-9][0-9]{0,4}$|100000$/,
|
||
|
inputErrorMessage: '请输入正确的金额',
|
||
|
})
|
||
|
.then(({ value }) => {
|
||
|
const data: any = {
|
||
|
merId: userStore.$state.userInfos.merchantId,
|
||
|
offerAmount: value,
|
||
|
orderNo: goodsinfo.value.orderNo,
|
||
|
}
|
||
|
console.log(data)
|
||
|
verifyOffersEvent( goodsinfo.value.orderNo, userStore.$state.userInfos.merchantId)
|
||
|
.then((res: any) => {
|
||
|
console.log(res)
|
||
|
merchantOffers(data)
|
||
|
ElMessage({
|
||
|
type: 'success',
|
||
|
message: `请求成功`,
|
||
|
})
|
||
|
})
|
||
|
.catch((error: any) => {
|
||
|
ElMessage({
|
||
|
type: 'error',
|
||
|
message: `重复报价`,
|
||
|
})
|
||
|
console.log(error)
|
||
|
return
|
||
|
})
|
||
|
})
|
||
|
.catch(() => {
|
||
|
// ElMessage({
|
||
|
// type: 'info',
|
||
|
// message: 'Input canceled',
|
||
|
// })
|
||
|
})
|
||
|
}
|
||
|
const submitEvent = async (monry: any = null) => {
|
||
|
const data: any = {
|
||
|
merId: userStore.$state.userInfos.merchantId,
|
||
|
offerAmount: monry || goodsinfo.value.otPrice,
|
||
|
orderNo: goodsinfo.value.orderNo,
|
||
|
}
|
||
|
console.log(data)
|
||
|
// verifyOffersEvent(goodsinfo.value.orderNo, userStore.$state.userInfos.merchantId)
|
||
|
// .then((res: any) => {
|
||
|
// console.log(res)
|
||
|
// takeOrdersNow(data)
|
||
|
// ElMessage({
|
||
|
// type: 'success',
|
||
|
// message: `请求成功`,
|
||
|
// })
|
||
|
// })
|
||
|
// .catch((error: any) => {
|
||
|
// ElMessage({
|
||
|
// type: 'error',
|
||
|
// message: `重复报价`,
|
||
|
// })
|
||
|
// console.log(error)
|
||
|
// return
|
||
|
// })
|
||
|
takeOrdersNow(data).then((res:any) => {
|
||
|
console.log(res);
|
||
|
ElMessage({
|
||
|
type: 'success',
|
||
|
message: `请求成功`,
|
||
|
})
|
||
|
}).catch((error:any) => {
|
||
|
console.log(error);
|
||
|
// ElMessage({
|
||
|
// type: 'error',
|
||
|
// message: `重复报价`,
|
||
|
// })
|
||
|
})
|
||
|
}
|
||
|
const verifyOffersEvent = (orderNo: any, merId: any) => {
|
||
|
return new Promise(async (resolve, reject) => {
|
||
|
// 发起请求的代码
|
||
|
const response = await verifyOffers({ orderNo, merId })
|
||
|
console.log(response, 'response')
|
||
|
if (response) {
|
||
|
resolve('请求成功')
|
||
|
} else {
|
||
|
reject(new Error('请求失败'))
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style lang="scss" scoped>
|
||
|
.submit-tow {
|
||
|
width: 0.5833rem;
|
||
|
height: 0.1667rem;
|
||
|
color: #ff94d4;
|
||
|
margin: 0 10px;
|
||
|
text-align: center;
|
||
|
line-height: 0.1667rem;
|
||
|
border: 1px solid #ff94d4;
|
||
|
// background: linear-gradient(90deg, #ff94d4 0%, #ffddbe 100%);
|
||
|
cursor: pointer;
|
||
|
}
|
||
|
.submit {
|
||
|
width: 0.5833rem;
|
||
|
height: 0.1667rem;
|
||
|
color: #fff;
|
||
|
text-align: center;
|
||
|
line-height: 0.1667rem;
|
||
|
background: linear-gradient(90deg, #ff94d4 0%, #ffddbe 100%);
|
||
|
cursor: pointer;
|
||
|
}
|
||
|
</style>
|