detection-business/pages/coupon/couponadd.vue
2024-09-11 15:55:28 +08:00

567 lines
12 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- 新增-->
<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>
<view class="mub">
<view class="top-ail">
<view class="box-list">
<!-- <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>
</view>
<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>
</view>
<text class='biaoz'>规则:</text>
<view class="box-list" v-if="ane == ''">
<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>
</view>
</view>
<text class='biaoz' v-if="timeone == '请选择生效时间' && ane == '' ">或</text>
<view class="box-list" v-if="timeone == '请选择生效时间' ">
<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>
</view>
</view>
<view class="dlanniu" @click="getgoods()" >
<text>提交</text>
</view>
</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>
<!-- 底部 -->
</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:[
[{ label: '代办',id: 'jcdb'},
{ label: '单位管理员',id: 'jcdwgly'},
{ label: '普通用户',id: 'jcyh'},
]
],
columnGoods:[],
rolename:'请选择身份',
roleKey:'',
timeone:'请选择生效时间',
timetwo:'请选择过期时间',
timethree:'请选择活动开始时间',
timefrou:'请选择活动结束时间',
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,
}
},
onLoad() {
},
onShow() {
this.partnerId = uni.getStorageSync('partnerId')
this.canUsegoods()
},
methods: {
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)
console.log(this.columnGoods)
}
},
open1(){
console.log('触发');
this.show1 = false
},
open2(){
console.log('触发');
this.show2 = false
},
open3(){
console.log('触发');
this.show3 = false
},
open4(){
console.log('触发');
this.show4 = false
},
stimes(e){
console.log(e);
this.roleKey = e.value[0].id
this.rolename = e.value[0].label
this.shows = false
},
opens(){
console.log(e);
},
stime1(e){
console.log(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();
this.timeone = year + "-" + month + "-" + day
this.show1 = false
},
stime2(e){
console.log(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();
this.timetwo = year + "-" + month + "-" + day
this.show2 = false
},
stime3(e){
console.log(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();
this.timethree = year + "-" + month + "-" + day
this.show3 = false
},
stime4(e){
console.log(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();
this.timefrou = year + "-" + month + "-" + day
this.show4 = false
},
sureGoods(obj){
console.log(obj)
this.selectGoodsId = obj.value[0].value
this.selectGoods = obj.value[0].label
this.show5 = false
},
async getgoods(){
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
}
let res = await request({
url:'/partnerOwn/partner/sendCoupon',
method: 'post',
data:data
})
console.log(res);
if(res.code == 200){
uni.showToast({
title:"发布成功",
duration: 2000
})
}
setTimeout(
uni.navigateBack(),1000);
},
gettapindex(index){
this.tapnum = index
},
getback(){
uni.navigateBack()
},
getyes(){
this.show = false
},
}
}
</script>
<style scoped lang="scss">
.content {
box-sizing: border-box;
width: 100%;
height: calc(100vh);
background: white;
}
.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;
}
.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;
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 ;
}
.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;
}
.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>