Commit 882e1f00 by zhangzhen

美团授权功能开发

parent 74494150
......@@ -5,7 +5,7 @@ VUE_APP_TITLE = 凑角管理系统
ENV = 'development'
# 凑角管理系统/开发环境
VUE_APP_BASE_API = '/dev-api'
VUE_APP_BASE_API = '/prod-api'
# 路由懒加载
VUE_CLI_BABEL_TRANSPILE_MODULES = true
......@@ -42,3 +42,17 @@ export function delConsumerCoupon(id) {
method: 'delete'
})
}
export function getAppKey() {
return request({
url: '/common/appKey',
method: 'get'
})
}
export function oauthToken(code) {
return request({
url: `/chessCards/oauthToken?authCode=${code}`,
method: 'get'
})
}
......@@ -83,26 +83,29 @@
</el-form-item>
<el-form-item label="有效期开始" prop="startDate">
<el-date-picker clearable
v-model="queryParams.startDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择有效期开始">
v-model="queryParams.startDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择有效期开始"
>
</el-date-picker>
</el-form-item>
<el-form-item label="有效期结束" prop="endDate">
<el-date-picker clearable
v-model="queryParams.endDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择有效期结束">
v-model="queryParams.endDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择有效期结束"
>
</el-date-picker>
</el-form-item>
<el-form-item label="使用时间" prop="useDate">
<el-date-picker clearable
v-model="queryParams.useDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择使用时间">
v-model="queryParams.useDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择使用时间"
>
</el-date-picker>
</el-form-item>
<el-form-item label="删除状态" prop="isDelete">
......@@ -123,10 +126,11 @@
</el-form-item>
<el-form-item label="更新时间" prop="deleteTime">
<el-date-picker clearable
v-model="queryParams.deleteTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择更新时间">
v-model="queryParams.deleteTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择更新时间"
>
</el-date-picker>
</el-form-item>
<el-form-item>
......@@ -136,27 +140,26 @@
</el-form>
<el-row :gutter="10" class="mb8">
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="primary"-->
<!-- plain-->
<!-- icon="el-icon-plus"-->
<!-- size="mini"-->
<!-- @click="handleAdd"-->
<!-- v-hasPermi="['system:consumerCoupon:add']"-->
<!-- >新增</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="success"-->
<!-- plain-->
<!-- icon="el-icon-edit"-->
<!-- size="mini"-->
<!-- :disabled="single"-->
<!-- @click="handleUpdate"-->
<!-- v-hasPermi="['system:consumerCoupon:edit']"-->
<!-- >修改</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="primary"-->
<!-- plain-->
<!-- icon="el-icon-plus"-->
<!-- size="mini"-->
<!-- @click="handleAdd"-->
<!-- v-hasPermi="['system:consumerCoupon:add']"-->
<!-- >新增</el-button>-->
<!-- </el-col>-->
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
@click="onEmpower"
>美团授权
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
......@@ -166,7 +169,8 @@
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:consumerCoupon:remove']"
>删除</el-button>
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
......@@ -176,39 +180,42 @@
size="mini"
@click="handleExport"
v-hasPermi="['system:consumerCoupon:export']"
>导出</el-button>
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="consumerCouponList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="ID" align="center" prop="id" />
<el-table-column label="用户ID" align="center" prop="consumerId" />
<el-table-column label="优惠券ID" align="center" prop="couponId" />
<el-table-column label="优惠券编码" align="center" prop="couponCode" />
<el-table-column label="优惠券名称" align="center" prop="name" width="240px" />
<!-- <el-table-column label="优惠房型" align="center" prop="roomType" />-->
<el-table-column label="优惠房型" align="center" prop="roomType" width="240px" >
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="ID" align="center" prop="id"/>
<el-table-column label="用户ID" align="center" prop="consumerId"/>
<el-table-column label="优惠券ID" align="center" prop="couponId"/>
<el-table-column label="优惠券编码" align="center" prop="couponCode"/>
<el-table-column label="优惠券名称" align="center" prop="name" width="240px"/>
<!-- <el-table-column label="优惠房型" align="center" prop="roomType" />-->
<el-table-column label="优惠房型" align="center" prop="roomType" width="240px">
<template slot-scope="scope">
<div v-if="scope.row.roomType.length" style="display: flex;flex-wrap: wrap;width: 100%;">
<dict-tag style="margin: 0 3px;" v-for="(item ,k) in scope.row.roomType" :key="k" :options="dict.type.store_room_type" :value="item"/>
<dict-tag style="margin: 0 3px;" v-for="(item ,k) in scope.row.roomType" :key="k"
:options="dict.type.store_room_type" :value="item"
/>
</div>
</template>
</el-table-column>
<el-table-column label="优惠开始" align="center" prop="couponTimeStart" />
<el-table-column label="优惠结束" align="center" prop="couponTimeEnd" />
<!-- <el-table-column label="优惠券类型" align="center" prop="couponType" />-->
<el-table-column label="优惠开始" align="center" prop="couponTimeStart"/>
<el-table-column label="优惠结束" align="center" prop="couponTimeEnd"/>
<!-- <el-table-column label="优惠券类型" align="center" prop="couponType" />-->
<el-table-column label="优惠券类型" align="center" prop="couponType">
<template slot-scope="scope">
<dict-tag :options="dict.type.store_coupon_type" :value="scope.row.couponType"/>
</template>
</el-table-column>
<el-table-column label="折扣最大时长" align="center" prop="maxDuration" />
<el-table-column label="时长" align="center" prop="duration" />
<el-table-column label="门槛金额" align="center" prop="minPrice" />
<el-table-column label="减去金额" align="center" prop="subPrice" />
<!-- <el-table-column label="优惠券来源" align="center" prop="sourceType" />-->
<el-table-column label="折扣最大时长" align="center" prop="maxDuration"/>
<el-table-column label="时长" align="center" prop="duration"/>
<el-table-column label="门槛金额" align="center" prop="minPrice"/>
<el-table-column label="减去金额" align="center" prop="subPrice"/>
<!-- <el-table-column label="优惠券来源" align="center" prop="sourceType" />-->
<el-table-column label="优惠券来源" align="center" prop="sourceType">
<template slot-scope="scope">
<dict-tag :options="dict.type.consumer_coupon_source_type" :value="scope.row.sourceType"/>
......@@ -235,35 +242,36 @@
<span>{{ parseTime(scope.row.useDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="使用状态" align="center" prop="useStatus" />-->
<!-- <el-table-column label="使用状态" align="center" prop="useStatus" />-->
<el-table-column label="使用状态" align="center" prop="useStatus">
<template slot-scope="scope">
<dict-tag :options="dict.type.coupon_use_status" :value="scope.row.useStatus"/>
</template>
</el-table-column>
<el-table-column label="更新者" align="center" prop="deleteBy" />
<el-table-column label="更新者" align="center" prop="deleteBy"/>
<el-table-column label="更新时间" align="center" prop="deleteTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.deleteTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="备注" align="center" prop="remark"/>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-edit"-->
<!-- @click="handleUpdate(scope.row)"-->
<!-- v-hasPermi="['system:consumerCoupon:edit']"-->
<!-- >修改</el-button>-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-edit"-->
<!-- @click="handleUpdate(scope.row)"-->
<!-- v-hasPermi="['system:consumerCoupon:edit']"-->
<!-- >修改</el-button>-->
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:consumerCoupon:remove']"
>删除</el-button>
>删除
</el-button>
</template>
</el-table-column>
</el-table>
......@@ -280,75 +288,79 @@
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="用户ID" prop="consumerId">
<el-input v-model="form.consumerId" placeholder="请输入用户ID" />
<el-input v-model="form.consumerId" placeholder="请输入用户ID"/>
</el-form-item>
<el-form-item label="优惠券ID" prop="couponId">
<el-input v-model="form.couponId" placeholder="请输入优惠券ID" />
<el-input v-model="form.couponId" placeholder="请输入优惠券ID"/>
</el-form-item>
<el-form-item label="优惠券编码" prop="couponCode">
<el-input v-model="form.couponCode" placeholder="请输入优惠券编码" />
<el-input v-model="form.couponCode" placeholder="请输入优惠券编码"/>
</el-form-item>
<el-form-item label="优惠券名称" prop="name">
<el-input v-model="form.name" placeholder="请输入优惠券名称" />
<el-input v-model="form.name" placeholder="请输入优惠券名称"/>
</el-form-item>
<el-form-item label="优惠开始" prop="couponTimeStart">
<el-input v-model="form.couponTimeStart" placeholder="请输入优惠开始" />
<el-input v-model="form.couponTimeStart" placeholder="请输入优惠开始"/>
</el-form-item>
<el-form-item label="优惠结束" prop="couponTimeEnd">
<el-input v-model="form.couponTimeEnd" placeholder="请输入优惠结束" />
<el-input v-model="form.couponTimeEnd" placeholder="请输入优惠结束"/>
</el-form-item>
<el-form-item label="折扣最大时长" prop="maxDuration">
<el-input v-model="form.maxDuration" placeholder="请输入折扣最大时长" />
<el-input v-model="form.maxDuration" placeholder="请输入折扣最大时长"/>
</el-form-item>
<el-form-item label="时长" prop="duration">
<el-input v-model="form.duration" placeholder="请输入时长" />
<el-input v-model="form.duration" placeholder="请输入时长"/>
</el-form-item>
<el-form-item label="门槛金额" prop="minPrice">
<el-input v-model="form.minPrice" placeholder="请输入门槛金额" />
<el-input v-model="form.minPrice" placeholder="请输入门槛金额"/>
</el-form-item>
<el-form-item label="减去金额(满减券单位:元,折扣为系数)" prop="subPrice">
<el-input v-model="form.subPrice" placeholder="请输入减去金额(满减券单位:元,折扣为系数)" />
<el-input v-model="form.subPrice" placeholder="请输入减去金额(满减券单位:元,折扣为系数)"/>
</el-form-item>
<el-form-item label="有效期开始" prop="startDate">
<el-date-picker clearable
v-model="form.startDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择有效期开始">
v-model="form.startDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择有效期开始"
>
</el-date-picker>
</el-form-item>
<el-form-item label="有效期结束" prop="endDate">
<el-date-picker clearable
v-model="form.endDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择有效期结束">
v-model="form.endDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择有效期结束"
>
</el-date-picker>
</el-form-item>
<el-form-item label="使用时间" prop="useDate">
<el-date-picker clearable
v-model="form.useDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择使用时间">
v-model="form.useDate"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择使用时间"
>
</el-date-picker>
</el-form-item>
<el-form-item label="删除状态(0:未删除,1:已删除)" prop="isDelete">
<el-input v-model="form.isDelete" placeholder="请输入删除状态(0:未删除,1:已删除)" />
<el-input v-model="form.isDelete" placeholder="请输入删除状态(0:未删除,1:已删除)"/>
</el-form-item>
<el-form-item label="更新者" prop="deleteBy">
<el-input v-model="form.deleteBy" placeholder="请输入更新者" />
<el-input v-model="form.deleteBy" placeholder="请输入更新者"/>
</el-form-item>
<el-form-item label="更新时间" prop="deleteTime">
<el-date-picker clearable
v-model="form.deleteTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择更新时间">
v-model="form.deleteTime"
type="date"
value-format="yyyy-MM-dd"
placeholder="请选择更新时间"
>
</el-date-picker>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
......@@ -356,15 +368,27 @@
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<el-dialog title="平台授权" :visible.sync="openEmpower" width="80%" append-to-body>
<iframe :src="src" frameborder="0" width="100%" height="700px"></iframe>
</el-dialog>
</div>
</template>
<script>
import { listConsumerCoupon, getConsumerCoupon, delConsumerCoupon, addConsumerCoupon, updateConsumerCoupon } from "@/api/system/consumerCoupon";
import {
listConsumerCoupon,
getConsumerCoupon,
delConsumerCoupon,
addConsumerCoupon,
updateConsumerCoupon,
getAppKey, oauthToken
} from '@/api/system/consumerCoupon'
import log from '@/views/monitor/job/log'
export default {
name: "ConsumerCoupon",
dicts: ['consumer_coupon_platform_type', 'store_coupon_type','consumer_coupon_source_type','store_room_type','coupon_use_status'],
name: 'ConsumerCoupon',
dicts: ['consumer_coupon_platform_type', 'store_coupon_type', 'consumer_coupon_source_type', 'store_room_type', 'coupon_use_status'],
data() {
return {
// 遮罩层
......@@ -382,7 +406,7 @@ export default {
// 优惠券领取记录表格数据
consumerCouponList: [],
// 弹出层标题
title: "",
title: '',
// 是否显示弹出层
open: false,
// 查询参数
......@@ -409,38 +433,49 @@ export default {
useStatus: null,
isDelete: null,
deleteBy: null,
deleteTime: null,
deleteTime: null
},
// 表单参数
form: {},
// 表单校验
rules: {
consumerId: [
{ required: true, message: "用户ID不能为空", trigger: "blur" }
{ required: true, message: '用户ID不能为空', trigger: 'blur' }
],
couponCode: [
{ required: true, message: "优惠券编码不能为空", trigger: "blur" }
],
}
};
{ required: true, message: '优惠券编码不能为空', trigger: 'blur' }
]
},
src:'',
openEmpower:false
}
},
created() {
this.getList();
this.getList()
},
mounted() {
window.addEventListener('message', (data) => {
this.openEmpower = false;
if(data.data.auth_code)
oauthToken(data.data.auth_code).then(res => {
this.$modal.msgSuccess('操作成功')
})
})
},
methods: {
/** 查询优惠券领取记录列表 */
getList() {
this.loading = true;
this.loading = true
listConsumerCoupon(this.queryParams).then(response => {
this.consumerCouponList = response.rows;
this.total = response.total;
this.loading = false;
});
this.consumerCouponList = response.rows
this.total = response.total
this.loading = false
})
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
this.open = false
this.reset()
},
// 表单重置
reset() {
......@@ -472,77 +507,101 @@ export default {
deleteBy: null,
deleteTime: null,
remark: null
};
this.resetForm("form");
}
this.resetForm('form')
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
this.resetForm('queryForm')
this.handleQuery()
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加优惠券领取记录";
this.reset()
this.open = true
this.title = '添加优惠券领取记录'
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
this.reset()
const id = row.id || this.ids
getConsumerCoupon(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改优惠券领取记录";
});
this.form = response.data
this.open = true
this.title = '修改优惠券领取记录'
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs['form'].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateConsumerCoupon(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
this.$modal.msgSuccess('修改成功')
this.open = false
this.getList()
})
} else {
addConsumerCoupon(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
this.$modal.msgSuccess('新增成功')
this.open = false
this.getList()
})
}
}
});
})
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
const ids = row.id || this.ids
this.$modal.confirm('是否确认删除优惠券领取记录编号为"' + ids + '"的数据项?').then(function() {
return delConsumerCoupon(ids);
return delConsumerCoupon(ids)
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
this.getList()
this.$modal.msgSuccess('删除成功')
}).catch(() => {
})
},
/** 导出按钮操作 */
handleExport() {
this.download('system/consumerCoupon/export', {
...this.queryParams
}, `consumerCoupon_${new Date().getTime()}.xlsx`)
},
// 美团授权逻辑
onEmpower() {
console.log(window.location.href)
let uri = window.location.href
let appKey = ''
getAppKey().then(res => {
appKey = res.appKey
let state = 'test'
let redirectUrl = encodeURIComponent(uri)
this.src = `https://e.dianping.com/dz-open/merchant/auth?app_key=${appKey}&state=${state}`
this.openEmpower = true;
// window.location.href = url
// let windowDom = window.open(url,'平台授权','width=1440,height=1000')
// windowDom.addEventListener('message',(data)=>{
// if(data.auth_code){
// oauthToken(data.auth_code).then(res=>{
// windowDom.close()
// this.$modal.msgSuccess("操作成功");
// })
// }
// })
})
}
}
};
}
</script>
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 to comment