123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <template>
- <view class="container">
- <u-cell-group class="form-info" :border="false">
- <u-field label="优惠券名称" placeholder="请输入优惠券名称" label-width="180" v-model="couponInfo.couponName"></u-field>
- <u-field label="条件金额" placeholder="请输入条件金额" label-width="180" v-model="couponInfo.fullAmount"></u-field>
- <u-field label="减免金额" placeholder="请输入减免金额" label-width="180" v-model="couponInfo.discountAmount"></u-field>
- <u-field label="有效期(天)" placeholder="请输入有效期(天)" label-width="180" v-model="couponInfo.term"></u-field>
- </u-cell-group>
- <view class="form-handle">
- <u-button type="success" shape="circle" :ripple="true" @click="submitData" :disabled="getPermit()" class="handle-custom">发放</u-button>
- </view>
- <u-top-tips ref="uTips"></u-top-tips>
- </view>
- </template>
- <script>
- const NET = require('@/utils/request')
- const API = require('@/config/api')
- export default {
- data() {
- return {
- couponInfo: {
- couponName: '',
- fullAmount: '',
- discountAmount: '',
- term: '',
- },
- }
- },
- onLoad() {},
- methods: {
- // 检查必填项
- getPermit() {
- if (!this.couponInfo.couponName || !this.couponInfo.fullAmount || !this.couponInfo.discountAmount || !this.couponInfo
- .term) {
- return true
- }
- return false
- },
- // 提交
- submitData() {
- NET.request(API.addCoupon, {
- ...this.couponInfo,
- }, 'POST').then(res => {
- this.$refs.uTips.show({
- title: '发放优惠券成功',
- type: 'success',
- })
- setTimeout(() => {
- uni.navigateBack()
- }, 1000)
- }).catch(error => {
- this.$refs.uTips.show({
- title: error.data.msg,
- type: 'warning',
- })
- })
- },
- },
- }
- </script>
- <style lang="less" scoped>
- page {
- width: 100%;
- height: 100%;
- }
- .container {
- width: 100%;
- height: 100%;
- float: left;
- box-sizing: border-box;
- padding-bottom: 70px;
- overflow-y: auto;
- position: absolute;
- .form-info {
- width: 100%;
- float: left;
- /deep/.u-label-text {
- color: #333333;
- }
- /deep/.u-cell_title {
- color: #333333;
- }
- }
- .form-handle {
- width: calc(100% - 30px);
- height: 40px;
- position: fixed;
- bottom: 20px;
- left: 15px;
- background-color: #FFFFFF;
- .handle-custom {
- background-color: #51A539;
- /deep/button {
- background-color: #56a83a;
- }
- /deep/.u-btn--success--disabled {
- background-color: #74bd60 !important;
- }
- }
- }
- }
- </style>
|