初始上传
This commit is contained in:
126
addon/cashier/source/os/pages/marketing/coupon_detail.vue
Executable file
126
addon/cashier/source/os/pages/marketing/coupon_detail.vue
Executable file
@@ -0,0 +1,126 @@
|
||||
<template>
|
||||
<base-page>
|
||||
<view class="coupons-detail">
|
||||
<view class="common-wrap common-form fixd common-scrollbar" v-if="!loading">
|
||||
<view class="title-back flex items-center cursor-pointer" @click="backFn">
|
||||
<text class="iconfont iconqianhou1"></text>
|
||||
<text class="left">返回</text>
|
||||
<text class="content">|</text>
|
||||
<text>优惠券详情</text>
|
||||
</view>
|
||||
<view class="common-title">基本信息</view>
|
||||
<view class="flex flex-wrap">
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">优惠券名称:</label>
|
||||
<view class="form-input-inline">{{ couponsData.coupon_name }}</view>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">优惠券类型:</label>
|
||||
<view class="form-input-inline">{{ couponsData.type == 'reward' ? '满减' : '折扣' }}</view>
|
||||
</view>
|
||||
<view class="common-form-item" v-if="couponsData.type == 'reward'">
|
||||
<label class="form-label">优惠面额:</label>
|
||||
<view class="form-input-inline">¥{{ couponsData.money }}元</view>
|
||||
</view>
|
||||
<view class="common-form-item" v-else>
|
||||
<label class="form-label">优惠券折扣:</label>
|
||||
<view class="form-input-inline">{{ couponsData.discount }}折</view>
|
||||
</view>
|
||||
<view class="common-form-item" v-if="couponsData.type == 'discount' && couponsData.discount_limit != 0">
|
||||
<label class="form-label">最多优惠:</label>
|
||||
<view class="form-input-inline">¥{{ couponsData.discount_limit }}元</view>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">使用门槛: </label>
|
||||
<view class="form-input-inline">¥{{ couponsData.at_least }}元</view>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">是否允许直接领取:</label>
|
||||
<view class="form-input-inline">{{ couponsData.is_show === 1 ? '是' : '否' }}</view>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">发放数量:</label>
|
||||
<view class="form-input-inline">{{ (couponsData.is_show == 0 || couponsData.count == -1) ? '无限制' : couponsData.count + '张' }}</view>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">最大领取数量:</label>
|
||||
<view class="form-input-inline" v-if="couponsData.is_show == 0 || couponsData.max_fetch == 0">无领取限制</view>
|
||||
<view class="form-input-inline" v-else>{{ couponsData.max_fetch }}张/人</view>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">有效期:</label>
|
||||
<view class="form-input-inline radio-list" v-if="couponsData.validity_type == 0">{{ couponsData.end_time }}</view>
|
||||
<view class="form-input-inline radio-list" v-else-if="couponsData.validity_type == 1">领取后 {{ couponsData.fixed_term }}天 有效</view>
|
||||
<view class="form-input-inline radio-list" v-else>长期有效</view>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">使用渠道:</label>
|
||||
<view class="form-input-inline">
|
||||
{{ couponsData.use_channel === 'all' ? '线上线下使用' :couponsData.use_channel === 'online' ?'线上使用':'线下使用' }}
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="couponsData.use_channel != 'online'" class="common-form-item">
|
||||
<label class="form-label">适用门店:</label>
|
||||
<view class="form-input-inline truncate">
|
||||
<text v-if="couponsData.use_store === 'all'">全部门店</text>
|
||||
<text v-else :title="couponsData.use_store_list.map(v=>{return v.store_name}).join('、')">{{ couponsData.use_store_list.map(v=>{return v.store_name}).join('、') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">活动商品:</label>
|
||||
<view class="form-input-inline radio-list">
|
||||
{{couponsData.goods_type == 1 ? '全部商品参与' : couponsData.goods_type == 2 ? '指定商品参与' : '指定不参与商品' }}
|
||||
</view>
|
||||
</view>
|
||||
<view class="common-form-item coupons-img">
|
||||
<label class="form-label">优惠券图片:</label>
|
||||
<view class="form-input-inline upload-box">
|
||||
<view class="upload">
|
||||
<image :src="$util.img(couponsData.image)" mode="heightFix" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="common-title">数据统计</view>
|
||||
<view class="data flex flex-wrap">
|
||||
<view class="data-item">
|
||||
<view class="title">发放数</view>
|
||||
<view class="content">{{ couponsData.count||0 }}</view>
|
||||
</view>
|
||||
<view class="data-item">
|
||||
<view class="title">领取数</view>
|
||||
<view class="content">{{ couponsData.lead_count||0 }}</view>
|
||||
</view>
|
||||
<view class="data-item">
|
||||
<view class="title">使用数</view>
|
||||
<view class="content">{{ couponsData.used_count||0 }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="common-title mt-20">领取记录</view>
|
||||
<view class="record flex">
|
||||
<block v-for="item in statusList">
|
||||
<view :class="{'active':item.value==option.state}" type="default" @click="queryRecord(item.value)">{{ item.label }}</view>
|
||||
</block>
|
||||
</view>
|
||||
<uniDataTable url="/coupon/storeapi/membercoupon/getReceiveCouponPageList" :option="option" :cols="cols" ref="couponListTable" />
|
||||
<block v-if="couponsData.goods_type!=1">
|
||||
<view class="common-title mt-20">{{couponsData.goods_type==2?'指定商品参与':'指定不参与商品'}}</view>
|
||||
<uniDataTable :cols="goodsListCols" :data="couponsData.goods_list" classType />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</base-page>
|
||||
</template>
|
||||
<script>
|
||||
import couponDetail from './public/js/coupon_detail.js';
|
||||
import uniDataTable from '@/components/uni-data-table/uni-data-table.vue';
|
||||
export default {
|
||||
components:{
|
||||
uniDataTable
|
||||
},
|
||||
mixins: [couponDetail]
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import './public/css/coupon_detail.scss';
|
||||
</style>
|
||||
102
addon/cashier/source/os/pages/marketing/coupon_list.vue
Executable file
102
addon/cashier/source/os/pages/marketing/coupon_list.vue
Executable file
@@ -0,0 +1,102 @@
|
||||
<template>
|
||||
<base-page>
|
||||
<view class="coupons-list">
|
||||
<view class="add-coupons">
|
||||
<button type="default" class="screen-btn" @click="add">添加优惠券</button>
|
||||
</view>
|
||||
<view class="screen-warp common-form">
|
||||
<view class="common-form-item">
|
||||
<view class="form-inline">
|
||||
<label class="form-label">优惠券名称</label>
|
||||
<view class="form-input-inline">
|
||||
<input type="text" v-model="option.coupon_name" placeholder="请输入优惠券名称" class="form-input" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-inline">
|
||||
<label class="form-label">优惠券类型</label>
|
||||
<view class="form-input-inline border-0">
|
||||
<select-lay :zindex="10" :value="option.type" name="type" placeholder="请选择优惠券类型" :options="typeList" @selectitem="selectCouponsType"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-inline">
|
||||
<label class="form-label">优惠券状态</label>
|
||||
<view class="form-input-inline border-0">
|
||||
<select-lay :zindex="9" :value="option.status" name="status" placeholder="请选择优惠券状态" :options="statusList" @selectitem="selectStatus"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="form-inline">
|
||||
<label class="form-label">适用场景</label>
|
||||
<view class="form-input-inline border-0">
|
||||
<select-lay :zindex="9" :value="option.use_channel" name="status" placeholder="请选择优惠券状态" :options="useChannelList" @selectitem="selectUseChannel"/>
|
||||
</view>
|
||||
</view>
|
||||
<!-- <view class="form-inline">
|
||||
<label class="form-label">有效期限</label>
|
||||
<view class="form-input-inline border-0">
|
||||
<select-lay :zindex="9" :value="option.validity_type" name="validity_type" placeholder="请选择有效期限" :options="validityTypeList" @selectitem="selectValidityType"/>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="form-inline common-btn-wrap">
|
||||
<button type="default" class="screen-btn" @click="searchFn()">筛选</button>
|
||||
<button type="default" @click="resetFn()">重置</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<uniDataTable url="/coupon/storeapi/coupon/lists" :option="option" :cols="cols" ref="couponListTable">
|
||||
<template v-slot:action="dataTable">
|
||||
<view class="action-btn-wrap">
|
||||
<text v-if="dataTable.value.status=='1'" class="action-item" @click="promotion(dataTable.value.coupon_type_id)">推广</text>
|
||||
<text v-if="dataTable.value.status=='1' && globalStoreInfo.store_id===dataTable.value.store_id" class="action-item" @click="edit(dataTable.value.coupon_type_id)">编辑</text>
|
||||
<text class="action-item" @click="detail(dataTable.value.coupon_type_id)">详情</text>
|
||||
<text v-if="dataTable.value.status=='1' && globalStoreInfo.store_id===dataTable.value.store_id" class="action-item" @click="closeOpen(dataTable.value.coupon_type_id)">关闭</text>
|
||||
<text v-if="dataTable.value.status!='1' && globalStoreInfo.store_id===dataTable.value.store_id" class="action-item" @click="deleteOpen(dataTable.value.coupon_type_id)">删除</text>
|
||||
</view>
|
||||
</template>
|
||||
</uniDataTable>
|
||||
</view>
|
||||
<!-- 推广 -->
|
||||
<ns-promotion-popup ref="promotionPop" />
|
||||
<!-- 关闭 -->
|
||||
<unipopup ref="closeCouponsPop" type="center">
|
||||
<view class="confirm-pop">
|
||||
<view class="title">确定要关闭该优惠券吗?</view>
|
||||
<view class="btn">
|
||||
<button type="primary" class="default-btn btn save" @click="$refs.closeCouponsPop.close()">取消</button>
|
||||
<button type="primary" class="primary-btn btn" @click="close">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</unipopup>
|
||||
|
||||
<!-- 删除 -->
|
||||
<unipopup ref="deleteCouponsPop" type="center">
|
||||
<view class="confirm-pop">
|
||||
<view class="title">确定要删除该优惠券吗?</view>
|
||||
<view class="btn">
|
||||
<button type="primary" class="default-btn btn save" @click="$refs.deleteCouponsPop.close()">取消</button>
|
||||
<button type="primary" class="primary-btn btn" @click="del">确定</button>
|
||||
</view>
|
||||
</view>
|
||||
</unipopup>
|
||||
|
||||
</base-page>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import uniDataTable from '@/components/uni-data-table/uni-data-table.vue';
|
||||
import nsPromotionPopup from '@/components/ns-promotion-popup/ns-promotion-popup.vue';
|
||||
import unipopup from '@/components/uni-popup/uni-popup.vue';
|
||||
import couponList from './public/js/coupon_list.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
unipopup,
|
||||
uniDataTable,
|
||||
nsPromotionPopup
|
||||
},
|
||||
mixins: [couponList]
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import './public/css/coupon_list.scss';
|
||||
</style>
|
||||
167
addon/cashier/source/os/pages/marketing/edit_coupon.vue
Executable file
167
addon/cashier/source/os/pages/marketing/edit_coupon.vue
Executable file
@@ -0,0 +1,167 @@
|
||||
<template>
|
||||
<base-page>
|
||||
<view class="coupons-form">
|
||||
<view class="common-wrap common-form fixd common-scrollbar">
|
||||
<view class="common-title">{{ couponsData.coupon_type_id ? '编辑优惠券' : '添加优惠券' }}</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label"><text class="required">*</text>优惠券名称</label>
|
||||
<view class="form-input-inline">
|
||||
<input type="text" v-model="couponsData.coupon_name" class="form-input" maxlength="15" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label"><text class="required">*</text>优惠券类型</label>
|
||||
<view class="form-input-inline border-0">
|
||||
<uni-data-checkbox v-model="couponsData.type" :localdata="typeList"/>
|
||||
</view>
|
||||
</view>
|
||||
<view class="common-form-item" v-if="couponsData.type == 'reward'">
|
||||
<label class="form-label"><text class="required">*</text>优惠券面额</label>
|
||||
<view class="form-input-inline">
|
||||
<input type="number" v-model="couponsData.money" class="form-input" />
|
||||
</view>
|
||||
<text class="form-word-aux">元</text>
|
||||
<text class="form-word-aux-line">价格不能小于等于0,可保留两位小数</text>
|
||||
</view>
|
||||
<view class="common-form-item" v-else>
|
||||
<label class="form-label"><text class="required">*</text>优惠券折扣</label>
|
||||
<view class="form-input-inline">
|
||||
<input type="number" v-model="couponsData.discount" class="form-input" />
|
||||
</view>
|
||||
<text class="form-word-aux">折</text>
|
||||
<text class="form-word-aux-line">优惠券折扣不能小于1折,且不可大于9.9折,可保留两位小数</text>
|
||||
</view>
|
||||
<view class="common-form-item" v-if="couponsData.type == 'discount'">
|
||||
<label class="form-label">最多优惠</label>
|
||||
<view class="form-input-inline"><input type="number" v-model="couponsData.discount_limit" class="form-input" /></view>
|
||||
<text class="form-word-aux">元</text>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label"><text class="required">*</text>满多少元可以使用</label>
|
||||
<view class="form-input-inline">
|
||||
<input type="number" v-model="couponsData.at_least" class="form-input" />
|
||||
</view>
|
||||
<text class="form-word-aux">元</text>
|
||||
<text class="form-word-aux-line">价格不能小于0,无门槛请设为0</text>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">是否允许直接领取</label>
|
||||
<view class="form-input-inline border-0">
|
||||
<switch :checked="couponsData.is_show === 1" style="transform:scale(0.7)" @change="checkIsShow" />
|
||||
</view>
|
||||
</view>
|
||||
<block v-if="couponsData.is_show === 1">
|
||||
<view class="common-form-item">
|
||||
<label class="form-label"><text class="required">*</text>发放数量</label>
|
||||
<view class="form-input-inline">
|
||||
<input type="number" v-model="couponsData.count" class="form-input" />
|
||||
</view>
|
||||
<text class="form-word-aux">张</text>
|
||||
<text class="form-word-aux-line">优惠券发放数量,没有之后不能领取或发放,-1为不限制发放数量,发放数量只能增加不能减少。</text>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label"><text class="required">*</text>最大领取数量</label>
|
||||
<view class="form-input-inline">
|
||||
<input type="number" v-model="couponsData.max_fetch" class="form-input" />
|
||||
</view>
|
||||
<text class="form-word-aux">张</text>
|
||||
<text class="form-word-aux-line">数量不能小于0,且必须为整数;设置为0时,可无限领取</text>
|
||||
</view>
|
||||
</block>
|
||||
<view class="common-form-item coupons-img">
|
||||
<label class="form-label">优惠券图片</label>
|
||||
<view class="form-input-inline upload-box" @click="addImg">
|
||||
<view class="upload" v-if="couponsData.image">
|
||||
<image :src="$util.img(couponsData.image)" mode="heightFix" />
|
||||
</view>
|
||||
<view class="upload" v-else>
|
||||
<text class="iconfont iconyunshangchuan"></text>
|
||||
<view>点击上传</view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="form-word-aux-line">建议尺寸:325*95像素,图片上传默认不限制大小</text>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">有效期类型</label>
|
||||
<view class="form-input-inline border-0 radio-list">
|
||||
<uni-data-checkbox v-model="couponsData.validity_type" :localdata="validityTypeList"/>
|
||||
</view>
|
||||
<view class="form-word-aux-line top" v-if="couponsData.validity_type === 0">
|
||||
<view class="w-250">
|
||||
<uni-datetime-picker v-model="couponsData.end_time" type="timestamp" :clearIcon="false" @change="changeTime" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="common-form-item" v-if="couponsData.validity_type === 1">
|
||||
<label class="form-label"><text class="required">*</text>领取后几天有效</label>
|
||||
<view class="form-input-inline">
|
||||
<input type="number" v-model="couponsData.fixed_term" class="form-input" />
|
||||
</view>
|
||||
<text class="form-word-aux">天</text>
|
||||
<text class="form-word-aux-line">不能小于等于0,且必须为整数</text>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">活动商品</label>
|
||||
<view class="form-input-inline border-0 radio-list">
|
||||
<uni-data-checkbox v-model="couponsData.goods_type" :localdata="goodsTypeList" @change="goodsType"/>
|
||||
</view>
|
||||
<view class="form-word-aux-line top" v-if="couponsData.goods_type==2||couponsData.goods_type===3">
|
||||
<view class="table-wrap">
|
||||
<view class="table-head">
|
||||
<view class="table-tr">
|
||||
<view class="table-th" style="flex: 5;">商品名称</view>
|
||||
<view class="table-th" style="flex: 1;">价格</view>
|
||||
<view class="table-th" style="flex: 1;">库存</view>
|
||||
<view class="table-th" style="flex: 1;">操作</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="table-body">
|
||||
<block v-for="(item, index) in couponsData.goods_list" :key="index">
|
||||
<view class="table-tr">
|
||||
<view class="table-td goods-name" style="flex: 5;">{{ item.goods_name }}</view>
|
||||
<view class="table-td" style="flex: 1;">{{ item.price || '0.00' }}</view>
|
||||
<view class="table-td" style="flex: 1;">{{ item.goods_stock || 0 }}</view>
|
||||
<view class="table-td" style="flex: 1;">
|
||||
<button type="default" class="delete" @click="delGoods(item.sku_id)">删除</button>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<view class="table-tr table-empty" v-if="!couponsData.goods_list.length">暂无数据,请选择商品数据</view>
|
||||
</view>
|
||||
</view>
|
||||
<button type="default" class="gooods_select" @click="dialogVisible = true">选择商品</button>
|
||||
</view>
|
||||
<view class="form-word-aux-line top" v-if="couponsData.goods_type==4||couponsData.goods_type===5">
|
||||
<view class="flex items-center">
|
||||
<button type="default" class="gooods_select" @click="$refs.couponCategoryPop.open(couponsData.goods_ids_real?couponsData.goods_ids_real.split(','):[])">选择商品分类</button>
|
||||
<text class="goods_names">{{couponsData.goods_names}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="common-form-item">
|
||||
<label class="form-label">适用场景</label>
|
||||
<view class="form-input-inline border-0 radio-list">
|
||||
<uni-data-checkbox v-model="couponsData.use_channel" :localdata="useChannelList"/>
|
||||
</view>
|
||||
<text class="form-word-aux-line">在小程序和pc端商城下单为线上使用,在收银台下单为线下使用。</text>
|
||||
</view>
|
||||
<view class="common-btn-wrap">
|
||||
<button type="default" class="screen-btn" @click="saveFn">保存</button>
|
||||
<button type="default" @click="backFn">返回</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<stock-goods-dialog v-model="dialogVisible" apiType="spu" @selectGoods="selectGoods" />
|
||||
<coupon-category-popup ref="couponCategoryPop" @confirm="goodsCategoryConfirm"/>
|
||||
</base-page>
|
||||
</template>
|
||||
<script>
|
||||
import editCoupon from './public/js/edit_coupon.js';
|
||||
import couponCategoryPopup from '@/components/coupon-category-popup/coupon-category-popup.vue'
|
||||
export default {
|
||||
mixins: [editCoupon]
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import './public/css/edit_coupon.scss';
|
||||
</style>
|
||||
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