Commit ed107576 by Jony.L

订单相关提交01

parent 06a9e9bc
......@@ -47,6 +47,13 @@ export function orderBuy (query) {
})
}
export function bizOrderSubmit(query){
return request({
url: '/api/v1/bizOrderSubmit',
method: 'post',
data: query
})
}
// 确认订单回显数据
export function confirmOrderInfo (query) {
return request({
......
......@@ -66,21 +66,21 @@
<el-table-column prop="term" label="时长" sortable/>
<el-table-column label="操作" width="204px">
<template #default="{row}">
<el-button class="action-button" @click="selectedProduct(1,row.id)">加入购物车</el-button>
<el-button type="primary" class="action-button" @click="selectedProduct(2,row.id)">立即申请
<!-- <el-button class="action-button" @click="selectedProduct(1,row.id)">加入购物车</el-button>-->
<el-button type="primary" class="action-button" @click="selectedProduct(2,row.id)">立即购买
</el-button>
</template>
</el-table-column>
</el-table>
</div>
<!--卡片形式-->
<div v-if="showVersion === 2" class="version-2">
<el-row :gutter="24">
<el-col v-for="(item,index) in tableData" :key="index" :span="6">
<div class="product-card">
<div class="top-info">
<div class="title">{{ item.model }}</div>
<div class="title">{{item.term}}</div>
<div class="title">{{ item.term }}</div>
<div class="tag">
<!--<el-tag type="warning" effect="dark">性价比</el-tag>-->
<!--<el-tag type="info" effect="plain">专家推荐</el-tag>-->
......@@ -119,12 +119,12 @@
</el-col>
</el-row>
<el-divider></el-divider>
<div class="flex-justify-end price">¥{{ item.publicPrice }}{{item.unitTypeName}}</div>
<div class="flex-justify-end price">¥{{ item.publicPrice }}{{ item.unitTypeName }}</div>
<!--<div class="flex-justify-end month-expenses">约¥15/月</div>-->
<el-divider></el-divider>
<div class="footer-action flex">
<el-button class="action-button" @click="selectedProduct(1,item.id)">加入购物车</el-button>
<el-button type="primary" class="action-button" @click="selectedProduct(2,item.id)">立即申请
<!-- <el-button class="action-button" @click="selectedProduct(1,item.id)">加入购物车</el-button>-->
<el-button type="primary" class="action-button" @click="selectedProduct(2,item.id)">立即购买
</el-button>
</div>
</div>
......@@ -155,6 +155,7 @@
<div class="label">型号</div>
<div class="value">{{ productDetail.model }}</div>
</div>
</div>
<div class="info-block">
......@@ -242,9 +243,9 @@ import {
computilityMenu,
getRListByCategory,
getRDetail,
orderBuy,
// orderBuy,
shoppingAdd,
orderComputer
orderComputer, bizOrderSubmit
} from '@/api/computingResource.js'
import {useRoute, useRouter} from 'vue-router'
......@@ -306,41 +307,43 @@ function selectedProduct(type, id) {
selectedType.value = type
selectedId.value = id
getRDetail({id}).then(res => {
res.data.options.forEach(item => {
if ([0, 1, 4].includes(item.type)) {
item.value = item.options[0].id
}
if (item.type === 2) {
item.value = 1
}
})
// res.data.options.forEach(item => {
// if ([0, 1, 4].includes(item.type)) {
// item.value = item.options[0].id
// }
// if (item.type === 2) {
// item.value = 1
// }
// })
productDetail.value = res.data
orderComputerPrice()
// orderComputerPrice()
orderPrice.value=res.data.publicPrice;
showDrawer.value = true
})
}
function initSubmitData() {
return {
id: selectedId.value,
num: form.value.num,
computerItems: productDetail.value.options.map(item => {
if ([0, 1, 4].includes(item.type)) {
return {
id: item.id,
name: item.label,
valueId: item.value
}
}
return {
id: item.id,
name: item.label,
valueId: item.options[0].id,
value: item.value.toString()
}
})
}
}
// function initSubmitData() {
// return {
// id: selectedId.value,
// num: form.value.num,
// computerItems: productDetail.value.options.map(item => {
// if ([0, 1, 4].includes(item.type)) {
// return {
// id: item.id,
// name: item.label,
// valueId: item.value
// }
// }
// return {
// id: item.id,
// name: item.label,
// valueId: item.options[0].id,
// value: item.value.toString()
// }
// })
// }
// }
const orderPrice = ref(0)
......@@ -350,33 +353,78 @@ function orderComputerPrice() {
})
}
function getSubmitData(){
return{
skuId : selectedId.value,
}
}
function submit() {
const data = initSubmitData()
if (selectedType.value === 1) {
shoppingAdd(data).then(res => {
// 弹出确认对话框
ElMessageBox.confirm(
'添加到购物车成功',
'确定购买吗?', // 对话框提示文字
'购买确认', // 对话框标题
{
confirmButtonText: '去提交',
cancelButtonText: '关闭',
type: 'success'
}
).then(() => {
router.push('/computingResource/shoppingCart')
}).catch(() => {
})
confirmButtonText: '确认', // 确认按钮文字
cancelButtonText: '取消', // 取消按钮文字
type: 'warning' // 对话框类型(警告样式)
}
)
.then(() => {
// 用户点击“确认”时执行
// 1. 获取提交数据(复用之前的 initSubmitData 函数)
const submitData = getSubmitData();
// 2. 调用购买接口(此处用 TODO 标记实际接口逻辑)
// TODO: 实际接口调用代码,例如:
bizOrderSubmit(submitData).then(res => {
// 接口调用成功后的处理(如跳转订单页)
}).catch(err => {
// 接口调用失败的处理(如提示错误)
});
// 3. 关闭抽屉(如果需要)
showDrawer.value = false;
})
}
if (selectedType.value === 2) {
orderBuy(data).then(res => {
router.push({
path: '/computingResource/confirmOrder',
query: {id: res.data}
})
})
}
.catch(() => {
// 用户点击“取消”时执行(不做任何操作)
// console.log('用户取消购买');
// 可以添加取消后的提示(可选)
// ElMessage({
// type: 'info',
// message: '已取消购买'
// });
});
}
// function submit() {
// const data = initSubmitData()
// if (selectedType.value === 1) {
// shoppingAdd(data).then(res => {
// ElMessageBox.confirm(
// '添加到购物车成功',
// {
// confirmButtonText: '去提交',
// cancelButtonText: '关闭',
// type: 'success'
// }
// ).then(() => {
// router.push('/computingResource/shoppingCart')
// }).catch(() => {
// })
// })
//
// }
//
// if (selectedType.value === 2) {
// orderBuy(data).then(res => {
// router.push({
// path: '/computingResource/confirmOrder',
// query: {id: res.data}
// })
// })
// }
// }
</script>
<style scoped lang="scss">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment