初始上传
This commit is contained in:
121
addon/cashier/source/os/pages/marketing/public/css/coupon_detail.scss
Executable file
121
addon/cashier/source/os/pages/marketing/public/css/coupon_detail.scss
Executable file
@@ -0,0 +1,121 @@
|
||||
.coupons-detail {
|
||||
position: relative;
|
||||
height: calc(100vh - 0.4rem);
|
||||
background-color: #fff;
|
||||
.common-wrap.fixd {
|
||||
padding: 30rpx;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
padding-bottom: 0.85rem !important;
|
||||
box-sizing: border-box;
|
||||
|
||||
.form-label {
|
||||
width: 1.7rem !important;
|
||||
height: 0.3rem !important;
|
||||
line-height: 0.3rem !important;
|
||||
padding: 0 0.15rem;
|
||||
}
|
||||
.common-form-item{
|
||||
width: 33.333%;
|
||||
height: 0.3rem;
|
||||
margin-bottom: 0;
|
||||
.form-input-inline{
|
||||
border-width: 0 !important;
|
||||
width: calc(100% - 1.8rem);
|
||||
}
|
||||
&.coupons-img{
|
||||
-webkit-box-align: start;
|
||||
-ms-flex-align: start;
|
||||
-webkit-align-items: flex-start;
|
||||
align-items: flex-start;
|
||||
width: 100% !important;
|
||||
height: auto;
|
||||
.upload-box {
|
||||
border: 0.01rem dashed #e6e6e6 !important;
|
||||
width: 2.5rem !important;
|
||||
height: 1.2rem !important;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.upload {
|
||||
text-align: center;
|
||||
color: #5a5a5a;
|
||||
|
||||
.iconfont {
|
||||
font-size: 0.3rem;
|
||||
}
|
||||
|
||||
image {
|
||||
max-width: 100%;
|
||||
height: 1.2rem !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.common-title {
|
||||
font-size: 0.18rem;
|
||||
margin-bottom: 0.2rem;
|
||||
&.mt-20{
|
||||
margin-top: 0.2rem;
|
||||
}
|
||||
}
|
||||
.data{
|
||||
margin-top: 0.1rem;
|
||||
.data-item{
|
||||
width: 33.333%;
|
||||
text-align: center;
|
||||
.title{
|
||||
color: #909399;
|
||||
margin-bottom: 0.2rem;
|
||||
}
|
||||
.content{
|
||||
font-size: 0.26rem;
|
||||
color: #303133;
|
||||
}
|
||||
}
|
||||
}
|
||||
/deep/ .member-img{
|
||||
width: 0.6rem;
|
||||
height: 0.6rem;
|
||||
margin-right: 0.1rem;
|
||||
-ms-flex-negative: 0;
|
||||
-webkit-flex-shrink: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
/deep/ .member-nickname{
|
||||
width: 2.3rem;
|
||||
}
|
||||
/deep/ .member-mobile{
|
||||
width: 2.3rem;
|
||||
}
|
||||
.record{
|
||||
margin-bottom: 0.2rem;
|
||||
view {
|
||||
width: 1rem;
|
||||
height: 0.35rem;
|
||||
line-height: 0.35rem;
|
||||
text-align: center;
|
||||
font-size: 0.14rem;
|
||||
border: 0.01rem solid #e6e6e6;
|
||||
border-left-width: 0;
|
||||
transition: all 0.3s;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover,
|
||||
&.active {
|
||||
border-color: $primary-color;
|
||||
color: $primary-color;
|
||||
background-color: var(--primary-color-light-9);
|
||||
box-shadow: -0.01rem 0 0 0 $primary-color;
|
||||
}
|
||||
|
||||
&:first-child {
|
||||
border-left-width: 0.01rem;
|
||||
box-shadow: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
124
addon/cashier/source/os/pages/marketing/public/css/coupon_list.scss
Executable file
124
addon/cashier/source/os/pages/marketing/public/css/coupon_list.scss
Executable file
@@ -0,0 +1,124 @@
|
||||
view {
|
||||
color: #303133;
|
||||
}
|
||||
|
||||
/deep/ .uni-scroll-view::-webkit-scrollbar {
|
||||
width: 0.05rem;
|
||||
height: 0.3rem;
|
||||
}
|
||||
|
||||
/deep/ .uni-scroll-view::-webkit-scrollbar-thumb {
|
||||
border-radius: 0.1rem;
|
||||
box-shadow: inset 0 0 0.05rem rgba(0, 0, 0, 0.2);
|
||||
background: rgba(193, 193, 193, 1);
|
||||
}
|
||||
|
||||
.cart-empty {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 2.1rem;
|
||||
}
|
||||
|
||||
.record-body {
|
||||
width: 10rem;
|
||||
min-height: 7rem;
|
||||
}
|
||||
|
||||
.add-coupons{
|
||||
margin-bottom: 0.1rem;
|
||||
|
||||
button{
|
||||
background-color: $primary-color;
|
||||
color: #fff;
|
||||
display: inline-block;
|
||||
padding: 0 0.2rem;
|
||||
height: 0.36rem;
|
||||
line-height: .36rem;
|
||||
font-size: 0.14rem;
|
||||
&::after{
|
||||
border-width: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 筛选面板
|
||||
.screen-warp {
|
||||
padding: 0.15rem 0.15rem 0;
|
||||
background-color: #f2f3f5;
|
||||
margin-bottom: 0.15rem;
|
||||
|
||||
.common-form-item .form-label {
|
||||
width: 1.2rem;
|
||||
}
|
||||
|
||||
.common-btn-wrap {
|
||||
margin-left: 1.2rem;
|
||||
}
|
||||
|
||||
.coupons-category .form-input-inline {
|
||||
width: 2.8rem;
|
||||
}
|
||||
|
||||
.form-inline {
|
||||
margin-bottom: 0.15rem;
|
||||
}
|
||||
|
||||
.common-form-item {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.input-append {
|
||||
position: relative;
|
||||
|
||||
.form-input {
|
||||
padding-right: 0.3rem;
|
||||
}
|
||||
|
||||
.unit {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0.1rem;
|
||||
height: 0.35rem;
|
||||
line-height: 0.35rem;
|
||||
}
|
||||
}
|
||||
|
||||
.form-input-inline.split-wrap {
|
||||
width: initial;
|
||||
background: none;
|
||||
border: none;
|
||||
}
|
||||
}
|
||||
|
||||
.coupons-list {
|
||||
display: block;
|
||||
width: 100%;
|
||||
@extend %body-overhide;
|
||||
padding: 0.15rem 0.15rem 0;
|
||||
background-color: #fff;
|
||||
|
||||
/deep/ .coupons-content {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.action-btn-wrap {
|
||||
.action-item {
|
||||
margin-left: 0.1rem;
|
||||
color: $primary-color;
|
||||
|
||||
&:first-of-type {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/deep/ .batch-action {
|
||||
.batch-item {
|
||||
margin-right: 0.15rem;
|
||||
border: 0.01rem solid rgba(0, 0, 0, 0.2);
|
||||
padding: 0.05rem;
|
||||
border-radius: 0.03rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
199
addon/cashier/source/os/pages/marketing/public/css/edit_coupon.scss
Executable file
199
addon/cashier/source/os/pages/marketing/public/css/edit_coupon.scss
Executable file
@@ -0,0 +1,199 @@
|
||||
.coupons-form {
|
||||
position: relative;
|
||||
.common-wrap.fixd {
|
||||
padding: 30rpx;
|
||||
height: calc(100vh - 0.4rem);
|
||||
overflow-y: auto;
|
||||
box-sizing: border-box;
|
||||
|
||||
.form-label {
|
||||
width: 1.7rem !important;
|
||||
}
|
||||
|
||||
.form-input-inline /deep/ .uni-select {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.common-btn-wrap {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
padding: 0.24rem 0.2rem;
|
||||
}
|
||||
|
||||
.form-word-aux-line {
|
||||
margin-left: 1.7rem !important;
|
||||
.gooods_select{
|
||||
margin: 0;
|
||||
}
|
||||
.goods_names{
|
||||
margin-left: 0.15rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.upload-box {
|
||||
border: 0.01rem dashed #e6e6e6 !important;
|
||||
width: 2.5rem !important;
|
||||
height: 1.2rem !important;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.upload {
|
||||
text-align: center;
|
||||
color: #5a5a5a;
|
||||
|
||||
.iconfont {
|
||||
font-size: 0.3rem;
|
||||
}
|
||||
|
||||
image {
|
||||
max-width: 100%;
|
||||
height: 1.2rem !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.coupons-img {
|
||||
align-items: flex-start !important;
|
||||
}
|
||||
|
||||
.map-box {
|
||||
width: 6.5rem;
|
||||
height: 5rem;
|
||||
position: relative;
|
||||
|
||||
.map-icon {
|
||||
position: absolute;
|
||||
top: calc(50% - 0.36rem);
|
||||
left: calc(50% - 0.18rem);
|
||||
width: 0.36rem;
|
||||
height: 0.36rem;
|
||||
z-index: 100;
|
||||
}
|
||||
}
|
||||
|
||||
.form-input {
|
||||
font-size: 0.16rem;
|
||||
}
|
||||
|
||||
.form-input-inline.btn {
|
||||
height: 0.37rem;
|
||||
line-height: 0.35rem;
|
||||
box-sizing: border-box;
|
||||
border: 0.01rem solid #e6e6e6;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.common-title {
|
||||
font-size: 0.18rem;
|
||||
margin-bottom: 0.2rem;
|
||||
}
|
||||
/deep/ .uni-select-lay-select{
|
||||
height: 0.37rem;
|
||||
width: 2.52rem;
|
||||
margin: 0;
|
||||
}
|
||||
.radio-list{
|
||||
width: 7rem !important;
|
||||
}
|
||||
.radio-item{
|
||||
margin-right: 0.1rem;
|
||||
}
|
||||
/deep/ .uni-date-x{
|
||||
height: 0.37rem;
|
||||
|
||||
}
|
||||
.top{
|
||||
margin-top: 0.1rem;
|
||||
|
||||
}
|
||||
.w-250{
|
||||
width: 2.5rem;
|
||||
}
|
||||
.form-input-inline{
|
||||
width: 2.5rem;
|
||||
}
|
||||
.required{
|
||||
color: red;
|
||||
}
|
||||
.table-wrap {
|
||||
position: relative;
|
||||
border: 1rpx solid #ccc;
|
||||
color: #333;
|
||||
.table-head {
|
||||
background-color: #f7f7f7;
|
||||
}
|
||||
|
||||
.table-body {
|
||||
.table-tr {
|
||||
&:last-of-type .table-td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.table-tr {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.table-th,
|
||||
.table-td {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0.07rem 0.3rem;
|
||||
border-bottom: 0.01rem solid #ccc;
|
||||
border-right: 0.01rem solid #ccc;
|
||||
text-align: center;
|
||||
|
||||
&:last-of-type {
|
||||
border-right: 0;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
&.goods-name {
|
||||
-webkit-box-pack: start;
|
||||
-ms-flex-pack: start;
|
||||
-webkit-justify-content: flex-start;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.delete {
|
||||
margin: 0;
|
||||
font-size: $uni-font-size-base;
|
||||
background-color: $primary-color;
|
||||
color: #fff;
|
||||
line-height: 0.32rem;
|
||||
height: 0.32rem;
|
||||
&::after{
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.table-empty {
|
||||
justify-content: center;
|
||||
padding: 0.3rem;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
.gooods_select{
|
||||
background-color: $primary-color;
|
||||
color: #fff;
|
||||
display: inline-block;
|
||||
padding: 0 0.2rem;
|
||||
height: 0.36rem;
|
||||
line-height: .36rem;
|
||||
font-size: 0.14rem;
|
||||
border-radius: 3px;
|
||||
margin-top: 0.1rem;
|
||||
&::after{
|
||||
border-width: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
169
addon/cashier/source/os/pages/marketing/public/js/coupon_detail.js
Executable file
169
addon/cashier/source/os/pages/marketing/public/js/coupon_detail.js
Executable file
@@ -0,0 +1,169 @@
|
||||
import {getCouponDetail } from '@/api/marketing.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
couponsData: {
|
||||
coupon_type_id:'',
|
||||
coupon_name: "",
|
||||
type: "reward",
|
||||
money: "",
|
||||
discount: "",
|
||||
discount_limit: "",
|
||||
at_least: "",
|
||||
is_show: 1,
|
||||
count: "",
|
||||
max_fetch: "",
|
||||
image: "",
|
||||
validity_type: 0,
|
||||
end_time: this.$util.timeFormat(Date.parse(new Date()) / 1000),
|
||||
fixed_term: 0,
|
||||
goods_type:1,
|
||||
lead_count:0,
|
||||
used_count:0,
|
||||
use_channel:'',
|
||||
use_store:'',
|
||||
use_store_list:[],
|
||||
goods_list:[]
|
||||
},
|
||||
loading:false,
|
||||
cols: [{
|
||||
field: 'account_data',
|
||||
width: 20,
|
||||
title: '会员信息',
|
||||
align: 'left',
|
||||
templet: data => {
|
||||
let img = this.$util.img(data.headimg);
|
||||
let html = `
|
||||
<view class="member-content flex">
|
||||
<image class="member-img" src="${img}" mode="aspectFit"/>
|
||||
<view class="flex flex-col justify-between">
|
||||
<text class="member-nickname multi-hidden">${data.nickname}</text>
|
||||
<text class="member-mobile multi-hidden">${data.mobile}</text>
|
||||
</view>
|
||||
</view>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'coupon_name',
|
||||
width: 15,
|
||||
title: '优惠券',
|
||||
align: 'left',
|
||||
},{
|
||||
title: '类型',
|
||||
width: 10,
|
||||
unresize: 'false',
|
||||
templet: data=> {
|
||||
return data.type == 'reward' ? '满减券' : '折扣券';
|
||||
}
|
||||
},{
|
||||
field: 'get_type_name',
|
||||
width: 15,
|
||||
title: '获取方式',
|
||||
align: 'left',
|
||||
},{
|
||||
title: '状态',
|
||||
width: 10,
|
||||
unresize: 'false',
|
||||
templet: data=> {
|
||||
var str = '';
|
||||
switch (data.state) {
|
||||
case 1:
|
||||
str = '已领取';
|
||||
break;
|
||||
case 2:
|
||||
str = '已使用';
|
||||
break;
|
||||
case 3:
|
||||
str = '已过期';
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
},{
|
||||
title: '领取时间',
|
||||
width: 15,
|
||||
unresize: 'false',
|
||||
templet: data=> {
|
||||
return this.$util.timeFormat(Date.parse(new Date(data.fetch_time)));
|
||||
}
|
||||
}, {
|
||||
title: '使用时间',
|
||||
width: 15,
|
||||
templet: data=> {
|
||||
return data.use_time ? this.$util.timeFormat(Date.parse(new Date(data.use_time))) : '';
|
||||
}
|
||||
},],
|
||||
statusList: [{
|
||||
value: '',
|
||||
label: '全部'
|
||||
},{
|
||||
value: '1',
|
||||
label: '已领取'
|
||||
}, {
|
||||
value: '2',
|
||||
label: '已使用'
|
||||
},
|
||||
{
|
||||
value: '3',
|
||||
label: '已过期'
|
||||
}],
|
||||
option:{
|
||||
page_size: 9,
|
||||
coupon_type_id:'',
|
||||
state: '',
|
||||
},
|
||||
goodsListCols:[{
|
||||
field: 'goods_name',
|
||||
width: 60,
|
||||
title: '商品名称',
|
||||
align: 'left',
|
||||
},{
|
||||
title: '价格',
|
||||
width: 20,
|
||||
unresize: 'false',
|
||||
templet: data=> {
|
||||
return data.price || '0.00';
|
||||
}
|
||||
},{
|
||||
title: '库存',
|
||||
width: 20,
|
||||
unresize: 'false',
|
||||
templet: data=> {
|
||||
return data.goods_stock || 0;
|
||||
}
|
||||
},]
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
if(option.coupon_type_id){
|
||||
this.couponsData.coupon_type_id = option.coupon_type_id
|
||||
this.option.coupon_type_id = option.coupon_type_id
|
||||
this.getData(option.coupon_type_id)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getData(coupon_type_id) {
|
||||
this.loading = true
|
||||
getCouponDetail(coupon_type_id).then(res=>{
|
||||
let data = res.data;
|
||||
if(res.code>=0 && data) {
|
||||
Object.keys(this.couponsData).forEach(key => {
|
||||
this.couponsData[key] = data.info[key]
|
||||
if (key == 'end_time') this.couponsData[key] = this.couponsData.end_time = this.$util.timeFormat(Date.parse(new Date(data.info[key])))
|
||||
})
|
||||
}
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
queryRecord(val){
|
||||
this.option.state = val
|
||||
this.$refs.couponListTable.load({
|
||||
page: 1
|
||||
});
|
||||
},
|
||||
backFn() {
|
||||
this.$util.redirectTo('/pages/marketing/coupon_list');
|
||||
},
|
||||
}
|
||||
}
|
||||
221
addon/cashier/source/os/pages/marketing/public/js/coupon_list.js
Executable file
221
addon/cashier/source/os/pages/marketing/public/js/coupon_list.js
Executable file
@@ -0,0 +1,221 @@
|
||||
import {closeCoupon, deleteCoupon} from '@/api/marketing.js';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
option: {
|
||||
page_size: 10,
|
||||
coupon_name: '',
|
||||
type: '',
|
||||
status: '',
|
||||
use_channel: '',
|
||||
},
|
||||
coupon_type_id: "",
|
||||
flag: false,
|
||||
typeList: [{
|
||||
value: 'reward',
|
||||
label: '满减'
|
||||
}, {
|
||||
value: 'discount',
|
||||
label: '折扣'
|
||||
},],
|
||||
statusList: [{
|
||||
value: '1',
|
||||
label: '进行中'
|
||||
}, {
|
||||
value: '2',
|
||||
label: '已结束'
|
||||
}, {
|
||||
value: '-1',
|
||||
label: '已关闭'
|
||||
}],
|
||||
// validityTypeList:[{
|
||||
// value: '0',
|
||||
// label: '固定时间'
|
||||
// }, {
|
||||
// value: '1',
|
||||
// label: '相对时间'
|
||||
// },
|
||||
// {
|
||||
// value: '2',
|
||||
// label: '长期有效'
|
||||
// }],
|
||||
useChannelList:[
|
||||
{
|
||||
value: 'all',
|
||||
label: '线上线下使用'
|
||||
},
|
||||
{
|
||||
value: 'online',
|
||||
label: '线上使用'
|
||||
},
|
||||
{
|
||||
value: 'offline',
|
||||
label: '线下使用'
|
||||
},
|
||||
],
|
||||
cols: [{
|
||||
field: 'coupon_name',
|
||||
width: 15,
|
||||
title: '优惠券名称',
|
||||
align: 'left',
|
||||
}, {
|
||||
field: 'reward',
|
||||
title: '优惠券类型',
|
||||
align: 'left',
|
||||
width: 10,
|
||||
templet: function (data) {
|
||||
if (data.type == 'reward') {
|
||||
return '满减';
|
||||
} else {
|
||||
return '折扣';
|
||||
}
|
||||
}
|
||||
}, {
|
||||
title: '优惠金额/折扣',
|
||||
width: 10,
|
||||
align: 'left',
|
||||
templet: function (data) {
|
||||
if (data.type == 'reward') {
|
||||
return `<span style="padding-right: 15px;">¥${data.money}</span>`;
|
||||
} else {
|
||||
return `<span style="padding-right: 15px;">${data.discount}折</span>`;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
field: 'count',
|
||||
title: '发放数量',
|
||||
width: 10,
|
||||
templet: function (data) {
|
||||
return data.is_show == 0 || data.count == -1 ? '无限制' : data.count;
|
||||
}
|
||||
}, {
|
||||
title: '剩余数量',
|
||||
width: 10,
|
||||
templet: function (data) {
|
||||
return data.is_show == 0 || data.count == -1 ? '无限制' : data.count - data.lead_count;
|
||||
}
|
||||
}, {
|
||||
title: '领取上限',
|
||||
width: 10,
|
||||
templet: function (data) {
|
||||
return data.is_show == 0 || data.max_fetch == 0 ? '无领取限制' : data.max_fetch + '张/人';
|
||||
}
|
||||
}, {
|
||||
title: '有效期限',
|
||||
unresize: 'false',
|
||||
width: 15,
|
||||
templet: (data) => {
|
||||
if (data.validity_type == 0) {
|
||||
return `失效期:${this.$util.timeFormat(data.end_time)}`
|
||||
} else if (data.validity_type == 1) {
|
||||
return `领取后,${data.fixed_term}天有效`
|
||||
} else {
|
||||
return '长期有效'
|
||||
}
|
||||
}
|
||||
},{
|
||||
field: 'use_channel_name',
|
||||
title: '适用场景',
|
||||
unresize: 'false',
|
||||
width: 10
|
||||
}, {
|
||||
field: 'status_name',
|
||||
title: '状态',
|
||||
width: 10
|
||||
}, {
|
||||
width: 10,
|
||||
title: '操作',
|
||||
align: 'right',
|
||||
action: true
|
||||
}],
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
},
|
||||
methods: {
|
||||
switchStoreAfter() {
|
||||
this.searchFn();
|
||||
},
|
||||
selectCouponsType(index) {
|
||||
this.option.type = index == -1 ? '' : this.typeList[index].value;
|
||||
},
|
||||
selectStatus(index) {
|
||||
this.option.status = index == -1 ? '' : this.statusList[index].value;
|
||||
},
|
||||
selectUseChannel(index) {
|
||||
this.option.use_channel = index == -1 ? '' : this.useChannelList[index].value;
|
||||
},
|
||||
// selectValidityType(index){
|
||||
// this.option.validity_type = index == -1 ? '' : this.validityTypeList[index].value;
|
||||
// },
|
||||
// 搜索商品
|
||||
searchFn() {
|
||||
this.$refs.couponListTable.load({
|
||||
page: 1
|
||||
});
|
||||
},
|
||||
resetFn() {
|
||||
this.option = {
|
||||
page_size: 10,
|
||||
coupon_name: '',
|
||||
type: '',
|
||||
status: '',
|
||||
}
|
||||
this.$refs.couponListTable.load({
|
||||
page: 1,
|
||||
coupon_name: '',
|
||||
type: '',
|
||||
status: '',
|
||||
});
|
||||
},
|
||||
add() {
|
||||
this.$util.redirectTo('/pages/marketing/edit_coupon');
|
||||
},
|
||||
detail(coupon_type_id) {
|
||||
this.$util.redirectTo('/pages/marketing/coupon_detail', {
|
||||
coupon_type_id
|
||||
});
|
||||
},
|
||||
edit(coupon_type_id) {
|
||||
this.$util.redirectTo('/pages/marketing/edit_coupon', {
|
||||
coupon_type_id
|
||||
});
|
||||
},
|
||||
closeOpen(coupon_type_id) {
|
||||
this.coupon_type_id = coupon_type_id
|
||||
this.$refs.closeCouponsPop.open()
|
||||
},
|
||||
close() {
|
||||
if (this.flag) return false;
|
||||
this.flag = true;
|
||||
this.$refs.closeCouponsPop.close()
|
||||
closeCoupon(this.coupon_type_id).then(res => {
|
||||
if (res.code >= 0) {
|
||||
this.flag = false;
|
||||
|
||||
this.$refs.couponListTable.load();
|
||||
}
|
||||
})
|
||||
},
|
||||
deleteOpen(coupon_type_id) {
|
||||
this.coupon_type_id = coupon_type_id
|
||||
this.$refs.deleteCouponsPop.open()
|
||||
},
|
||||
del() {
|
||||
if (this.flag) return false;
|
||||
this.flag = true;
|
||||
this.$refs.deleteCouponsPop.close()
|
||||
deleteCoupon(this.coupon_type_id).then(res => {
|
||||
if (res.code >= 0) {
|
||||
this.flag = false;
|
||||
|
||||
this.$refs.couponListTable.load();
|
||||
}
|
||||
})
|
||||
},
|
||||
promotion(coupon_type_id){
|
||||
this.$refs.promotionPop.open({coupon_type_id})
|
||||
}
|
||||
}
|
||||
}
|
||||
382
addon/cashier/source/os/pages/marketing/public/js/edit_coupon.js
Executable file
382
addon/cashier/source/os/pages/marketing/public/js/edit_coupon.js
Executable file
@@ -0,0 +1,382 @@
|
||||
import {
|
||||
getCouponDetail,
|
||||
addCoupon,
|
||||
editCoupon,
|
||||
} from '@/api/marketing.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
couponsData: {
|
||||
coupon_type_id: '',
|
||||
coupon_name: "",
|
||||
type: "reward",
|
||||
money: "",
|
||||
discount: "",
|
||||
discount_limit: "",
|
||||
at_least: "",
|
||||
is_show: 1,
|
||||
count: "",
|
||||
max_fetch: "",
|
||||
image: "",
|
||||
validity_type: 0,
|
||||
end_time: this.$util.timeFormat((Date.parse(new Date()) / 1000) + (10 * 24 * 60 * 60)),
|
||||
fixed_term: 0,
|
||||
goods_type: 1,
|
||||
goods_ids: '',
|
||||
goods_ids_real:'',
|
||||
goods_list: [],
|
||||
goods_names:'',
|
||||
use_channel:'all',
|
||||
},
|
||||
flag: false,
|
||||
goods_ids: [],
|
||||
typeList: [{
|
||||
value: 'reward',
|
||||
text: '满减'
|
||||
}, {
|
||||
value: 'discount',
|
||||
text: '折扣'
|
||||
},],
|
||||
validityTypeList: [{
|
||||
value: 0,
|
||||
text: '固定时间'
|
||||
}, {
|
||||
value: 1,
|
||||
text: '领取之日起'
|
||||
}, {
|
||||
value: 2,
|
||||
text: '长期有效'
|
||||
}],
|
||||
goodsTypeList: [{
|
||||
value: 1,
|
||||
text: '全部商品参与'
|
||||
}, {
|
||||
value: 2,
|
||||
text: '指定商品参与'
|
||||
}, {
|
||||
value: 3,
|
||||
text: '指定商品不参与'
|
||||
}, {
|
||||
value: 4,
|
||||
text: '指定分类参与'
|
||||
}, {
|
||||
value: 5,
|
||||
text: '指定分类不参与'
|
||||
}],
|
||||
|
||||
useChannelList: [{
|
||||
value: 'all',
|
||||
text: '线上线下使用'
|
||||
}, {
|
||||
value: 'online',
|
||||
text: '线上使用'
|
||||
}, {
|
||||
value: 'offline',
|
||||
text: '线下使用'
|
||||
}],
|
||||
dialogVisible: false
|
||||
};
|
||||
},
|
||||
onLoad(option) {
|
||||
if (option.coupon_type_id) {
|
||||
this.couponsData.coupon_type_id = option.coupon_type_id
|
||||
this.getData(option.coupon_type_id)
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'couponsData.validity_type'(newValue) {
|
||||
if (newValue === 0) this.couponsData.end_time = this.$util.timeFormat((Date.parse(new Date()) / 1000) + (10 * 24 * 60 * 60))
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getData(coupon_type_id) {
|
||||
getCouponDetail(coupon_type_id).then(res => {
|
||||
let data = res.data;
|
||||
if (res.code >= 0 && data) {
|
||||
Object.keys(this.couponsData).forEach(key => {
|
||||
this.couponsData[key] = data.info[key]
|
||||
if (key == 'end_time') this.couponsData[key] = this.couponsData.end_time = this.$util.timeFormat(Date.parse(new Date(data.info[key])))
|
||||
})
|
||||
}
|
||||
this.goods_ids = this.couponsData.goods_list.map(v => v.goods_id)
|
||||
this.couponsData.goods_ids = this.goods_ids.join()
|
||||
})
|
||||
},
|
||||
addImg() {
|
||||
this.$util.upload(1, {
|
||||
path: 'image'
|
||||
}, res => {
|
||||
if (res.length > 0) {
|
||||
this.couponsData.image = res[0];
|
||||
this.$forceUpdate();
|
||||
}
|
||||
});
|
||||
},
|
||||
checkIsShow(e) {
|
||||
this.couponsData.is_show = e.detail.value ? 1 : 0
|
||||
},
|
||||
changeTime(data) {
|
||||
this.couponsData.end_time = data;
|
||||
},
|
||||
selectGoods(data) { //选择数据
|
||||
data.forEach(el => {
|
||||
if (!this.goods_ids.includes(el.goods_id)) {
|
||||
this.goods_ids.push(el.goods_id)
|
||||
this.couponsData.goods_list.push(el)
|
||||
}
|
||||
})
|
||||
},
|
||||
delGoods(id) {//删除已选择的商品
|
||||
this.couponsData.goods_list.splice(this.goods_ids.indexOf(id), 1);
|
||||
this.goods_ids.splice(this.goods_ids.indexOf(id), 1);
|
||||
},
|
||||
checkData() {
|
||||
let _this = this
|
||||
let verify = {
|
||||
days: function (value) {
|
||||
if (_this.couponsData.validity_type == 1) {
|
||||
if (value % 1 != 0) {
|
||||
return '请输入整数';
|
||||
}
|
||||
if (value <= 0) {
|
||||
return '有效天数不能小于等于0';
|
||||
}
|
||||
return ''
|
||||
}
|
||||
return ''
|
||||
},
|
||||
number: function (value) {
|
||||
if (value < 0) {
|
||||
return '请输入不小于0的数!'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
coupon_money: function (value) {
|
||||
if (parseFloat(value) > 10000) {
|
||||
return '优惠券面额不能大于10000'
|
||||
}
|
||||
if (parseFloat(value) <= 0) {
|
||||
return '优惠券面额不能小于0'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
int: function (value) {
|
||||
if (value % 1 != 0) {
|
||||
return '最多优惠,请输入整数!'
|
||||
}
|
||||
if (value < 0) {
|
||||
return '最多优惠,请输入大于0的数!'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
money: function (value) {
|
||||
if (value < 0) {
|
||||
return '金额不能小于0'
|
||||
}
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return '保留小数点后两位'
|
||||
}
|
||||
return ''
|
||||
},
|
||||
time: function (value) {
|
||||
if (_this.couponsData.validity_type == 0) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var end_time = (new Date(value)).getTime();
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
return ''
|
||||
}
|
||||
return ''
|
||||
},
|
||||
max: function (value) {
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请输入最大领取数量';
|
||||
}
|
||||
|
||||
if (_this.couponsData.count != -1 && parseFloat(value) > parseFloat(_this.couponsData.count)) {
|
||||
return '最大领取数量不能超过发放数量!';
|
||||
}
|
||||
return ''
|
||||
},
|
||||
fl: function (value, str) {
|
||||
str = str.substring(0, str.length - 1);
|
||||
|
||||
if (value < 1) {
|
||||
return str + "不能小于1折";
|
||||
}
|
||||
|
||||
if (value > 9.9) {
|
||||
return str + "不能大于9.9折";
|
||||
}
|
||||
|
||||
var arrMen = value.split(".");
|
||||
var val = 0;
|
||||
if (arrMen.length == 2) {
|
||||
val = arrMen[1];
|
||||
}
|
||||
if (val.length > 2) {
|
||||
return str + "最多可保留两位小数";
|
||||
}
|
||||
return ''
|
||||
},
|
||||
count: function (value) {
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请输入发放数量';
|
||||
}
|
||||
if (value % 1 != 0) {
|
||||
return '请输入整数';
|
||||
}
|
||||
if (value == 0) {
|
||||
return '发放数量不能为0';
|
||||
}
|
||||
if (value != -1 && parseInt(value) < parseInt('{$coupon_type_info.count}')) {
|
||||
return '发放数量不能小于原发放数量!';
|
||||
}
|
||||
return ''
|
||||
}
|
||||
};
|
||||
|
||||
if (!this.couponsData.coupon_name) {
|
||||
this.$util.showToast({
|
||||
title: "请输入优惠券名称"
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (!this.couponsData.type) {
|
||||
this.$util.showToast({
|
||||
title: "请选择优惠券类型"
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (this.couponsData.type === 'reward') {
|
||||
if (!this.couponsData.money) {
|
||||
this.$util.showToast({
|
||||
title: "请输入优惠券面额"
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (verify.number(this.couponsData.money) || verify.money(this.couponsData.money) || verify.coupon_money(this.couponsData.money)) {
|
||||
this.$util.showToast({
|
||||
title: verify.number(this.couponsData.money) || verify.money(this.couponsData.money) || verify.coupon_money(this.couponsData.money)
|
||||
});
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
if (!this.couponsData.discount) {
|
||||
this.$util.showToast({
|
||||
title: "请输入优惠券折扣"
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (verify.fl(this.couponsData.discount, '优惠券折扣')) {
|
||||
this.$util.showToast({
|
||||
title: verify.fl(this.couponsData.discount, '优惠券折扣')
|
||||
});
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (this.couponsData.discount_limit) {
|
||||
if (verify.number(this.couponsData.discount_limit) || verify.int(this.couponsData.discount_limit)) {
|
||||
this.$util.showToast({
|
||||
title: verify.number(this.couponsData.discount_limit) || verify.int(this.couponsData.discount_limit)
|
||||
});
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (!this.couponsData.at_least) {
|
||||
this.$util.showToast({
|
||||
title: "请输入满多少元可以使用"
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (verify.number(this.couponsData.at_least) || verify.money(this.couponsData.at_least)) {
|
||||
this.$util.showToast({
|
||||
title: verify.number(this.couponsData.at_least) || verify.money(this.couponsData.at_least)
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (this.couponsData.is_show === 1) {
|
||||
if (verify.count(this.couponsData.count)) {
|
||||
this.$util.showToast({
|
||||
title: verify.count(this.couponsData.count)
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (verify.max(this.couponsData.max_fetch)) {
|
||||
this.$util.showToast({
|
||||
title: verify.max(this.couponsData.max_fetch)
|
||||
});
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (verify.time(this.couponsData.end_time)) {
|
||||
this.$util.showToast({
|
||||
title: verify.time(this.couponsData.end_time)
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (verify.days(this.couponsData.fixed_term)) {
|
||||
this.$util.showToast({
|
||||
title: verify.days(this.couponsData.fixed_term)
|
||||
});
|
||||
return false
|
||||
}
|
||||
if (this.couponsData.goods_type == 2||this.couponsData.goods_type == 3) {
|
||||
if (!this.goods_ids.length) {
|
||||
this.$util.showToast({
|
||||
title: '请选择活动商品'
|
||||
});
|
||||
return false
|
||||
}
|
||||
}
|
||||
if (this.couponsData.goods_type == 4||this.couponsData.goods_type == 5) {
|
||||
if (!this.goods_ids.length) {
|
||||
this.$util.showToast({
|
||||
title: '请选择商品分类'
|
||||
});
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
},
|
||||
goodsType(){
|
||||
this.couponsData.goods_ids = ''
|
||||
this.couponsData.goods_ids_real = ''
|
||||
this.goods_ids = []
|
||||
this.couponsData.goods_names = ''
|
||||
},
|
||||
goodsCategoryConfirm(obj){
|
||||
this.goods_ids = obj.id_arr;
|
||||
this.couponsData.goods_names = obj.name_arr.join('、');
|
||||
},
|
||||
saveFn() {
|
||||
if (this.checkData(this.couponsData)) {
|
||||
if (this.flag) return false;
|
||||
this.flag = true;
|
||||
if (this.couponsData.goods_type != 1) this.couponsData.goods_ids = this.goods_ids.join();
|
||||
let save = this.couponsData.coupon_type_id ? editCoupon : addCoupon;
|
||||
save(this.couponsData).then(res => {
|
||||
this.flag = false;
|
||||
this.$util.showToast({
|
||||
title: res.message
|
||||
});
|
||||
if (res.code >= 0) {
|
||||
setTimeout(() => {
|
||||
this.backFn();
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
backFn() {
|
||||
this.$util.redirectTo('/pages/marketing/coupon_list');
|
||||
},
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user