新增抖音团购券核销

This commit is contained in:
gyq
2024-07-17 18:02:01 +08:00
parent aa25c6be3b
commit c155e8a805
13 changed files with 257 additions and 48 deletions

View File

@@ -0,0 +1,104 @@
<template>
<el-dialog title="绑定门店" v-model="showDialog" width="80%">
<div class="dialog">
<div class="tips">注意门店绑定后无法更改请谨慎选择</div>
<el-table :data="tableData.list" height="240px" border v-loading="tableData.loading">
<el-table-column label="门店名称" prop="poi_name"></el-table-column>
<el-table-column label="门店地址" prop="address"></el-table-column>
<el-table-column label="操作" width="120px">
<template v-slot="scope">
<el-button type="primary" size="small"
@click="bindShopHandle(scope.row.poi_id)">选择门店</el-button>
</template>
</el-table-column>
</el-table>
<div class="pagination">
<el-pagination @current-change="paginationChange" :current-page="tableData.page"
:page-size="tableData.size" layout="total, prev, pager, next, jumper" :total="tableData.total"
background>
</el-pagination>
</div>
</div>
</el-dialog>
</template>
<script setup>
import { ElMessage } from 'element-plus'
import { onMounted, reactive, ref } from 'vue';
import { douyinstorelist, douyinbindstore } from '@/api/group.js'
const emits = defineEmits(['success'])
const showDialog = ref(false)
const tableData = reactive({
page: 1,
size: 10,
total: 0,
loading: false,
list: []
})
// 绑定门店
async function bindShopHandle(poi_id) {
try {
await douyinbindstore({
poi_id: poi_id
})
showDialog.value = false
ElMessage.success('绑定成功')
emits('success')
} catch (error) {
console.log(error);
}
}
// 分页变化
function paginationChange(e) {
tableData.page = e
getTableData()
}
// 获取门店列表
async function getTableData() {
try {
tableData.loading = true
const { list, count } = await douyinstorelist({
page: tableData.page,
size: tableData.size
})
tableData.loading = false
tableData.list = list
tableData.total = count
} catch (error) {
console.log(error);
}
}
// 显示
function show() {
showDialog.value = true;
getTableData()
}
defineExpose({
show
})
</script>
<style scoped lang="scss">
.tips {
color: var(--el-color-danger);
padding-bottom: 14px;
}
.pagination {
display: flex;
padding: 0 14px;
margin-top: 14px;
}
.dialog {
padding: 14px;
}
</style>

View File

@@ -2,7 +2,7 @@
<template>
<div class="dialog">
<el-dialog :title="`核销${props.title}团购券`" width="600" v-model="dialogVisible" @open="reset">
<el-dialog :title="`核销${props.title}团购券`" width="600" v-model="dialogVisible" @open="reset" @close="close">
<div class="content">
<div class="left">
<el-image :src="icon" style="width: 60px; height: 60px"></el-image>
@@ -79,8 +79,7 @@
</template>
</el-table-column>
</el-table>
<el-table ref="douyin_table" :data="groupDetail.goods" border v-if="props.type == 2"
@selection-change="douyinSelectionChange">
<el-table ref="douyin_table" :data="groupDetail.goods" border v-if="props.type == 2">
<el-table-column type="selection" width="55" />
<el-table-column label="名称" prop="title"></el-table-column>
<el-table-column label="价格" prop="amount"></el-table-column>
@@ -93,6 +92,7 @@
@click="groupOrdergroupScanHandle">确认核销</el-button>
</div>
</el-dialog>
<BindShop ref="BindShopRef" @success="submitHandle()" />
</div>
</template>
@@ -102,6 +102,8 @@ import { ref } from "vue";
import icon from "@/assets/icon_scan.png";
import { groupOrderorderInfo, groupOrdergroupScan, douyinfulfilmentcertificateprepare, douyincertificateprepare } from '@/api/group'
import { useUser } from "@/store/user.js";
import BindShop from './bindShop.vue'
const BindShopRef = ref(null)
const store = useUser();
import {
queryMembermember,
@@ -110,6 +112,10 @@ import {
accountPaymember,
} from "@/api/member/index.js";
import { ElMessage } from "element-plus";
import { useGlobal } from '@/store/global.js'
const global = useGlobal()
const emits = defineEmits(["success"]);
const props = defineProps({
@@ -152,7 +158,8 @@ async function groupOrdergroupScanHandle() {
case 2:
{
groupDetailLoading.value = true
let encrypted_codes = groupDetail.value.goods.map(item => item.encrypted_code)
let encrypted_codes = douyin_table.value.getSelectionRows().map(item => item.encrypted_code)
console.log(encrypted_codes);
const res = await douyincertificateprepare({
verify_token: groupDetail.value.verify_token,
encrypted_codes: encrypted_codes.join(','),
@@ -171,17 +178,12 @@ async function groupOrdergroupScanHandle() {
emits('succcess')
} catch (error) {
groupDetailLoading.value = false
console.log(error);
console.log('groupOrdergroupScanHandle.error', error);
}
}
const douyin_table = ref(null)
// 选择要核销的券
function douyinSelectionChange(e) {
console.log(e);
}
// 核销券码
async function submitHandle() {
try {
@@ -202,6 +204,7 @@ async function submitHandle() {
const res = await douyinfulfilmentcertificateprepare({
object_id: decodeURI(scanCode.value),
});
dialogVisible.value = false
loading.value = false
groupDetail.value = res
detailVisible.value = true
@@ -217,7 +220,10 @@ async function submitHandle() {
}
} catch (error) {
loading.value = false
console.log(error);
console.log('submitHandle.error', error);
if (error.code == 4399) {
BindShopRef.value.show()
}
}
}
@@ -255,6 +261,7 @@ const inputChange = _.debounce(function (e) {
}, 500);
function show() {
global.updateData(true)
dialogVisible.value = true;
setTimeout(() => {
inputRef.value.focus();
@@ -262,6 +269,7 @@ function show() {
}
function close() {
global.updateData(false)
dialogVisible.value = false;
}
@@ -274,6 +282,7 @@ defineExpose({
show,
close,
loading,
submitHandle
});
</script>