createYhq.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="content">
  3. <view class="jg"></view>
  4. <view class="tab">
  5. <view class="tab-item flex">
  6. <view class="item-name">名称</view>
  7. <input type="text" placeholder="请输入优惠券名称" class="item-val" v-model="name">
  8. </view>
  9. <view class="tab-item flex">
  10. <view class="item-name">介绍</view>
  11. <textarea name="" id="" cols="30" rows="10" placeholder="请输入优惠券介绍" v-model="store_info"
  12. class="item-area"></textarea>
  13. </view>
  14. <view class="tab-item flex">
  15. <view class="item-name">价格</view>
  16. <input type="number" placeholder="请输入优惠券价格" class="item-val" v-model="price">
  17. </view>
  18. <view class="tab-item flex">
  19. <view class="item-name">原价</view>
  20. <input type="number" placeholder="请输入优惠券原价" class="item-val" v-model="ot_price">
  21. </view>
  22. <view class="tab-item flex">
  23. <view class="item-name">面值</view>
  24. <input type="number" placeholder="请输入优惠券面值" class="item-val" v-model="coupon_price">
  25. </view>
  26. <view class="tab-item flex">
  27. <view class="item-name">开始时间</view>
  28. <picker mode="date" class="item-val" @change="bindStartTimeChange">
  29. <view class="item-val" :class="{'empty': start_time == ''}">
  30. {{start_time == ''?'请输入优惠券开始时间':start_time}}
  31. </view>
  32. </picker>
  33. <!-- <input type="number" placeholder="请输入优惠券开始时间" class="item-val" v-model="start_time"> -->
  34. </view>
  35. <view class="tab-item flex">
  36. <view class="item-name">结束时间</view>
  37. <picker mode="date" class="item-val" @change="bindEndTimeChange">
  38. <view class="item-val" :class="{'empty': end_time == ''}">{{end_time == ''?'请输入优惠券结束时间':end_time}}
  39. </view>
  40. </picker>
  41. <!-- <input type="number" placeholder="请输入优惠券结束时间" class="item-val" v-model="end_time"> -->
  42. </view>
  43. <view class="tab-item flex">
  44. <view class="item-name">发放数量</view>
  45. <input type="number" placeholder="请输入优惠券发放数量" class="item-val" v-model="stock">
  46. </view>
  47. </view>
  48. <view class="sub" @click="sub">
  49. 确认添加
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. storeCoupon
  56. } from '@/api/shop.js'
  57. export default {
  58. data() {
  59. return {
  60. name: '',
  61. price: '',
  62. ot_price: '',
  63. coupon_price: '',
  64. start_time: '',
  65. end_time: '',
  66. stock: '',
  67. store_info: '',
  68. uping: false,
  69. }
  70. },
  71. onLoad() {
  72. },
  73. onShow() {
  74. },
  75. onReachBottom() {
  76. },
  77. onReady() {
  78. },
  79. methods: {
  80. bindStartTimeChange(res) {
  81. console.log(res)
  82. this.start_time = res.detail.value
  83. },
  84. bindEndTimeChange(res) {
  85. console.log(res)
  86. this.end_time = res.detail.value
  87. },
  88. sub() {
  89. console.log('dddd')
  90. let obj = this
  91. if (obj.uping) {
  92. return
  93. }
  94. if (obj.name == '') {
  95. return obj.$api.msg('请输入优惠券名称')
  96. }
  97. if (obj.store_info == '') {
  98. return obj.$api.msg('请输入优惠券介绍')
  99. }
  100. if (obj.price == '') {
  101. return obj.$api.msg('请输入优惠券价格')
  102. }
  103. if (obj.ot_price == '') {
  104. return obj.$api.msg('请输入优惠券原价')
  105. }
  106. if (obj.coupon_price == '') {
  107. return obj.$api.msg('请输入优惠券面值')
  108. }
  109. if (obj.start_time == '') {
  110. return obj.$api.msg('请输入优惠券开始时间')
  111. }
  112. if (obj.end_time == '') {
  113. return obj.$api.msg('请输入优惠券结束时间')
  114. }
  115. if (obj.stock == '') {
  116. return obj.$api.msg('请输入优惠券发放数量')
  117. }
  118. obj.uping = true
  119. storeCoupon({
  120. name: obj.name,
  121. price: obj.price,
  122. ot_price: obj.ot_price,
  123. coupon_price: obj.coupon_price,
  124. start_time: obj.start_time,
  125. end_time: obj.end_time,
  126. stock: obj.stock,
  127. store_info: obj.store_info,
  128. }).then(res => {
  129. obj.$api.showOk('添加成功')
  130. obj.uping = false
  131. }).catch(res => {
  132. obj.uping = false
  133. })
  134. }
  135. }
  136. }
  137. </script>
  138. <style lang="scss">
  139. .jg {
  140. height: 20rpx;
  141. }
  142. .tab {
  143. width: 690rpx;
  144. margin: auto;
  145. border-radius: 10px;
  146. background-color: #fff;
  147. margin-bottom: 20rpx;
  148. .tab-item {
  149. padding: 0 20rpx;
  150. font-size: 30rpx;
  151. align-items: flex-start;
  152. line-height: 100rpx;
  153. border-bottom: 1px #F0F0F0 solid;
  154. &:last-of-type {
  155. border-bottom: none;
  156. }
  157. .item-name {
  158. flex-shrink: 0;
  159. width: 220rpx;
  160. color: #333333;
  161. }
  162. .item-area {
  163. // padding-top: 28rpx;
  164. border: 1px #F0F0F0 solid;
  165. margin: 28rpx 0;
  166. border-radius: 20rpx;
  167. }
  168. .item-val {
  169. display: inline-block;
  170. flex-grow: 1;
  171. text-align: left;
  172. line-height: 100rpx;
  173. height: 100rpx;
  174. }
  175. }
  176. }
  177. .sub {
  178. text-align: center;
  179. width: 560rpx;
  180. line-height: 80rpx;
  181. background: #ff005d;
  182. border-radius: 40rpx;
  183. color: #fff;
  184. font-size: 30rpx;
  185. font-weight: 500;
  186. margin: 80rpx auto 0;
  187. }
  188. .empty {
  189. color: #999999;
  190. }
  191. </style>