|
|
@@ -1,17 +1,17 @@
|
|
|
<script setup lang="ts">
|
|
|
-import {useRouter} from "vue-router";
|
|
|
-import {ref, onMounted, computed} from "vue";
|
|
|
-import {addStock, getProductById} from "../../api/product.ts";
|
|
|
-import {Back, RefreshRight} from "@element-plus/icons-vue";
|
|
|
-import {ElTable} from "element-plus";
|
|
|
-import {calculateOrder, createOrder, payOrder} from "../../api/order.ts";
|
|
|
-import {getAvailableCouponsByStoreId} from "../../api/coupon.ts";
|
|
|
-import {getCommentsById} from "../../api/product.ts";
|
|
|
-import CommentItem from "../../components/CommentItem.vue";
|
|
|
-
|
|
|
-const router = useRouter();
|
|
|
+import {ref, onMounted, computed} from "vue"
|
|
|
+import {router} from '../../router'
|
|
|
+import {Back, RefreshRight} from "@element-plus/icons-vue"
|
|
|
+import {ElTable} from "element-plus"
|
|
|
+import {addStock, getProductById} from "../../api/product.ts"
|
|
|
+import {calculateOrder, createOrder, payOrder} from "../../api/order.ts"
|
|
|
+import {getAvailableCouponsByStoreId} from "../../api/coupon.ts"
|
|
|
+import {getCommentsById} from "../../api/product.ts"
|
|
|
+import CommentItem from "../../components/CommentItem.vue"
|
|
|
+
|
|
|
const role = sessionStorage.getItem("role")
|
|
|
-const productId = router.currentRoute.value.params.productId;
|
|
|
+
|
|
|
+const productId = router.currentRoute.value.params.productId
|
|
|
const productVO = ref()
|
|
|
const storeId = ref(0)
|
|
|
const name = ref('')
|
|
|
@@ -37,23 +37,20 @@ const couponId = ref(0)
|
|
|
const addStockNumber = ref('')
|
|
|
|
|
|
const hasTypeInput = computed(() => type.value != null)
|
|
|
-const hasAddStockInput = computed(() => addStockNumber.value != '')
|
|
|
-
|
|
|
const amountLegal = computed(() => amount.value <= stock.value)
|
|
|
-
|
|
|
const createOrderDisabled = computed(() => {
|
|
|
- return !(amountLegal.value && hasTypeInput.value);
|
|
|
+ return !(amountLegal.value && hasTypeInput.value)
|
|
|
})
|
|
|
|
|
|
+const hasAddStockInput = computed(() => addStockNumber.value != '')
|
|
|
const addStockDisabled = computed(() => {
|
|
|
- return !(hasAddStockInput.value);
|
|
|
+ return !(hasAddStockInput.value)
|
|
|
})
|
|
|
|
|
|
const commentList = ref([])
|
|
|
|
|
|
getCommentsById(productId).then(res => {
|
|
|
commentList.value = res.result
|
|
|
- console.log(res)
|
|
|
})
|
|
|
|
|
|
getProductDetail()
|
|
|
@@ -75,24 +72,7 @@ function getProductDetail() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function parseCategory(category) {
|
|
|
- if (category === 'FOOD') {
|
|
|
- return "食品"
|
|
|
- } else if (category === 'CLOTHES') {
|
|
|
- return "服饰"
|
|
|
- } else if (category === 'FURNITURE') {
|
|
|
- return "家具"
|
|
|
- } else if (category === 'ELECTRONICS') {
|
|
|
- return "电子产品"
|
|
|
- } else if (category === 'ENTERTAINMENT') {
|
|
|
- return "娱乐"
|
|
|
- } else if (category === 'SPORTS') {
|
|
|
- return "体育产品"
|
|
|
- } else if (category === 'LUXURY') {
|
|
|
- return "奢侈品"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
+// 添加库存按钮
|
|
|
function AddStock() {
|
|
|
addStock(productId, addStockNumber.value).then(res => {
|
|
|
if (res.code === '000') {
|
|
|
@@ -113,12 +93,13 @@ function AddStock() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// 创建订单按钮
|
|
|
function handleCreateOrder() {
|
|
|
const payload = {
|
|
|
productId: productId,
|
|
|
amount: amount.value,
|
|
|
type: type.value
|
|
|
- };
|
|
|
+ }
|
|
|
createOrder(payload).then(res => {
|
|
|
if (res.code === '000') {
|
|
|
ElMessage({
|
|
|
@@ -140,10 +121,11 @@ function handleCreateOrder() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-const showForm = ref(false);
|
|
|
+const showForm = ref(false)
|
|
|
const isLoading = ref(false)
|
|
|
const refreshButtonVisible = ref(false)
|
|
|
|
|
|
+// 确定订单按钮
|
|
|
function handleConfirmOrder() {
|
|
|
payOrder(orderId.value, couponId.value).then(res => {
|
|
|
if (res.code === '000') {
|
|
|
@@ -154,10 +136,10 @@ function handleConfirmOrder() {
|
|
|
})
|
|
|
isLoading.value = true
|
|
|
refreshButtonVisible.value = true
|
|
|
- const paymentWindow = window.open('', '_blank');
|
|
|
- paymentWindow.document.write(res.result);
|
|
|
- paymentWindow.document.forms[0].submit(); // 提交表单
|
|
|
- showForm.value = false; // 隐藏表单
|
|
|
+ const paymentWindow = window.open('', '_blank')
|
|
|
+ paymentWindow.document.write(res.result)
|
|
|
+ paymentWindow.document.forms[0].submit() // 提交表单
|
|
|
+ showForm.value = false // 隐藏表单
|
|
|
} else if (res.code === '400') {
|
|
|
ElMessage({
|
|
|
message: res.msg,
|
|
|
@@ -169,7 +151,7 @@ function handleConfirmOrder() {
|
|
|
}
|
|
|
|
|
|
function refreshPage() {
|
|
|
- location.reload();
|
|
|
+ location.reload()
|
|
|
}
|
|
|
|
|
|
function handlePayDialogClose() {
|
|
|
@@ -180,32 +162,8 @@ function handlePayDialogClose() {
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
- showForm.value = true; // 组件加载后显示表单
|
|
|
-});
|
|
|
-
|
|
|
-function parseOrderType(type) {
|
|
|
- if (type === "PICKUP") {
|
|
|
- return "到店自提"
|
|
|
- } else if (type === "DELIVERY") {
|
|
|
- return "快递到家"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function parseCouponType(type) {
|
|
|
- if (type === "FULL_REDUCTION") {
|
|
|
- return "满减"
|
|
|
- } else if (type === "SPECIAL") {
|
|
|
- return "折扣"
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function parseNull(value) {
|
|
|
- if (value === null) {
|
|
|
- return "/"
|
|
|
- } else {
|
|
|
- return value
|
|
|
- }
|
|
|
-}
|
|
|
+ showForm.value = true // 组件加载后显示表单
|
|
|
+})
|
|
|
|
|
|
// 处理优惠券
|
|
|
interface Coupon {
|
|
|
@@ -242,11 +200,54 @@ const handleCurrentChange = (val: Coupon | undefined) => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+function parseCategory(category) {
|
|
|
+ if (category === 'FOOD') {
|
|
|
+ return "食品"
|
|
|
+ } else if (category === 'CLOTHES') {
|
|
|
+ return "服饰"
|
|
|
+ } else if (category === 'FURNITURE') {
|
|
|
+ return "家具"
|
|
|
+ } else if (category === 'ELECTRONICS') {
|
|
|
+ return "电子产品"
|
|
|
+ } else if (category === 'ENTERTAINMENT') {
|
|
|
+ return "娱乐"
|
|
|
+ } else if (category === 'SPORTS') {
|
|
|
+ return "体育产品"
|
|
|
+ } else if (category === 'LUXURY') {
|
|
|
+ return "奢侈品"
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function parseOrderType(type) {
|
|
|
+ if (type === "PICKUP") {
|
|
|
+ return "到店自提"
|
|
|
+ } else if (type === "DELIVERY") {
|
|
|
+ return "快递到家"
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function parseCouponType(type) {
|
|
|
+ if (type === "FULL_REDUCTION") {
|
|
|
+ return "满减"
|
|
|
+ } else if (type === "SPECIAL") {
|
|
|
+ return "折扣"
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function parseNull(value) {
|
|
|
+ if (value === null) {
|
|
|
+ return "/"
|
|
|
+ } else {
|
|
|
+ return value
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function toBackPage() {
|
|
|
router.push("/storeDetail/" + storeId.value)
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
+
|
|
|
<template>
|
|
|
<el-container>
|
|
|
<el-aside width="25%" class="page-aside">
|
|
|
@@ -421,6 +422,7 @@ function toBackPage() {
|
|
|
</el-container>
|
|
|
</template>
|
|
|
|
|
|
+
|
|
|
<style scoped>
|
|
|
.page-aside {
|
|
|
border-right: lightgrey solid 1px;
|