coupon.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div class="app-content">
  3. <div class="module-com flex-center-between switch-blo">
  4. <div class="app-size-32">开启自动涨价</div>
  5. <div>
  6. <switch :checked="form.switch ? true : false" @change="switchChangeFn" />
  7. </div>
  8. </div>
  9. <div class="module-com new_wrap">
  10. <div class="module-det">
  11. <div>
  12. <span>新人注册会员赠送</span>
  13. <input type="text" class="setting-inp" v-model="form.amount" />
  14. <span>元优惠券,满</span>
  15. <input type="text" class="setting-inp" v-model="form.miniCost" />
  16. </div>
  17. <div>
  18. <span>元可以使用,</span>
  19. <input type="text" class="setting-inp" v-model="form.duration" />
  20. <span>天内有效。</span>
  21. </div>
  22. </div>
  23. </div>
  24. <div class="prompt-text">节日当天和前一天,勾选自动涨价的商品将统一按上面规则涨价。</div>
  25. <div class="admin-button-com blue big" @click="confirmFn">确定</div>
  26. </div>
  27. </template>
  28. <script>
  29. import { couponAssetDet, couponAssetUpdate } from '@/api/coupon'
  30. export default {
  31. name: 'setting-coupon',
  32. data() {
  33. return {
  34. form: {
  35. switch: 1,
  36. amount: 0,
  37. miniCost: 0,
  38. duration: 0
  39. }
  40. }
  41. },
  42. onLoad() {
  43. // this.init()
  44. },
  45. methods: {
  46. init() {
  47. this._getDet()
  48. },
  49. // 获取详情
  50. _getDet() {
  51. couponAssetDet().then(res => {
  52. if (this.$util.isEmpty(res.data)) return
  53. Object.keys(this.form).forEach((i, index) => {
  54. this.form[i] = res.data[i]
  55. })
  56. })
  57. },
  58. // 设置奖励
  59. confirmFn() {
  60. couponAssetUpdate(this.form).then(res => {
  61. this.$msg('修改成功!')
  62. })
  63. },
  64. switchChangeFn(e) {
  65. this.switch = e.target.value ? 1 : 0
  66. console.log('switch1 发生 change 事件,携带值为', e.target.value)
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .prompt-text {
  73. color: $fontColor3;
  74. padding: 0 30px 20px;
  75. }
  76. .module-com {
  77. margin-bottom: 20px;
  78. padding: 30px;
  79. background-color: #fff;
  80. color: $fontColor2;
  81. .module-tit {
  82. font-size: 28px;
  83. }
  84. }
  85. .admin-button-com {
  86. width: calc(100% - 100px);
  87. margin: 60px 30px 0;
  88. }
  89. .switch-blo {
  90. padding: 15px 30px;
  91. }
  92. .new_wrap {
  93. .module-det {
  94. color: $fontColor2;
  95. font-size: 28px;
  96. & > div {
  97. @include disFlex(center, flex-start);
  98. flex-wrap: wrap;
  99. margin-bottom: 20px;
  100. &:last-child {
  101. margin-bottom: 0;
  102. }
  103. }
  104. .setting-inp {
  105. width: 120px;
  106. height: 70px;
  107. border: 2px solid $borderColor;
  108. border-radius: 10px;
  109. margin: 0 16px;
  110. text-align: center;
  111. &:first-child {
  112. margin-left: 0;
  113. }
  114. &:last-child {
  115. margin-right: 0;
  116. }
  117. }
  118. }
  119. }
  120. </style>