文件

1517 行
74 KiB
HTML
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/vue/element-ui.2.8.2.css">
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/vue/js/vue2.5.16.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/vue/element-ui.2.8.2.js"></script>
<title>商户支付券</title>
<style>
[v-cloak] {
display: none;
}
.seek-div {
margin: 10px 0 10px 10px;
}
.seek-div > div {
margin: 0 10px 10px 0;
}
.slots {
display: flex;
}
.slots > div:nth-child(1) {
margin-right: 10px;
}
/* 领取记录详情 */
.dialog-function {
display: flex;
line-height: 50px;
padding-bottom: 20px;
}
.dialog-function > div:nth-child(1) {
margin-right: 10px;
}
.dialog-function > div:nth-child(3) {
margin: 0 30px;
}
/* 领取详情分页 */
.dialog-paging {
margin: 20px 0 0 300px;
}
</style>
</head>
<body>
<div id="app" v-cloak>
<!-- 搜索 -->
<div class="seek-div">
<el-date-picker
size="small"
clearable
v-model="add_time"
type="datetimerange"
value-format="yyyy-MM-dd HH:mm:ss"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间">
</el-date-picker>
<el-select v-model="stock_type" placeholder="券类型" size="small" clearable>
<el-option value="1" label="固定面额满减券"></el-option>
<!-- <el-option value="2" label="折扣券"></el-option>
<el-option value="3" label="换购券"></el-option>-->
</el-select>
<el-select v-model="activate_status" placeholder="激活状态" size="small" clearable>
<el-option value="2" label="未激活"></el-option>
<el-option value="1" label="已激活"></el-option>
</el-select>
<el-select v-model="suspend_status" placeholder="领取状态" size="small" clearable>
<el-option value="1" label="允许领取"></el-option>
<el-option value="2" label="已暂停"></el-option>
</el-select>
<if condition="$auth['search'] eq true">
<el-button type="primary" @click="search" size="small">查询</el-button>
</if>
<if condition="$auth['coupon'] eq true">
<el-button type="primary" plain @click="Coupon" size="small">创建代金券</el-button>
</if>
<if condition="$auth['getRecord'] eq true">
<el-button type="primary" plain @click="getRecord" size="small">发放记录</el-button>
</if>
<if condition="$auth['download'] eq true">
<el-button @click="download" size="small">下载券码</el-button>
</if>
</div>
<!-- 列表 -->
<div style="width: calc(100vw - 20px);">
<el-table border :data="couponList" style="width: calc(100% - 20px);border: none;margin: 0 auto"
size="mini"
max-height="500"
v-loading="loading"
element-loading-text="数据获取中"
@selection-change="ChooseCouponChange"
element-loading-spinner="el-icon-loading">
<el-table-column type="selection" width="55" align="center"></el-table-column>
<el-table-column prop="index" label="序号" show-overflow-tooltip width="50"></el-table-column>
<el-table-column prop="user_name" label="支付模式" show-overflow-tooltip></el-table-column>
<el-table-column prop="type_name" label="场景" show-overflow-tooltip></el-table-column>
<el-table-column prop="operator_name" label="创建人" show-overflow-tooltip></el-table-column>
<el-table-column prop="stock_name" label="代金券名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="stock_id" label="代金券ID" show-overflow-tooltip></el-table-column>
<el-table-column prop="stock_type_name" label="代金券类型" show-overflow-tooltip></el-table-column>
<el-table-column prop="max_coupons" label="总库存" show-overflow-tooltip></el-table-column>
<el-table-column prop="operation_num" label="剩余库存" show-overflow-tooltip></el-table-column>
<el-table-column prop="valid_time" label="有效时间" show-overflow-tooltip></el-table-column>
<el-table-column fixed="right" label="操作" width="260" style="border-right: none;">
<template slot-scope="scope">
<if condition="$auth['coupon_info'] eq true">
<el-button @click="coupon_info(scope.row.id)" type="text" size="small">查看详情</el-button>
</if>
<if condition="$auth['activation'] eq true">
<el-button @click="activation(scope.row.id)" type="text" size="small"
v-if="scope.row.activate_status == 2">激活
</el-button>
</if>
<if condition="$auth['grant'] eq true">
<el-button @click="grant(scope.row.id,scope.row.user_type,scope.row.type)" type="text"
size="small"
v-if="scope.row.activate_status == 1 && scope.row.suspend_status == 1">发放
</el-button>
</if>
</if>
<if condition="$auth['suspendOperation'] eq true">
<el-button @click="suspendOperation(scope.row.id)" type="text" size="small"
v-if="scope.row.suspend_status == 1">暂停代金券
</el-button>
<el-button @click="restartOperation(scope.row.id)" type="text" size="small"
v-if="scope.row.suspend_status == 2">重启代金券
</el-button>
</if>
<if condition="deleteOperation eq true">
<el-button @click="deleteOperation(scope.row.id)" type="text" size="small">删除
</el-button>
</if>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[10, 15, 20, 25, 30, 35, 40, 45, 50]"
:page-size="100"
layout="total, sizes, prev, pager, next, jumper"
:total="currentLen">
</el-pagination>
</div>
<!-- 弹出层(代金券设置) -->
<el-dialog title="代金券设置" :visible.sync="showSetting" width="800px" top="7vh"
:before-close="clearCoupon" :close-on-click-modal="false">
<el-form :model="add_form" :rules="ruleForm" ref="add_form" size="mini" label-width="140px">
<div v-show="couponOne">
<!-- <el-form-item label="支付模式:" prop="user_type">
<el-select class="add_form-input" v-model="add_form.user_type" clearable
placeholder="请选择支付模式" size="small" style="margin-right:10px">
<el-option label="普通支付模式" :value="1"></el-option>
<el-option label="服务商支付模式" :value="2"></el-option>
</el-select>
</el-form-item>-->
<if condition="$pay_type eq 1">
<el-form-item label="场景:">
<el-select class="add_form-input" v-model="add_form.type" clearable
placeholder="请选择场景" size="small" style="margin-right:10px">
<el-option label="线下" :value="2"></el-option>
<el-option label="线上" :value="1"></el-option>
</el-select>
</el-form-item>
</if>
<el-form-item label="代金券名称:" prop="stock_name">
<el-input v-model="add_form.stock_name" clearable placeholder="请输入代金券名称"
style="width:300px;"></el-input>
<span>(最多6个字)</span>
</el-form-item>
<el-form-item label="营销经费:">
<div>
<el-radio v-model="add_form.no_cash" label="2">预充值,使用本商户号余额 ,商户订单实收不变</el-radio>
</div>
<div>
<el-radio v-model="add_form.no_cash" label="1">免充值,扣减商户订单实收金额</el-radio>
</div>
</el-form-item>
<el-form-item label="代金券类型:" prop="stock_type">
<el-radio v-model="add_form.stock_type" label="1">满减券</el-radio>
<!-- <el-radio v-model="add_form.stock_type" label="2">折扣券</el-radio>-->
</el-form-item>
<el-form-item label="代金券面额:" prop="coupon_use_rule.fixed_normal_coupon.coupon_amount"
v-if="add_form.stock_type==1">
<el-input v-model="add_form.coupon_use_rule.fixed_normal_coupon.coupon_amount" clearable
placeholder="请输入代金券面额" style="width:150px;"></el-input>
<span>最低0.02元</span>
</el-form-item>
<!-- <el-form-item label="最高折扣金额:" v-if="add_form.stock_type==2"
prop="coupon_use_rule.disscount_coupon.discount_amount_max">
<el-input v-model="add_form.coupon_use_rule.disscount_coupon.discount_amount_max" clearable
placeholder="请输入最高折扣金额" style="width:150px;"></el-input>
元
</el-form-item>
<el-form-item label="折扣:" v-if="add_form.stock_type==2"
prop="coupon_use_rule.disscount_coupon.discount_percent">
<el-input v-model="add_form.coupon_use_rule.disscount_coupon.discount_percent" clearable
placeholder="请输入折扣如 88 表示八八折" style="width:150px;"></el-input>
<span>请输入折扣如 88 表示八八折</span>
</el-form-item>-->
<el-form-item label="代金券门槛:" prop="coupon_use_rule.fixed_normal_coupon.transaction_minimum">
消费
<el-input v-model="add_form.coupon_use_rule.fixed_normal_coupon.transaction_minimum"
clearable
placeholder="请输入代金券门槛" style="width:150px;"></el-input>
元可用
</el-form-item>
<el-form-item label="总发放数量:" prop="stock_use_rule.max_coupons">
<el-input v-model="add_form.stock_use_rule.max_coupons" clearable
placeholder="请输入总发放数量" style="width:150px;"></el-input>
</el-form-item>
<el-form-item label="总发放金额:" prop="stock_use_rule.max_amount">
<el-input v-model="add_form.stock_use_rule.max_amount" clearable
placeholder="请输入总发放金额" style="width:150px;"></el-input>
<span>数量*金额</span>
</el-form-item>
<!-- <el-form-item label="单用户限制:" prop="stock_use_rule.max_coupons_per_user">
<el-input v-model="add_form.stock_use_rule.max_coupons_per_user" clearable
placeholder="请输入单用户限制" style="width:150px;"></el-input>
<span>单个用户可领个数,每个用户最多60张券</span>
</el-form-item>-->
<el-form-item>
<el-button type="primary" size="small" @click="distance(2)">下一步</el-button>
</el-form-item>
</div>
<div v-show="couponTwo">
<el-form-item label="有效时间:" prop="available_time">
<el-date-picker
v-model="add_form.available_time"
value-format="yyyy-MM-ddTHH:mm:ss"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
:picker-options="datePickerOptions"
>
</el-date-picker>
</el-form-item>
<el-form-item label="生效时间(可不选):">
<div>
<el-radio v-model="add_form.valid_time_type" label="1">固定时间段</el-radio>
<el-time-picker
v-model="add_form.coupon_use_rule.coupon_available_time.fix_available_time.begin_time"
value-format="HH:mm"
:picker-options="{
selectableRange: '00:00:00 - 23:59:59'
}"
placeholder="开始时间">
</el-time-picker>
<el-time-picker
v-model="add_form.coupon_use_rule.coupon_available_time.fix_available_time.end_time"
value-format="HH:mm"
:picker-options="{
selectableRange: '00:00:00 - 23:59:59'
}"
placeholder="结束时间">
</el-time-picker>
<!-- <div>
<template>
<el-checkbox-group
v-model="add_form.coupon_use_rule.coupon_available_time.fix_available_time.available_week_day">
<el-checkbox label="0">星期日</el-checkbox>
<el-checkbox label="1">星期一</el-checkbox>
<el-checkbox label="2">星期二</el-checkbox>
<el-checkbox label="3">星期三</el-checkbox>
<el-checkbox label="4">星期四</el-checkbox>
<el-checkbox label="5">星期五</el-checkbox>
<el-checkbox label="6">星期六</el-checkbox>
</el-checkbox-group>
</template>
</div>-->
</div>
<div>
<el-radio v-model="add_form.valid_time_type" label="2">领取后第二天生效</el-radio>
</div>
<!-- <div>
<el-radio v-model="add_form.valid_time_type" label="3">领取后
<el-input
v-model="add_form.coupon_use_rule.coupon_available_time.available_time_after_receive"
clearable
placeholder="请输入时间单位分钟" style="width:150px;"></el-input>
分钟生效
<span>最少30分钟</span>
</el-radio>
</div>-->
</el-form-item>
<el-form-item label="代金券使用类型:" prop="coupon_type">
<div>
<el-radio v-model="add_form.coupon_type" label="1" @change="full">全场券</el-radio>
</div>
<div>
<el-radio v-model="add_form.coupon_type" label="2">单品券</el-radio>
</div>
<div v-if="add_form.coupon_type==2">
<div>核销方式:</div>
<div>
<el-radio v-model="add_form.appoint_type" label="1">指定商品id</el-radio>
</div>
<div>
<el-radio v-model="add_form.appoint_type" label="2">指定商品条码(不区分门店,只要商品条码符合即可使用)
</el-radio>
</div>
</div>
<div v-if="add_form.coupon_type==2">
<el-button type="primary" @click="choiceGoods">选择商品</el-button>
</div>
<!-- <span v-if="add_form.coupon_type==1">不可使用商品(最多选择50个)</span>-->
<span v-if="add_form.coupon_type==2">可使用商品(最多选择50个)</span>
<el-table
v-if="add_form.coupon_type == 2"
:data="add_form.coupon_use_rule.goodsList"
border
height="300px"
size="mini"
style="width: 100%; margin-top: 20px">
<el-table-column align="center" label="序号" type="index" width="60"></el-table-column>
<el-table-column align="center" prop="goods_id" label="商品ID" width="120"></el-table-column>
<el-table-column prop="goods_name" label="商品名称" min-width="120"></el-table-column>
<el-table-column prop="store_name" label="所属门店" width="120"></el-table-column>
<el-table-column label="操作" width="60">
<template slot-scope="scope">
<el-button type="text" size="mini" @click="deleteGoods(scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="distance(1)">上一步</el-button>
<el-button type="primary" size="small" @click="distance(3)">下一步</el-button>
</el-form-item>
</div>
<div v-show="couponThree">
<!-- <el-form id="label_form">
<el-form-item label="LOGO">
<label class="file_label" style="display: block;margin-top:10px;">
<input type="hidden" name="label_img_id" value=""/>
<input @change="changeLabelImage" type="file" name="label_img" placeholder="选择Logo"
accept="image/png,image/jpeg,image/gif"/>
<img id="label_url" style="max-width: 200px" src=""
onerror="this.onerror=null;this.src='__PUBLIC__/paper/images/wx_add.png'">
<span>最大1M</span>
</label>
</el-form-item>
</el-form>-->
<el-form-item label="商户名称">
<el-input v-model="add_form.pattern_info.merchant_name" clearable placeholder="商户名称"
style="width:300px;"></el-input>
<span>(最多48字)</span>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="distance(2)">上一步</el-button>
<el-button type="primary" v-if="edit" size="small" @click="createCoupon('add_form')">提交</el-button>
</el-form-item>
</div>
</el-form>
</el-dialog>
<el-dialog title="门店商品列表" :visible.sync="storeSetting" width="800px" top="7vh">
<div class="dialog-details-first">
<div style="display: flex;align-items: center;flex-wrap: wrap">
<select-store :store-id.sync="store_id"
:show-status="true"
@change="choiceStore"></select-store>
<el-input
size="small"
style="margin-right: 10px;width:200px"
class="el-input-remote"
v-model="searchText"
clearable
@keydown.enter.exact.native.prevent="searchGoods"
placeholder="名称/货号/条码">
</el-input>
<select-goods-category v-if="showClass && store_id" :user-type="2"
:store-id="store_id"
:category-id1.sync="goodsClassId1"
:category-id2.sync="goodsClassId2"
:category-id3.sync="goodsClassId3"></select-goods-category>
<el-button type="primary" plain @click="searchGoods" size="small">搜索</el-button>
<el-button type="primary" @click="setGoods" size="small">选择</el-button>
</div>
</div>
<div style="border: 1px solid #e6e6e6;max-width: calc(100vw - 208px);margin-top: 10px;">
<el-table border :data="storeGoodsList" style="width: 100%;border: none;"
size="mini"
max-height="500"
@selection-change="handleSelectionChange"
v-loading="storeLoading">
<el-table-column type="selection" width="55"></el-table-column>
<el-table-column prop="goods_id" label="ID" width="50"></el-table-column>
<el-table-column prop="goods_name" label="商品名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="goods_number" label="货号" min-width="60" show-overflow-tooltip></el-table-column>
<el-table-column prop="goods_code" min-width="100" label="商品条码" show-overflow-tooltip></el-table-column>
</el-table>
<el-pagination
@size-change="storeHandleSizeChange"
@current-change="storeHandleCurrentChange"
:current-page="storeCurrentPage"
:page-sizes="[10, 15, 20, 25, 30, 35, 40, 45, 50]"
:page-size="100"
layout="total, sizes, prev, pager, next, jumper"
:total="storeCurrentLen">
</el-pagination>
</div>
</el-dialog>
<el-dialog title="人员列表" :visible.sync="xcx_status" width="800px" top="7vh">
<div class="dialog-details-first">
<div style="display: flex;">
<el-input
size="small"
style="margin-right: 10px;width:200px"
class="el-input-remote"
v-model="vipSearchText"
clearable
placeholder="名称/手机号">
</el-input>
<el-button type="primary" plain @click="searchVip" size="small">搜索</el-button>
<el-button type="primary" @click="setGoods" size="small">选择</el-button>
</div>
</div>
<div style="border: 1px solid #e6e6e6;max-width: calc(100vw - 208px);margin-top: 10px;">
<el-table border :data="vipList" style="width: 100%;border: none;"
size="mini"
max-height="500"
v-loading="vipLoading">
<el-table-column prop="openid" label="openid" show-overflow-tooltip></el-table-column>
<el-table-column prop="name" label="会员名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="mobile_phone" label="会员手机号" min-width="60"
show-overflow-tooltip></el-table-column>
<el-table-column fixed="right" label="操作" width="200" style="border-right: none;">
<template slot-scope="scope">
<if condition="$auth['grantAction'] eq true">
<el-button
@click="grantAction(scope.row.id,scope.row.vip_id,scope.row.openid,scope.row.service_openid,scope.row.ordinary_openid)"
type="text"
size="small">发放
</el-button>
</if>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="vipHandleSizeChange"
@current-change="vipHandleCurrentChange"
:current-page="vipCurrentPage"
:page-sizes="[10, 15, 20, 25, 30, 35, 40, 45, 50]"
:page-size="100"
layout="total, sizes, prev, pager, next, jumper"
:total="vipCurrentLen">
</el-pagination>
</div>
</el-dialog>
<el-dialog title="发放记录" :visible.sync="record_status" width="99%" top="7vh">
<div class="dialog-details-first">
<div style="display: flex;">
<el-input
size="small"
style="margin-right: 10px;width:300px"
class="el-input-remote"
v-model="recordSearchText"
clearable
placeholder="会员名称/代金券名称/手机号/发放的代金券ID">
</el-input>
<el-select v-model="use_status" placeholder="状态" size="small" clearable>
<el-option value="" label="所有状态"></el-option>
<el-option value="1" label="未使用"></el-option>
<el-option value="2" label="已使用"></el-option>
</el-select>
<el-button type="primary" plain @click="searchRecord" size="small">搜索</el-button>
</div>
</div>
<div style="border: 1px solid #e6e6e6;max-width: calc(100vw - 5px);margin-top: 10px;">
<el-table border :data="recordList" style="width: 100%;border: none;"
size="mini"
max-height="500"
v-loading="recordLoading">
<el-table-column prop="index" label="序号" width="50" show-overflow-tooltip></el-table-column>
<el-table-column prop="user_type_name" label="模式" show-overflow-tooltip></el-table-column>
<el-table-column prop="type_name" label="可用场景" show-overflow-tooltip></el-table-column>
<el-table-column prop="stock_name" label="代金券名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="stock_type_name" label="类型" show-overflow-tooltip></el-table-column>
<el-table-column prop="stock_id" label="发放代金券ID" show-overflow-tooltip></el-table-column>
<el-table-column prop="user_coupon_id" label="领取代金券ID" show-overflow-tooltip></el-table-column>
<el-table-column prop="openid" label="openid" show-overflow-tooltip></el-table-column>
<el-table-column prop="name" label="会员名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="mobile_phone" label="会员手机号" show-overflow-tooltip></el-table-column>
<el-table-column prop="receive_store_name" label="领取门店" show-overflow-tooltip></el-table-column>
<el-table-column prop="add_time" label="领取时间" show-overflow-tooltip></el-table-column>
<el-table-column prop="use_store_name" label="使用门店" show-overflow-tooltip></el-table-column>
<el-table-column prop="use_scene_name" label="使用场景" show-overflow-tooltip></el-table-column>
<el-table-column prop="use_time" label="核销时间" show-overflow-tooltip></el-table-column>
</el-table>
<el-pagination
@size-change="recordHandleSizeChange"
@current-change="recordHandleCurrentChange"
:current-page="recordCurrentPage"
:page-sizes="[10, 15, 20, 25, 30, 35, 40, 45, 50]"
:page-size="100"
layout="total, sizes, prev, pager, next, jumper"
:total="recordCurrentLen">
</el-pagination>
</div>
</el-dialog>
</div>
</body>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Retail/common/js/select-store.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Retail/common/js/select-goods-category.js"></script>
<script type="text/javascript" src="__PUBLIC__/jquery/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/calculate.js"></script>
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: function () {
let that = this;
return {
showClass: false,
couponSelection: [],
use_status: '', //使用状态
recordSearchText: "",
record_status: false,
recordCurrentPage: 1,
recordCurrentLimit: 10,
recordCurrentLen: 0,
recordList: [], //记录
recordLoading: false,
searchText: '', //搜索商品列表
goodsClassId1: '',
goodsClassId2: '',
goodsClassId3: '',
store_id: '',
goodsSelection: [], //勾选的商品
storeGoodsList: [], //门店的商品列表
storeCurrentPage: 1,
storeCurrentLimit: 10,
storeCurrentLen: 0,
add_form: {
user_type: "{$pay_type}",
type: "",
stock_name: '', //名称
stock_type: '1', //类型
coupon_type: '1', //全场券 单品券
appoint_type: '1', //指定id 指定条码
available_time: '', //有效时间
valid_time_type: '', //生效时间类型
no_cash: '1', //无资金流
stock_use_rule: {
max_coupons: '',
max_amount: '',
max_coupons_per_user: '1',
natural_person_limit: false,
prevent_api_abuse: false,
},
coupon_use_rule: {
coupon_available_time: {
fix_available_time: {
available_week_day: [],
begin_time: '',
end_time: ''
},
second_day_available: true,
available_time_after_receive: '',
},
fixed_normal_coupon: {
coupon_amount: '',
transaction_minimum: '',
},
disscount_coupon: {
discount_amount_max: '',
discount_percent: '',
transaction_minimum: ''
},
goodsList: [], //选择的商品列表
},
pattern_info: {
merchant_name: '',
},
},
datePickerOptions: {
disabledDate: (time) => {
let nowDate = new Date();
let oneDay = 1000 * 60 * 60 * 24;
let oneYearLater = new Date(nowDate.getTime() + (oneDay * 90));
return time.getTime() < nowDate - oneDay || time.getTime() > oneYearLater;
}
},
ruleForm: {
user_type: [{message: '请选择支付模式', required: true, trigger: 'change'}],
stock_name: [{message: '请输入代金券名称', required: true, trigger: 'change'}, {
validator: function (rule, value, callback) {
if (value.length > 6) {
callback(new Error("不能超过6个字"));
} else {
callback();
}
}, trigger: 'blur'
}],
stock_type: [{message: '请选择代金券类型', required: true, trigger: 'change'}],
"coupon_use_rule.fixed_normal_coupon.coupon_amount": [{
message: '请输入代金券面额',
required: false,
trigger: 'change'
}, {
validator: function (rule, value, callback) {
var reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{0,2})$/;
if ((!reg.test(value) || value <= 0.01) && value != '') {
callback(new Error("请输入代金券面额"));
} else {
callback();
}
}, trigger: 'blur'
}],
"coupon_use_rule.disscount_coupon.discount_amount_max": [{
message: '请输入最高折扣金额',
required: false,
trigger: 'change'
}, {
validator: function (rule, value, callback) {
var reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{0,2})$/;
if ((!reg.test(value) || value < 0) && value != '') {
callback(new Error("请输入最高折扣金额"));
} else {
callback();
}
}, trigger: 'blur'
}],
"coupon_use_rule.disscount_coupon.discount_percent": [{
message: '请输入折扣',
required: false,
trigger: 'change'
}, {
validator: function (rule, value, callback) {
var reg = /^\+?[0-9][0-9]*$/;
var reg = /^\+?[0-9][0-9]*$/;
if ((!reg.test(value) || value < 0) && value != '') {
callback(new Error("请输入正确折扣"));
} else {
callback();
}
}, trigger: 'blur'
}],
"coupon_use_rule.fixed_normal_coupon.transaction_minimum": [{
message: '请输入代金券门槛',
required: false,
trigger: 'change'
}, {
validator: function (rule, value, callback) {
var reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{0,2})$/;
if ((!reg.test(value) || value < 0) && value != '') {
callback(new Error("请输入代金券门槛"));
} else {
callback();
}
}, trigger: 'blur'
}],
"stock_use_rule.max_coupons": [{message: '请输入总发放量', required: true, trigger: 'change'}, {
validator: function (rule, value, callback) {
var reg = /^\+?[0-9][0-9]*$/;
if (!reg.test(value) || value < 0) {
callback(new Error("请输入总发放量"));
} else {
callback();
}
}, trigger: 'blur'
}],
"stock_use_rule.max_amount": [{message: '请输入总发放金额', required: true, trigger: 'change'}, {
validator: function (rule, value, callback) {
var reg = /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{0,2})$/;
if (!reg.test(value) || value < 0) {
callback(new Error("请输入总发放金额"));
} else if (value * 1 != toDecimal(that.add_form.stock_use_rule.max_coupons * that.add_form.coupon_use_rule.fixed_normal_coupon.coupon_amount)) {
callback(new Error("总发放金额等于代金券面额乘以数量"));
} else {
callback();
}
}, trigger: 'blur'
}],
/* "stock_use_rule.max_coupons_per_user": [{message: '请输入单用户限制', required: true, trigger: 'change'}, {
validator: function (rule, value, callback) {
var reg = /^\+?[0-9][0-9]*$/;
if (!reg.test(value) || value < 0 || value > 60) {
callback(new Error("单用户限制最多60张"));
} else {
callback();
}
}, trigger: 'blur'
}],*/
coupon_type: [{message: '请选择代金券使用类型', required: true, trigger: 'change'}],
available_time: [{message: '请选择有效时间', required: true, trigger: ['change', 'blur']}, {
validator: (rule, value, callback) => {
if (!value) {
callback(new Error('请选择有效时间'));
} else {
if (new Date(value[0]).getTime() < new Date().getTime()) {
callback(new Error("开始时间不能小于当前时间"));
} else {
callback();
}
}
}, trigger: ['change', 'blur']
}],
valid_time_type: [{message: '请选择生效时间类型', required: true, trigger: 'change'}, {
validator: function (rule, value, callback) {
if (value == '') {
callback(new Error("请选择生效时间类型"));
} else {
callback();
}
}, trigger: ['change', 'blur']
}],
},
loading: false,
storeLoading: false,
currentPage: 1,
currentLimit: 10,
currentLen: 0,
add_time: '',
stock_type: '',
activate_status: '',
suspend_status: '',
couponList: [],
setting: [],
showSetting: false,
storeSetting: false,
couponOne: false,
couponTwo: false,
couponThree: false,
edit: false, //编辑
xcx_status: false, //小程序用户
vipList: [], //会员列表
vipLoading: false,
vipCurrentLen: 0,
vipCurrentPage: 1,
vipCurrentLimit: 10,
vip_coupon_id: '', //发放的代金券id
create_coupon_type: '', //代金券类型 1普通 2服务商
create_source_type: '', //1小程序 2公众号
vipSearchText: '',
}
},
methods: {
//下载
download: function () {
var that = this;
var couponList = that.couponSelection;
if (couponList.length <= 0) {
that.$message.error("请选择券");
return;
}
that.loading = true;
$.ajax({
url: "{:U('downloadCoupon')}",
type: "post",
data: {
couponList: couponList
},
success: function (res) {
that.loading = false;
if (res.status == 1) {
window.open(`{:U('downloadCouponZip')}?directory_name=${res.data.path}&store_arr=${res.data.store_arr}&coupon_arr=${res.data.coupon_arr}`);
} else {
that.$message.error(res.message);
}
}
})
},
//选择
ChooseCouponChange: function (data) {
var that = this;
that.couponSelection = data;
},
//全场券
full: function () {
this.add_form.coupon_use_rule.goodsList = [];
},
//删除
deleteOperation: function (id) {
var that = this;
this.$confirm('此操作将删除此数据显示, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
$.ajax({
url: "{:U('deleteOperation')}",
type: "post",
data: {id: id},
success: function (res) {
if (res.status == 1) {
that.$message({
type: "success",
message: res.message,
duration: 1000,
onClose: function () {
that.getCouponList();
}
})
} else {
that.$message({
type: "error",
message: res.message,
duration: 2000
})
}
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
//重启
restartOperation: function (id) {
var that = this;
this.$confirm('此操作将重启代金券, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.restartPause(id, 2);
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
});
});
},
//暂停发放代金券
suspendOperation: function (id) {
var that = this;
this.$confirm('此操作将暂停代金券, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.restartPause(id, 1);
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
});
});
},
restartPause: function (id, operation_type) {
var that = this;
$.ajax({
url: "{:U('suspendOperation')}",
type: "post",
data: {
coupon_id: id,
operation_type: operation_type
},
success: function (res) {
if (res.status == 1) {
that.$message({
type: "success",
message: res.message,
duration: 1000,
onClose: function () {
that.getCouponList();
}
})
} else {
that.$message({
type: "error",
message: res.message,
duration: 2000
})
}
}
})
},
//记录搜索
searchRecord: function () {
this.recordCurrentPage = 1;
this.getRecord();
},
//记录
getRecord: function () {
var that = this;
that.recordLoading = true;
that.record_status = true;
var page = that.recordCurrentPage;
var limit = that.recordCurrentLimit;
var recordSearchText = that.recordSearchText;
var use_status = that.use_status;
$.ajax({
url: "{:U('record')}",
type: "post",
data: {
page: page,
limit: limit,
searchText: recordSearchText,
use_status: use_status
},
success: function (res) {
that.recordLoading = false;
that.recordList = [];
that.recordList = res.data.list;
that.$nextTick(function () {
that.recordCurrentLen = parseInt(res.data.count);
})
}
})
},
recordHandleSizeChange: function (val) {
this.recordCurrentLimit = val;//切换每页数量
this.recordCurrentPage = 1;
this.getRecord();
},
recordHandleCurrentChange: function (val) {
this.recordCurrentPage = val;
this.getRecord();//切换页数
},
//发放
grantAction: function (uid, vip_id, openid, service_openid, ordinary_openid) {
var that = this;
var coupon_id = that.vip_coupon_id;
if (coupon_id == '') {
that.$message({
type: "error",
message: "参数缺失",
duration: 1000
})
return;
}
that.$confirm('此操作将给该用户发放代金券, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
$.ajax({
url: "{:U('grant')}",
type: "post",
data: {
coupon_id: coupon_id,
uid: uid,
vip_id: vip_id,
openid: openid,
service_openid: service_openid,
ordinary_openid: ordinary_openid
},
success: function (res) {
if (res.status == 1) {
that.$message.success(res.message);
} else {
that.$message.error(res.message);
}
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消激活'
});
});
},
//用户列表
grant: function (id, create_coupon_type, create_source_type) {
var that = this;
that.xcx_status = true;
that.vipCurrentPage = 1;
that.vip_coupon_id = id;
that.create_coupon_type = create_coupon_type;
that.create_source_type = create_source_type;
that.vipSearchText = '';
that.getVipList();
},
searchVip: function () {
this.vipCurrentPage = 1;
this.getVipList();
},
//用户列表
getVipList: function () {
var that = this;
that.vipLoading = true;
var vipSearchText = that.vipSearchText;
var create_coupon_type = that.create_coupon_type;
var create_source_type = that.create_source_type;
$.ajax({
url: "{:U('userList')}",
type: "post",
data: {
create_coupon_type: create_coupon_type,
create_source_type: create_source_type,
vipSearchText: vipSearchText,
page: that.vipCurrentPage,
limit: that.vipCurrentLimit
},
success: function (res) {
that.vipLoading = false;
that.vipList = [];
that.vipList = res.data.list;
that.$nextTick(function () {
that.vipCurrentLen = parseInt(res.data.count);
})
}
})
},
vipHandleSizeChange: function (val) {
this.vipCurrentLimit = val;//切换每页数量
this.vipCurrentPage = 1;
this.getVipList();
},
vipHandleCurrentChange: function (val) {
this.vipCurrentPage = val;
this.getVipList();//切换页数
},
//激活
activation: function (id) {
var that = this;
this.$confirm('此操作将激活代金券, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
$.ajax({
url: "{:U('activation')}",
type: "post",
data: {id: id},
success: function (res) {
if (res.status == 1) {
that.$message({
type: "success",
message: res.message,
duration: 1000,
onClose: function () {
that.getCouponList();
}
})
} else {
that.$message.error(res.message);
}
}
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消激活'
});
});
},
//详情
coupon_info: function (id) {
var that = this;
that.edit = false;
$.ajax({
url: "{:U('couponInfo')}",
type: "post",
data: {id: id},
success: function (res) {
if (res.status == 1) {
that.add_form = {};
that.add_form = res.data.info;
that.showSetting = true;
that.couponOne = true;
that.couponTwo = false;
that.couponThree = false;
} else {
that.$message.error(res.message);
}
}
})
},
//提交代金券
createCoupon: function (formName) {
var that = this;
that.$refs[formName].validate((valid) => {
if (valid) {
var reg = /^\+?[0-9][0-9]*$/;
var add_form = that.add_form;
var no_cash = add_form.no_cash;
var type = add_form.type;
var user_type = add_form.user_type;
var stock_type = add_form.stock_type;
var coupon_amount = add_form.coupon_use_rule.fixed_normal_coupon.coupon_amount;
var transaction_minimum = add_form.coupon_use_rule.fixed_normal_coupon.transaction_minimum;
var discount_amount_max = add_form.coupon_use_rule.disscount_coupon.discount_amount_max;
var discount_percent = add_form.coupon_use_rule.disscount_coupon.discount_percent;
var valid_time_type = add_form.valid_time_type;
var begin_time = add_form.coupon_use_rule.coupon_available_time.fix_available_time.begin_time;
var end_time = add_form.coupon_use_rule.coupon_available_time.fix_available_time.end_time;
var available_time_after_receive = add_form.coupon_use_rule.coupon_available_time.available_time_after_receive;
var max_amount = add_form.stock_use_rule.max_amount;
var max_coupons = add_form.stock_use_rule.max_coupons;
var goods_list = add_form.coupon_use_rule.goodsList;
var coupon_type = add_form.coupon_type;
if (user_type == '') {
that.$message.error("请选择创建代金券的支付模式");
return;
}
if (user_type == 1 && type == '') {
that.$message.error("请选择创建代金券的使用场景");
return;
}
if (no_cash == '') {
that.$message.error("请选择代金券营销经费");
return;
}
if (user_type == 2 && no_cash == 2) {
that.$message.error("服务商模式下暂不支付创建预充值类型");
return;
}
switch (stock_type) {
case '1':
//满减券
if (coupon_amount == '' || parseFloat(coupon_amount) <= 0.01) {
that.$message.error("请输入正确代金券面额");
return;
}
if (transaction_minimum == '' || parseFloat(transaction_minimum) <= parseFloat(coupon_amount)) {
that.$message.error("代金券门槛必须大于代金券金额");
return;
}
if (parseFloat(max_amount) != toDecimal(parseFloat(max_coupons) * parseFloat(coupon_amount))) {
that.$message.error("总发放金额等于面额*数量");
return;
}
break;
case '2':
//折扣券
if (discount_amount_max == '' || parseFloat(discount_amount_max) <= 0) {
that.$message.error("请输入正确折扣金额");
return;
}
if (discount_percent == '' || parseInt(discount_percent) <= 0) {
that.$message.error("请输入正确折扣");
return;
}
break;
}
switch (valid_time_type) {
case '1':
//固定时间段
if (begin_time == '' || end_time == '') {
that.$message.error("请选择生效时间");
return;
}
break;
case '3':
if (available_time_after_receive == '' || !reg.test(available_time_after_receive) || available_time_after_receive < 30) {
that.$message.error("请输入正确生效天数");
return;
}
break;
}
switch (coupon_type) {
case '2':
//单品券
if (goods_list.length == 0) {
that.$message.error("请选择单品优惠的商品");
return;
}
if (goods_list.length > 50) {
that.$message.error("单品券最多选择50种商品");
return;
}
break;
}
that.$confirm("确认代金券信息无误,提交后无法修改", "温馨提示", {
confirmButtonText: '继续',
cancelButtonText: '取消',
type: 'info'
}).then(() => {
that.$loading({
lock: true,
text: '保存中,请等待',
spinner: 'el-icon-loading',
background: 'rgba(255, 255, 255, 0.7)'
});
add_form = JSON.stringify(add_form);
$.ajax({
url: "{:U('createCoupon')}",
data: {add_form: add_form},
type: "POST",
success: function (res) {
that.$loading().close();
if (res.status == 1) {
that.$message({
type: "success",
message: res.message,
duration: 1000,
onClose: function () {
that.showSetting = false;
that.getCouponList();
}
})
} else {
that.$message({
message: res.message,
type: 'error',
duration: 3000
});
}
}
});
}).catch(() => {
})
} else {
that.$message({message: '请完善必填项', type: 'error'});
}
});
},
changeLabelImage: function () {
if (window.event.target.files.length) {
var that = this;
var imgObj = window.event.target.files[0];
console.log(imgObj);
var imgType = ['image/jpg', 'image/jpeg', 'image/png', 'image/bmp'];
if (imgObj.size > 1024) {
that.$message({
type: "error",
message: "不能超过1M",
duration: 2000
})
return;
}
if (jQuery.inArray(imgObj.type, imgType) != -1) {
//是图片
var that = this;
var form_data = new FormData(document.getElementById('label_form'));
/* const loadsing = that.$loading({
target:"#loadingOne",
lock: true,
text: '保存中,请等待',
spinner: 'el-icon-loading',
background: 'rgba(255, 255, 255, 0.7)'
});*/
$.ajax({
url: "{:U('uploadWx')}",
type: "POST",
data: form_data,
dataType: 'JSON',
cache: false, // 不缓存
processData: false, // jQuery不要去处理发送的数据
contentType: false, // jQuery不要去设置Content-Type请求头
success: function (res) {
// loadsing.close();
if (res.status == 1) {
that.$message({
message: res.msg,
type: 'success',
duration: 1000,
onClose: function () {
var reader = new FileReader();
reader.readAsDataURL(imgObj);
reader.onload = function () {
$("input[name='label_img_id']").val('');
$("input[name='label_img']").next('img').attr('src', this.result);
}
}
});
} else {
that.$message({
message: res.msg,
type: 'error'
});
}
}
})
} else {
that.$message({
type: "error",
message: "格式不正确",
duration: 2000
})
}
}
},
//上传微信
uploadWx: function () {
},
//创建代金券
Coupon: function () {
this.store_id = '';
this.storeGoodsList = [],
this.edit = true,
this.add_form = {
user_type: '{$pay_type}',
type: '',
stock_name: '',
stock_type: '1',
coupon_type: '1',
appoint_type: '1',
available_time: [], //有效时间
valid_time_type: '', //生效时间类型
no_cash: '1', //无资金流
stock_use_rule: {
max_coupons: '',
max_amount: '',
max_coupons_per_user: '1',
natural_person_limit: false, //是否开启自然人限制
prevent_api_abuse: false, //api发券防刷
},
coupon_use_rule: {
coupon_available_time: {
fix_available_time: {
available_week_day: [],
begin_time: '', //生效时间
end_time: ''
},
second_day_available: true,
available_time_after_receive: '',
},
fixed_normal_coupon: {
coupon_amount: '',
transaction_minimum: '',
},
disscount_coupon: {
discount_amount_max: '',
discount_percent: '',
transaction_minimum: ''
},
goodsList: []
},
pattern_info: {
merchant_name: '',
}
},
this.showSetting = true;
this.storeSetting = false;
this.couponOne = true;
this.couponTwo = false;
this.couponThree = false;
},
//选择商品
choiceGoods: function () {
this.storeCurrentPage = 1;
this.storeSetting = true;
},
//选择门店
choiceStore: function () {
this.showClass = false;
this.goodsClassId1 = '';
this.goodsClassId2 = '';
this.goodsClassId3 = '';
this.storeGoodsList = [];
this.storeCurrentLen = 0;
this.$nextTick(() => {
if(this.store_id){
this.showClass = true;
this.storeCurrentPage = 1;
this.getStoreGoodsList();
}
})
},
//删除选中的商品
deleteGoods: function (index) {
this.add_form.coupon_use_rule.goodsList.splice(index, 1);
},
//选择商品
setGoods: function () {
var that = this;
var goodsSelection = that.goodsSelection;
if (goodsSelection.length <= 0) {
that.$message.error("请选择商品");
return;
}
var goodsList = JSON.parse(JSON.stringify(that.add_form.coupon_use_rule.goodsList));
for (var i = 0; i < goodsSelection.length; i++) {
goodsList.unshift(goodsSelection[i]);
}
if (goodsList.length > 50) {
that.$message.error("最多选择50种商品");
return;
}
that.goodsList = [];
that.add_form.coupon_use_rule.goodsList = goodsList;
that.searchGoods();
},
//选中的商品
handleSelectionChange: function (data) {
var that = this;
that.goodsSelection = data;
},
//搜索商品列表
searchGoods: function () {
this.storeCurrentPage = 1;
this.getStoreGoodsList();
},
//门店的商品列表
getStoreGoodsList: function () {
var that = this;
that.storeLoading = true;
if (that.store_id == '') {
this.$message.error("请选择门店");
return;
}
var goodsList = that.add_form.coupon_use_rule.goodsList;
var notInIds = [];
if (goodsList.length > 0) {
for (var i = 0; i < goodsList.length; i++) {
notInIds.push(goodsList[i].goods_id);
}
}
$.ajax({
url: "{:U('storeGoodsList')}",
type: "post",
data: {
store_id: that.store_id,
notInIds: notInIds,
page: that.storeCurrentPage,
limit: that.storeCurrentLimit,
searchText: that.searchText,
person1: that.goodsClassId1,
person2: that.goodsClassId2,
person3: that.goodsClassId3
},
success: function (res) {
that.storeLoading = false;
that.storeGoodsList = [];
that.storeGoodsList = res.data.list;
that.$nextTick(function () {
that.storeCurrentLen = res.data.count;
})
}
})
},
storeHandleSizeChange: function (val) {
this.storeCurrentLimit = val;//切换每页数量
this.storeCurrentPage = 1;
this.getStoreGoodsList();
},
storeHandleCurrentChange: function (val) {
this.storeCurrentPage = val;
this.getStoreGoodsList();//切换页数
},
//关闭弹框执行
clearCoupon: function () {
this.showSetting = false;
},
//路程
distance: function (speed) {
switch (speed) {
case 1:
this.couponOne = true;
this.couponTwo = false;
this.couponThree = false;
break;
case 2:
this.couponOne = false;
this.couponTwo = true;
this.couponThree = false;
break;
case 3:
this.couponOne = false;
this.couponTwo = false;
this.couponThree = true;
break;
}
},
//列表搜索
search: function () {
this.currentPage = 1;
this.getCouponList();
},
//代金券列表
getCouponList: function () {
var that = this;
var page = that.currentPage;
var limit = that.currentLimit;
var add_time = that.add_time;
var stock_type = that.stock_type;
var suspend_status = that.suspend_status;
var activate_status = that.activate_status;
$.ajax({
url: "{:U('CouponList')}",
type: "post",
data: {
page: page,
limit: limit,
add_time: add_time,
stock_type: stock_type,
suspend_status: suspend_status,
activate_status: activate_status
},
success: function (res) {
that.couponList = [];
that.couponList = res.data.list;
that.$nextTick(function () {
that.currentLen = parseInt(res.data.count);
})
}
})
},
handleSizeChange: function (val) {
this.currentLimit = val;//切换每页数量
this.currentPage = 1;
this.getCouponList();
},
handleCurrentChange: function (val) {
this.currentPage = val;
this.getCouponList();//切换页数
},
},
created: function () {
this.getCouponList();
}
})
</script>
</html>