createYhq.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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="text" 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. title: 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. uni.showToast({
  130. title: '添加成功',
  131. duration: 2000
  132. });
  133. obj.uping = false
  134. }).catch(res => {
  135. obj.uping = false
  136. })
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss">
  142. .jg {
  143. height: 20rpx;
  144. }
  145. .tab {
  146. width: 690rpx;
  147. margin: auto;
  148. border-radius: 10px;
  149. background-color: #fff;
  150. margin-bottom: 20rpx;
  151. .tab-item {
  152. padding: 0 20rpx;
  153. font-size: 30rpx;
  154. align-items: flex-start;
  155. line-height: 100rpx;
  156. border-bottom: 1px #F0F0F0 solid;
  157. &:last-of-type {
  158. border-bottom: none;
  159. }
  160. .item-name {
  161. flex-shrink: 0;
  162. width: 220rpx;
  163. color: #333333;
  164. }
  165. .item-area {
  166. // padding-top: 28rpx;
  167. border: 1px #F0F0F0 solid;
  168. margin: 28rpx 0;
  169. border-radius: 20rpx;
  170. }
  171. .item-val {
  172. display: inline-block;
  173. flex-grow: 1;
  174. text-align: left;
  175. line-height: 100rpx;
  176. height: 100rpx;
  177. }
  178. }
  179. }
  180. .sub {
  181. text-align: center;
  182. width: 560rpx;
  183. line-height: 80rpx;
  184. background: #ff005d;
  185. border-radius: 40rpx;
  186. color: #fff;
  187. font-size: 30rpx;
  188. font-weight: 500;
  189. margin: 80rpx auto 0;
  190. }
  191. .empty {
  192. color: #999999;
  193. }
  194. </style>