对接完毕下单
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
</div>
|
||||
<div class="shop_operation">
|
||||
<div class="shop_list">
|
||||
<div class="item" :class="{ active: cartListActive == index }" v-for="(item, index) in cartList" :key="item.id"
|
||||
@click="selectCartItemHandle(item, index)">
|
||||
<div class="item" :class="{ active: cartListActive == index }" v-for="(item, index) in cartList"
|
||||
:key="item.id" @click="selectCartItemHandle(item, index)">
|
||||
<div class="name_wrap">
|
||||
<span>{{ item.name }}</span>
|
||||
<span>¥{{ item.salePrice }}</span>
|
||||
@@ -74,10 +74,14 @@
|
||||
<div class="btm">
|
||||
<el-button icon="Edit" @click="remarkRef.show()"></el-button>
|
||||
<div class="button">
|
||||
<el-button type="primary" style="width: 100%;" @click="settleAccountRef.show()">
|
||||
<el-button type="primary" style="width: 100%;" :disabled="!cartList.length" v-loading="createOrderLoading"
|
||||
@click="createOrderHandle">
|
||||
<div class="js">
|
||||
<el-text class="t">¥{{ cartInfo.totalAmount }}</el-text>
|
||||
<el-text class="t" style="margin-left: 250px;">结算</el-text>
|
||||
<el-text class="t" style="margin-left: 250px;">
|
||||
<span v-if="!createOrderLoading">结算</span>
|
||||
<span v-else>下单中...</span>
|
||||
</el-text>
|
||||
</div>
|
||||
</el-button>
|
||||
</div>
|
||||
@@ -90,15 +94,16 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- 备注 -->
|
||||
<remarkModal ref="remarkRef" />
|
||||
<remarkModal ref="remarkRef" @success="e => remark = e" />
|
||||
<!-- 修改取餐号 -->
|
||||
<takeFoodCode />
|
||||
<el-drawer v-model="membershow" :with-header="true" size="90%" title="选择会员" >
|
||||
<el-drawer v-model="membershow" :with-header="true" size="90%" title="选择会员">
|
||||
<member :membershow="1"></member>
|
||||
</el-drawer>
|
||||
<takeFoodCode ref="takeFoodCodeRef" title="修改取餐号" placeholder="请输入取餐号" @success="takeFoodCodeSuccess" />
|
||||
<!-- 结算订单 -->
|
||||
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="remark" />
|
||||
<settleAccount ref="settleAccountRef" :cart="cartList" :amount="cartInfo.totalAmount" :remark="remark"
|
||||
:orderId="orderId" :masterId="masterId" @paySuccess="createCodeAjax" />
|
||||
<!-- 挂起订单 -->
|
||||
<pendingCartModal ref="pendingCartModalRef" @select="pendingCartHandle" />
|
||||
</template>
|
||||
@@ -112,7 +117,7 @@ import cartOperation from '@/views/home/components/cartOperation.vue'
|
||||
import settleAccount from '@/views/home/components/settleAccount.vue'
|
||||
import pendingCartModal from '@/views/home/components/pendingCartModal.vue'
|
||||
|
||||
import { createCart, queryCart, createCode, packall, delCart, cartStatus, clearCart } from '@/api/product'
|
||||
import { createCart, queryCart, createCode, packall, delCart, cartStatus, clearCart, createOrder } from '@/api/product'
|
||||
|
||||
// 商品列表
|
||||
import goods from '@/views/home/components/goods.vue'
|
||||
@@ -132,11 +137,32 @@ const cartListActive = ref(0)
|
||||
const cartList = ref([])
|
||||
const cartInfo = ref({})
|
||||
|
||||
const orderId = ref('')
|
||||
const createOrderLoading = ref(false)
|
||||
|
||||
// 取餐码
|
||||
const masterId = ref('')
|
||||
// 挂单量
|
||||
const pendingCartNum = ref(0)
|
||||
|
||||
// 生成订单
|
||||
async function createOrderHandle() {
|
||||
try {
|
||||
createOrderLoading.value = true
|
||||
const res = await createOrder({
|
||||
masterId: masterId.value,
|
||||
shopId: store.userInfo.shopId,
|
||||
remark: remark.value
|
||||
})
|
||||
orderId.value = res
|
||||
settleAccountRef.value.show()
|
||||
createOrderLoading.value = false
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
createOrderLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 清空购物车
|
||||
async function clearCartHandle() {
|
||||
try {
|
||||
@@ -168,7 +194,8 @@ async function pendingCart(params, status = true) {
|
||||
await cartStatus({
|
||||
shopId: store.userInfo.shopId,
|
||||
masterId: params.masterId,
|
||||
status: status
|
||||
status: status,
|
||||
uuid: params.uuid
|
||||
})
|
||||
if (status && !cartList.value.length) createCodeAjax()
|
||||
} catch (error) {
|
||||
@@ -232,7 +259,7 @@ async function addCart(params, type = 'add') {
|
||||
})
|
||||
masterId.value = res
|
||||
goodsRef.value.updateData()
|
||||
queryCartAjax(type)
|
||||
queryCartAjax()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
@@ -258,8 +285,8 @@ async function queryCartAjax() {
|
||||
async function createCodeAjax() {
|
||||
try {
|
||||
const res = await createCode({ shopId: store.userInfo.shopId })
|
||||
// masterId.value = res.code
|
||||
masterId.value = '#51'
|
||||
masterId.value = res.code
|
||||
// masterId.value = '#13'
|
||||
queryCartAjax()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
|
||||
Reference in New Issue
Block a user