| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <template>
- <view>
- <view class="from flex justify-center">
- <view class="from-box flex justify-center">
- <view class="from-box-c">
- <u-form :model="form" label-position="top" ref="uForm">
- <u-form-item label="优惠券名称">
- <u-input v-model="form.couponName" placeholder="请输入优惠券名称" />
- </u-form-item>
- <u-form-item label="有效期天数">
- <u-input v-model="form.endDate" type="number" placeholder="请选择有效期天数" />
- </u-form-item>
- <u-form-item label="可使用订单最低金额">
- <u-input v-model="form.minMoney" type="number" placeholder="请输入可使用订单最低金额" />
- </u-form-item>
- <!-- <u-form-item label="所需积分数">
- <u-input v-model="form.needIntegral" type="number" placeholder="请输入所需积分数" />
- </u-form-item> -->
- <u-form-item label="优惠券金额">
- <u-input v-model="form.money" type="number" placeholder="请输入优惠券金额" />
- </u-form-item>
- <u-form-item label="优惠券图片">
- <u-upload ref="uUpload" :multiple="false" max-count="1" :action="action" @on-remove="onRemove" @on-change="onChange"></u-upload>
- </u-form-item>
- </u-form>
- </view>
- </view>
- </view>
- <!-- 保存 -->
- <view class="button flex justify-center align-center">
- <view class="button-box flex justify-center align-center" @click="sumbit()">
- 保存
- </view>
- </view>
- </view>
- </template>
- <script>
- import config from '../../common/config.js'
- export default {
- data() {
- return {
- action: 'https://mxys.chuanghai-tech.com/sqx_fast/alioss/upload',
- // action: config.APIHOST+'/alioss/upload',
- fileList: [],
- form: {
- couponName: '',
- endDate: '',
- minMoney: '',
- // needIntegral: '',
- money: '',
- shopId: uni.getStorageSync('shopId'),
- couponPicture: '',
- },
- };
- },
- methods: {
- onRemove(e){
- this.form.couponPicture = ''
- },
- onChange(e){
-
- if(e.data){
- let obj = JSON.parse(e.data)
- if(obj.code!=0){
- uni.showToast({
- title:'上传失败,请重新上传!',
- icon:'none'
- })
-
- this.$refs.uUpload.clear()
- }else{
- this.form.couponPicture = obj.data
- }
-
- }else{
- uni.showToast({
- title:'上传失败,请重新上传!',
- icon:'none'
- })
- this.$refs.uUpload.clear()
- }
- },
- //提交
- sumbit(){
- if(!this.form.couponName){
- uni.showToast({
- title:'请输入优惠券名称',
- icon:'none'
- })
- return
- }
- if(!this.form.endDate){
- uni.showToast({
- title:'请输入有效期天数',
- icon:'none'
- })
- return
- }
- if(!this.form.minMoney){
- uni.showToast({
- title:'请输入可使用订单最低金额',
- icon:'none'
- })
- return
- }
- // if(!this.form.needIntegral){
- // uni.showToast({
- // title:'请输入所需积分数',
- // icon:'none'
- // })
- // return
- // }
- if(!this.form.money){
- uni.showToast({
- title:'请输入优惠券金额',
- icon:'none'
- })
- return
- }
- if(!this.form.couponPicture){
- uni.showToast({
- title:'请上传优惠券图片',
- icon:'none'
- })
- return
- }
- uni.showLoading({
- title:'提交中...'
- })
- this.$Request.postJson("/admin/coupon/issueCoupon", this.form).then(res => {
- if (res.code == 0) {
- uni.showToast({
- title:'发布成功'
- })
- setTimeout(()=>{
- uni.navigateBack()
- },1000)
- }else{
- uni.showToast({
- title:res.msg,
- icon:'none'
- })
- }
- uni.hideLoading()
- });
-
- },
- },
- }
- </script>
- <style lang="scss">
- .from {
- width: 100%;
- height: auto;
- margin-top: 30rpx;
- .from-box {
- width: 686rpx;
- height: 100%;
- border-radius: 16rpx;
- background-color: #ffffff;
- .from-box-c {
- width: 646rpx;
- }
- }
- }
- .button {
- width: 100%;
- height: 120rpx;
- background-color: rgb(241, 241, 241);
- position: fixed;
- bottom: 0;
- z-index: 999;
- .button-box {
- width: 686rpx;
- height: 80rpx;
- border-radius: 40rpx;
- background-color: #FCD202;
- }
- }
- </style>
|