对接购物车
This commit is contained in:
@@ -142,7 +142,7 @@
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref, computed, watch, reactive } from 'vue'
|
||||
import { queryPayType, accountPay, cashPay, vipPay, buyerPage, payCreditPay } from '@/api/pay'
|
||||
import { queryPayType, accountPay, vipPay, buyerPage, payCreditPay } from '@/api/pay'
|
||||
import { queryMembermember, createMembermember, membermemberScanPay, accountPaymember } from '@/api/member/index.js'
|
||||
import { useUser } from "@/store/user.js"
|
||||
import { clearNoNum, formatDecimal } from '@/utils'
|
||||
@@ -151,7 +151,11 @@ import scanModal from '@/components/payCard/scanModal.vue'
|
||||
import { ElMessage } from "element-plus";
|
||||
import { useGlobal } from '@/store/global.js'
|
||||
import { staffPermission } from '@/api/user.js'
|
||||
import { fa } from 'element-plus/es/locale/index.mjs'
|
||||
import { cashPay } from '@/api/order.js'
|
||||
|
||||
import { useGoods } from '@/store/goods.js'
|
||||
|
||||
const goodsStore = useGoods()
|
||||
|
||||
const global = useGlobal()
|
||||
|
||||
@@ -304,6 +308,31 @@ async function payTypeChange(index, item) {
|
||||
// 结算支付
|
||||
async function confirmOrder() {
|
||||
try {
|
||||
payLoading.value = true
|
||||
// 暂时使用现金支付
|
||||
await cashPay({
|
||||
shopId: store.shopInfo.id,
|
||||
checkOrderPay: {
|
||||
orderId: goodsStore.orderInfo.id,
|
||||
userId: '',
|
||||
seatNum: 0, // 用餐人数
|
||||
originAmount: goodsStore.orderInfo.originAmount, // 订单原金额(包含打包费+餐位费) 不含折扣价格
|
||||
discountRatio: 1, // 折扣比例(计算时 向上取整保留 两位小数)
|
||||
discountAmount: 0, // 手动优惠金额
|
||||
productCouponDiscountAmount: 0, // 商品优惠券抵扣金额
|
||||
fullCouponDiscountAmount: 0, // 满减优惠券抵扣金额
|
||||
couponList: [], // 用户使用的卡券
|
||||
orderAmount: goodsStore.orderInfo.originAmount, // 订单金额
|
||||
roundAmount: 0, // 抹零金额 减免多少钱
|
||||
pointsDiscountAmount: 0, // 积分抵扣金额(tb_points_basic_setting表)
|
||||
pointsNum: 0 // 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
|
||||
}
|
||||
})
|
||||
|
||||
payLoading.value = false
|
||||
ElMessage.success('支付成功')
|
||||
emit('paySuccess')
|
||||
return
|
||||
await staffPermission('yun_xu_shou_kuan')
|
||||
if (payLoading.value) return
|
||||
if (payActive.value == 'buyer') {
|
||||
@@ -477,7 +506,7 @@ function cancelDiscount() {
|
||||
|
||||
onMounted(() => {
|
||||
money.value = `${formatDecimal(props.amount)}`
|
||||
queryPayTypeAjax()
|
||||
// queryPayTypeAjax()
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
94
src/components/selectVipUser.vue
Normal file
94
src/components/selectVipUser.vue
Normal file
@@ -0,0 +1,94 @@
|
||||
<template>
|
||||
<el-dialog :title="`选择会员`" top="3vh" v-model="showDialog" width="80%">
|
||||
<el-form inline>
|
||||
<el-form-item>
|
||||
<el-input placeholder="请输入手机号搜索会员" v-model="tableData.phone" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="getMemberList">搜索</el-button>
|
||||
<el-button @click="resetTable">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table :data="tableData.list" height="440px" border stripe v-loading="tableData.loading">
|
||||
<el-table-column prop="nickName" label="昵称" width="120px" />
|
||||
<el-table-column prop="phone" label="手机" width="150px" />
|
||||
<el-table-column prop="code" label="编号" width="120px" />
|
||||
<el-table-column prop="level" label="等级" />
|
||||
<el-table-column prop="accountPoints" label="积分" />
|
||||
<el-table-column prop="amount" label="余额" width="100px">
|
||||
<template v-slot="scope">
|
||||
¥{{ formatDecimal(scope.row.amount) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120px">
|
||||
<template v-slot="scope">
|
||||
<el-button type="primary" @click="toHomeMember(scope.row)">选择</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px;"
|
||||
:total="Number(tableData.total)" v-model:current-page="tableData.page" @current-change="getMemberList" />
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import { shopUserList } from "@/api/account.js";
|
||||
|
||||
const showDialog = ref(false)
|
||||
const tableData = reactive({
|
||||
phone: '',
|
||||
loading: false,
|
||||
list: [],
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0
|
||||
})
|
||||
|
||||
|
||||
// 选择会员去下单
|
||||
async function toHomeMember(row) {
|
||||
try {
|
||||
console.log(row);
|
||||
// 选择会员后的操作
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
showDialog.value = false
|
||||
}
|
||||
|
||||
// 重置表格
|
||||
function resetTable() {
|
||||
tableData.phone = ''
|
||||
tableData.page = 1
|
||||
getMemberList()
|
||||
}
|
||||
|
||||
// 获取会员列表
|
||||
async function getMemberList() {
|
||||
try {
|
||||
tableData.loading = true
|
||||
const res = await shopUserList({
|
||||
key: tableData.phone,
|
||||
isVips: 1,
|
||||
page: tableData.page,
|
||||
size: tableData.size
|
||||
})
|
||||
tableData.list = res.records
|
||||
tableData.total = res.totalRow
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
tableData.loading = false
|
||||
}
|
||||
|
||||
// 显示选择会员弹窗
|
||||
function show() {
|
||||
showDialog.value = true
|
||||
getMemberList()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
show
|
||||
})
|
||||
</script>
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class="footer">
|
||||
<div class="info">
|
||||
<template v-if="goodsInfo.id">
|
||||
<span>库存:{{ goodsInfo.stockNumber }}</span>
|
||||
<!-- <span>库存:{{ goodsInfo.stockNumber }}</span> -->
|
||||
<span>¥{{ goodsInfo.salePrice }}</span>
|
||||
</template>
|
||||
</div>
|
||||
@@ -34,10 +34,6 @@
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { useUser } from "@/store/user.js"
|
||||
import { queryProductSku } from '@/api/product'
|
||||
|
||||
const store = useUser();
|
||||
const emit = defineEmits(['success'])
|
||||
|
||||
const type = ref('shop')
|
||||
@@ -56,16 +52,16 @@ const selecSkuArray = ref([])
|
||||
// 确认选择规格
|
||||
function submitSku() {
|
||||
dialogVisible.value = false
|
||||
switch (type.value) {
|
||||
case 'shop':
|
||||
emit('success', goodsInfo.value)
|
||||
break;
|
||||
case 'cart':
|
||||
emit('success', goods.value)
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// switch (type.value) {
|
||||
// case 'shop':
|
||||
// break;
|
||||
// case 'cart':
|
||||
// emit('success', goodsInfo.value)
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
emit('success', goodsInfo.value)
|
||||
}
|
||||
|
||||
// 选择规格
|
||||
@@ -100,11 +96,11 @@ function selectedSku(index = 0, i = 0) {
|
||||
})
|
||||
|
||||
goods.value.selectSpec[index + 1].selectSpecResult.map(item => {
|
||||
goods.value.groundingSpecInfo.map(val => {
|
||||
goods.value.skuList.map(val => {
|
||||
// console.log(val);
|
||||
// console.log(`${selecSkuArray.value.join(',')},${item.name}`);
|
||||
// console.log(val.specSnap.indexOf(`${selecSkuArray.value.join(',')},${item.name}`));
|
||||
if (val.specSnap.indexOf(`${selecSkuArray.value.join(',')},${item.name}`) != -1 && val.isGrounding) {
|
||||
// console.log(val.specInfo.indexOf(`${selecSkuArray.value.join(',')},${item.name}`));
|
||||
if (val.specInfo.indexOf(`${selecSkuArray.value.join(',')},${item.name}`) != -1 && val.isGrounding) {
|
||||
item.disabled = false
|
||||
}
|
||||
})
|
||||
@@ -147,80 +143,62 @@ function selectedSuccess() {
|
||||
|
||||
// 通过选中的商品规格查询价格
|
||||
async function queryProductSkuAjax() {
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await queryProductSku({
|
||||
shopId: store.userInfo.shopId,
|
||||
productId: type.value == 'shop' ? goods.value.id : goods.value.productId,
|
||||
spec_tag: selectedSkuTag.value
|
||||
})
|
||||
goodsInfo.value = res
|
||||
if (type.value == 'cart') {
|
||||
goods.value.skuId = res.id
|
||||
goods.value.skuList.map(item => {
|
||||
if (item.specInfo == selectedSkuTag.value) {
|
||||
goodsInfo.value = item
|
||||
}
|
||||
setTimeout(() => {
|
||||
loading.value = false
|
||||
}, 100)
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
console.log(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 显示规格
|
||||
function show(item, t = 'shop') {
|
||||
type.value = t
|
||||
let arr = []
|
||||
for (let val in item.selectSpecInfo) {
|
||||
if (item.selectSpecInfo[val].length) {
|
||||
|
||||
switch (type.value) {
|
||||
case 'shop':
|
||||
arr.push({
|
||||
name: val,
|
||||
selectSpecResult: item.selectSpecInfo[val].map(item => {
|
||||
return {
|
||||
active: false,
|
||||
name: item,
|
||||
disabled: false
|
||||
}
|
||||
})
|
||||
})
|
||||
break;
|
||||
case 'cart':
|
||||
// 如果从购物车选择规格需要做选中效果
|
||||
const skus = item.sku_name.split(',')
|
||||
arr.push({
|
||||
name: val,
|
||||
selectSpecResult: item.selectSpecInfo[val].map(item => {
|
||||
return {
|
||||
active: !!skus.find(val => val === item),
|
||||
name: item,
|
||||
disabled: false
|
||||
}
|
||||
})
|
||||
})
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item.selectSpec = arr
|
||||
|
||||
// 赋值新的规格数据
|
||||
goodsInfo.value = {}
|
||||
goods.value = {}
|
||||
selectedSkuNum.value = 0
|
||||
dialogVisible.value = true
|
||||
goods.value = ""
|
||||
goods.value = item
|
||||
type.value = t
|
||||
goods.value.selectSpec = JSON.parse(goods.value.selectSpec)
|
||||
goods.value.selectSpec.map((item, index) => {
|
||||
let arr = []
|
||||
item.selectSpecResult.map(val => {
|
||||
switch (type.value) {
|
||||
case 'shop':
|
||||
let disabled = true
|
||||
if (index == 0) {
|
||||
goods.value.groundingSpecInfo.map(item => {
|
||||
if (item.specSnap.indexOf(val) != -1 && item.isGrounding) {
|
||||
disabled = false
|
||||
}
|
||||
})
|
||||
}
|
||||
arr.push({
|
||||
active: false,
|
||||
name: val,
|
||||
disabled: index == 0 ? disabled : true
|
||||
})
|
||||
break;
|
||||
case 'cart':
|
||||
// 如果从购物车选择规格需要做选中效果
|
||||
const skus = goods.value.skuName.split(',')
|
||||
arr.push({
|
||||
active: !!skus.find(item => item === val),
|
||||
name: val,
|
||||
disabled: true
|
||||
})
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
})
|
||||
item.selectSpecResult = arr
|
||||
})
|
||||
|
||||
let arr = []
|
||||
|
||||
goods.value.selectSpec.map(item => {
|
||||
if (item.selectSpecResult.length) {
|
||||
arr.push({ ...item })
|
||||
}
|
||||
})
|
||||
|
||||
goods.value.selectSpec = arr
|
||||
|
||||
selectedSuccess()
|
||||
}
|
||||
|
||||
@@ -86,9 +86,9 @@ async function uplaodHandle() {
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (store.userInfo) {
|
||||
findVersionAjax()
|
||||
}
|
||||
// if (store.userInfo) {
|
||||
// findVersionAjax()
|
||||
// }
|
||||
ipcRenderer.on('updateProgress', (event, res) => {
|
||||
uploadPro.value = res
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user