detection-business/pages/coupon/couponadd.vue

554 lines
12 KiB
Vue
Raw Normal View History

2024-09-11 15:55:28 +08:00
<!-- 新增-->
<template>
<view class="content">
<view style="width: 100%; height: 44px;"></view>
<view class="top-heder">
<view class="t-left" @click="getback()">
<uni-icons type="left" size="18"></uni-icons>
</view>
<view class="t-title">
<text>添加优惠券</text>
</view>
<view class="t-you"></view>
</view>
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
<view class="mub">
<view class="top-ail">
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
<view class="box-list">
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
<!-- <view class="list-box">
<view class="l-left">商品类别</view>
<view class="l-right" @click="show=true">
<input type="text" placeholder="">
<text v-if="!ftitle">选择商品分类</text>
<text v-if="ftitle">{{ftitle}}</text>
</view>
</view> -->
<view class="list-box">
<view class="l-left">优惠券名称</view>
<view class="l-right">
<input type="text" v-model="title" placeholder="优惠券名称">
</view>
</view>
<view class="list-box">
<view class="l-left">抵扣金额</view>
<view class="l-right">
<input type="text" v-model="discout" placeholder="请输入抵扣金额">
</view>
</view>
<view class="list-box">
<view class="l-left">选择身份</view>
<view class="l-right" @click="shows = true">
<text>{{rolename}}</text>
</view>
</view>
<view class="list-box" @click="show3 = true">
<view class="l-left">可用开始时间</view>
<view class="l-right">
<text>{{timethree}} </text>
</view>
2024-11-11 13:18:56 +08:00
</view>
2024-09-11 15:55:28 +08:00
<view class="list-box" @click="show4 = true">
<view class="l-left">可用结束时间</view>
<view class="l-right">
<text>{{timefrou}} </text>
</view>
</view>
<view class="list-box" @click="show5 = true">
<view class="l-left">指定商品</view>
<view class="l-right">
<text >{{selectGoods}} </text>
</view>
</view>
2024-11-11 13:18:56 +08:00
</view>
2024-09-11 15:55:28 +08:00
<text class='biaoz'>规则:</text>
<view class="box-list" v-if="ane == ''">
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
<view class="list-box" @click="show1 = true" >
<view class="l-left">生效时间</view>
<view class="l-right">
<text>{{timeone}} </text>
</view>
</view>
<view class="list-box" @click="show2 = true" >
<view class="l-left">过期时间</view>
<view class="l-right">
<text>{{timetwo}} </text>
</view>
2024-11-11 13:18:56 +08:00
</view>
</view>
2024-09-11 15:55:28 +08:00
<text class='biaoz' v-if="timeone == '请选择生效时间' && ane == '' "></text>
<view class="box-list" v-if="timeone == '请选择生效时间' ">
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
<view class="list-box" >
<view class="l-left">领取后多少天有效</view>
<view class="l-right">
<input type="number" :onkeyup="ane = (ane || '').replace(/[^A-z0-9]/, '')" v-model="ane" placeholder="领取后多少天有效">
</view>
2024-11-11 13:18:56 +08:00
</view>
</view>
2024-09-11 15:55:28 +08:00
<view class="dlanniu" @click="getgoods()" >
<text>提交</text>
</view>
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
</view>
</view>
<u-picker :show="shows" :columns="columns" keyName="label" @confirm="stimes" @cancel="shows = false"></u-picker>
<u-datetime-picker
:show="show1"
v-model="value1"
mode="date"
@confirm="stime1"
@cancel="show1 = false"
></u-datetime-picker>
<u-datetime-picker
:show="show2"
v-model="value2"
mode="date"
@confirm="stime2"
@cancel="show2 = false"
></u-datetime-picker>
<u-datetime-picker
:show="show3"
v-model="value3"
mode="date"
@confirm="stime3"
@cancel="show3 = false"
></u-datetime-picker>
<u-datetime-picker
:show="show4"
v-model="value4"
mode="date"
@confirm="stime4"
@cancel="show4 = false"
></u-datetime-picker>
<u-picker :show="show5" :columns="columnGoods" keyName="label" @confirm="sureGoods" @cancel="show5 = false"></u-picker>
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
<!-- 底部 -->
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
</view>
</template>
<script>
import RboyEditor from "@/components/Rboy-editor/Rboy-editor"
import config from '@/config';
import request from '../../utils/request';
import upload from '@/utils/upload.js'
import code from '../../uni_modules/uview-ui/libs/config/props/code';
export default {
data() {
return {
baseUrl:this.$baseUrl,
columns:[
2024-11-11 13:18:56 +08:00
[{ label: '代办',id: 'jcdb'},
2024-09-11 15:55:28 +08:00
{ label: '单位管理员',id: 'jcdwgly'},
{ label: '普通用户',id: 'jcyh'},
]
],
columnGoods:[],
rolename:'请选择身份',
roleKey:'',
timeone:'请选择生效时间',
timetwo:'请选择过期时间',
timethree:'请选择活动开始时间',
2024-11-11 13:18:56 +08:00
timefrou:'请选择活动结束时间',
2024-09-11 15:55:28 +08:00
shows:false,
show:false,
show1:false,
show2:false,
show3:false,
show4:false,
show5:false,
value1: Number(new Date()),
value2: Number(new Date()),
value3: Number(new Date()),
value4: Number(new Date()),
guige:false,
msg:'3',
newsContent:'',
tapnum:0,
value5:'',
partnerId:'',
title:'',
ane:'',
discout:'',
selectGoods:'指定商品(可选)',
selectGoodsId:null,
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
},
onLoad() {
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
},
onShow() {
this.partnerId = uni.getStorageSync('partnerId')
this.canUsegoods()
},
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
methods: {
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
async canUsegoods(){
let res = await request({
url:'/partnerOwn/partner/canUsegoods?partnerId='+ this.partnerId,
method: 'get',
params:{}
})
if(res.code == 200){
this.columnGoods.push(res.data)
}
},
open1(){
this.show1 = false
},
open2(){
this.show2 = false
},
open3(){
this.show3 = false
},
open4(){
this.show4 = false
},
stimes(e){
this.roleKey = e.value[0].id
this.rolename = e.value[0].label
this.shows = false
},
opens(){
},
stime1(e){
var timestamp = e.value;
var date = new Date(timestamp);
var year = date.getFullYear();
var month = date.getMonth() + 1; // 月份从0开始所以要加1
var day = date.getDate();
2024-11-11 13:18:56 +08:00
this.timeone = year + "-" + month + "-" + day
2024-09-11 15:55:28 +08:00
this.show1 = false
},
stime2(e){
var timestamp = e.value;
var date = new Date(timestamp);
var year = date.getFullYear();
var month = date.getMonth() + 1; // 月份从0开始所以要加1
var day = date.getDate();
2024-11-11 13:18:56 +08:00
this.timetwo = year + "-" + month + "-" + day
2024-09-11 15:55:28 +08:00
this.show2 = false
},
stime3(e){
var timestamp = e.value;
var date = new Date(timestamp);
var year = date.getFullYear();
var month = date.getMonth() + 1; // 月份从0开始所以要加1
var day = date.getDate();
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
this.timethree = year + "-" + month + "-" + day
this.show3 = false
},
stime4(e){
var timestamp = e.value;
var date = new Date(timestamp);
var year = date.getFullYear();
var month = date.getMonth() + 1; // 月份从0开始所以要加1
var day = date.getDate();
2024-11-11 13:18:56 +08:00
this.timefrou = year + "-" + month + "-" + day
2024-09-11 15:55:28 +08:00
this.show4 = false
},
sureGoods(obj){
this.selectGoodsId = obj.value[0].value
this.selectGoods = obj.value[0].label
this.show5 = false
},
async getgoods(){
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
if(this.partnerId == '' ||this.title == '' ||this.discout == ''||this.roleKey == '' ){
uni.showToast({
title:'以上均不能为空'
})
return
}
if(this.ane != ''){
this.timeone = null
this.timetwo = null
}
let data = {
partnerId : this.partnerId,
title:this.title,
discount:this.discout * 100,
startTime:this.timeone,
expirationTime:this.timetwo,
eventsStartTime:this.timethree,
eventsEndTime:this.timefrou,
effectiveDay:this.ane,
roleKey:this.roleKey,
bindGoodsIds:this.selectGoodsId
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
let res = await request({
url:'/partnerOwn/partner/sendCoupon',
method: 'post',
data:data
})
if(res.code == 200){
uni.showToast({
title:"发布成功",
duration: 2000
})
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
setTimeout(
uni.navigateBack(),1000);
},
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
gettapindex(index){
this.tapnum = index
},
getback(){
uni.navigateBack()
},
getyes(){
this.show = false
},
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
}
</script>
<style scoped lang="scss">
.content {
box-sizing: border-box;
width: 100%;
height: calc(100vh);
background: white;
}
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
.top-heder{
width: 100%;
height: 46px;
background: white;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 5px 15px;
}
.t-title{
font-size: 17px;
font-weight: bold;
color: #333333;
}
.t-left{
width: 10%;
}
.t-you{
height: 100%;
width: 20%;
}
.biaoz{
margin-left: 10px;
font-size: 18px;
font-weight: 600;
}
.t-input{
width: 80%;
height: 36px;
background: #F0F0F0;
border-radius: 50px;
box-sizing: border-box;
padding: 0 15px;
display: flex;
align-items: center;
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
.top-ail{
width: 100%;
box-sizing: border-box;
padding: 15px;
background-color: #F4F4F4;
// height: calc(100vh);
}
.mub{
background-color: #F4F4F4;
height: calc(100vh);
}
.dix{
display: flex;
align-items: center;
}
.upimg{
width: 100%;
height: 126px;
border-radius: 8px;
box-sizing: border-box;
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
background-color: white;
image{
width: 100%;
height: 100%;
}
}
.xhong{
font-size: 12px;
color: crimson;
}
.box-list{
width: 100%;
border-radius: 8px;
box-sizing: border-box;
padding: 10px;
background-color: white;
margin: 10px auto;
}
.list-box{
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 15px 5px;
border-bottom: 1px solid #EEEEEE;
}
.l-left{
font-size: 16px;
font-weight: 400;
color: #333333;
}
.l-right{
font-size: 16px;
font-weight: 400;
color: #999999;
text-align: right;
}
.xiaolan{
// width: 109px;
// height: 30px;
background: #E2EAFF;
border-radius: 50px;
display: flex;
align-content: center;
justify-self: center;
box-sizing: border-box;
padding: 5px;
font-size: 14px;
font-weight: 400;
color: #0D2E8D;
}
.xiaohui{
// width: 141px;
// height: 30px;
box-sizing: border-box;
padding: 0px 10px;
background: #F7F7F7;
border-radius: 50px ;
display: flex;
align-items: center;
justify-content: center;
margin: 10px ;
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
.hui-right{
border-left:1px solid #DDDDDD;
padding: 5px;
margin-left: 5px;
}
.wrap-box{
width: 100%;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
}
.bottom-di{
width: 100%;
height: 56px;
background: #FFFFFF;
border-radius: 8px;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
padding: 0px 20px;
margin-bottom: 10px;
}
.thui{
font-size: 16px;
font-weight: 400;
color: #666666;
margin-top: 10px;
margin-left: 8px;
}
.imgs{
box-sizing: border-box;
margin-top: 20px;
}
.p-box{
border-radius: 10px;
overflow: hidden;
box-sizing: border-box;
padding: 20px;
width: 100%;
background-color: white;
}
.p-top{
width: 100%;
text-align: center;
font-size: 17px;
font-weight: bold;
color: #000000;
margin-bottom: 20px;
}
.on-input{
width: 100%;
display: flex;
align-items: center;
box-sizing: border-box;
2024-11-11 13:18:56 +08:00
2024-09-11 15:55:28 +08:00
}
.ipt-kuang{
width: 70%;
height: 30px;
background: #FFFFFF;
border-radius: 8px 8px 8px 8px;
opacity: 1;
border: 1px solid #DDDDDD;
display: flex;
align-items: center;
margin: 10px auto;
box-sizing: border-box;
padding: 0px 10px;
}
.t-left{
width: 20%;
font-size: 14px;
font-weight: 400;
color: #000000;
}
.dlanniu{
width: 80%;
height: 45px;
background: linear-gradient(180deg, #3F61C0 0%, #0D2E8D 100%);
border-radius: 50px;
display: flex;
align-items: center;
justify-content: center;
margin: 20px auto;
color: white;
}
.da{
font-size: 16px;
}
</style>