couponForm.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="container">
  3. <u-cell-group class="form-info" :border="false">
  4. <u-field label="优惠券名称" placeholder="请输入优惠券名称" label-width="180" v-model="couponInfo.couponName"></u-field>
  5. <u-field label="条件金额" placeholder="请输入条件金额" label-width="180" v-model="couponInfo.fullAmount"></u-field>
  6. <u-field label="减免金额" placeholder="请输入减免金额" label-width="180" v-model="couponInfo.discountAmount"></u-field>
  7. <u-field label="有效期(天)" placeholder="请输入有效期(天)" label-width="180" v-model="couponInfo.term"></u-field>
  8. </u-cell-group>
  9. <view class="form-handle">
  10. <u-button type="success" shape="circle" :ripple="true" @click="submitData" :disabled="getPermit()" class="handle-custom">发放</u-button>
  11. </view>
  12. <u-top-tips ref="uTips"></u-top-tips>
  13. </view>
  14. </template>
  15. <script>
  16. const NET = require('@/utils/request')
  17. const API = require('@/config/api')
  18. export default {
  19. data() {
  20. return {
  21. couponInfo: {
  22. couponName: '',
  23. fullAmount: '',
  24. discountAmount: '',
  25. term: '',
  26. },
  27. }
  28. },
  29. onLoad() {},
  30. methods: {
  31. // 检查必填项
  32. getPermit() {
  33. if (!this.couponInfo.couponName || !this.couponInfo.fullAmount || !this.couponInfo.discountAmount || !this.couponInfo
  34. .term) {
  35. return true
  36. }
  37. return false
  38. },
  39. // 提交
  40. submitData() {
  41. NET.request(API.addCoupon, {
  42. ...this.couponInfo,
  43. }, 'POST').then(res => {
  44. this.$refs.uTips.show({
  45. title: '发放优惠券成功',
  46. type: 'success',
  47. })
  48. setTimeout(() => {
  49. uni.navigateBack()
  50. }, 1000)
  51. }).catch(error => {
  52. this.$refs.uTips.show({
  53. title: error.data.msg,
  54. type: 'warning',
  55. })
  56. })
  57. },
  58. },
  59. }
  60. </script>
  61. <style lang="less" scoped>
  62. page {
  63. width: 100%;
  64. height: 100%;
  65. }
  66. .container {
  67. width: 100%;
  68. height: 100%;
  69. float: left;
  70. box-sizing: border-box;
  71. padding-bottom: 70px;
  72. overflow-y: auto;
  73. position: absolute;
  74. .form-info {
  75. width: 100%;
  76. float: left;
  77. /deep/.u-label-text {
  78. color: #333333;
  79. }
  80. /deep/.u-cell_title {
  81. color: #333333;
  82. }
  83. }
  84. .form-handle {
  85. width: calc(100% - 30px);
  86. height: 40px;
  87. position: fixed;
  88. bottom: 20px;
  89. left: 15px;
  90. background-color: #FFFFFF;
  91. .handle-custom {
  92. background-color: #51A539;
  93. /deep/button {
  94. background-color: #56a83a;
  95. }
  96. /deep/.u-btn--success--disabled {
  97. background-color: #74bd60 !important;
  98. }
  99. }
  100. }
  101. }
  102. </style>