zhe.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="liet">
  3. <view class="title">
  4. <u-icon name="close" @click="close()"></u-icon>
  5. <view class="font-thirty-two font-color3" style="margin: 0 auto; font-weight: 600;">
  6. 调整折扣
  7. </view>
  8. </view>
  9. <view class="border">
  10. <view style="text-align: center; height: 130rpx; padding-top: 30rpx;" class="font-color5 font-twenty;" v-if="flag">*此价格是在最终的基础上进行整体折扣调整</view>
  11. <view v-else style="padding-top: 100rpx;"></view>
  12. <!-- <view class="font-twenty font-color3" style="margin: 20rpx 0 50rpx;">
  13. 商品折扣
  14. </view> -->
  15. <!-- <u-input v-model="value" :type="type" :border="border" /> -->
  16. <!-- <input type="number" v-model="value" placeholder="请输入数字" /> -->
  17. <input v-model="value" class="input" border="true" height="100" placeholder="请输入折扣" />
  18. </view>
  19. <view class="footer11">
  20. <button type="default" class="btn" @click="submit">确认</button>
  21. <button type="default" class="btnClose" @click="close">返回</button>
  22. </view>
  23. <u-toast ref="uToast" />
  24. </view>
  25. </template>
  26. <script>
  27. export default{
  28. data(){
  29. return{
  30. value:'',
  31. type: 'number',
  32. money: null,
  33. index: null,
  34. goodsRatePrice: null,
  35. num: null,
  36. flag: false,
  37. }
  38. },
  39. methods:{
  40. close(){
  41. this.$emit('close')
  42. },
  43. shows(money,goodsRatePrice,num, index){
  44. this.flag = false;
  45. this.money = money;
  46. this.index = index;
  47. this.num = num;
  48. this.goodsRatePrice = goodsRatePrice;
  49. },
  50. show(){
  51. this.flag = true;
  52. },
  53. submit(){
  54. if(this.$u.test.range(this.value, [0, 1])){
  55. if(this.flag){
  56. this.$emit('total', this.value);
  57. this.close();
  58. }else{
  59. if(this.value.charAt(0) === '.'){
  60. this.value = '0'+ this.value
  61. }
  62. if(this.value < this.money){
  63. console.log('***', this.value.charAt(0))
  64. this.$emit('add', this.value,this.goodsRatePrice,this.num, this.index);
  65. this.close();
  66. }else{
  67. this.$refs.uToast.show({
  68. title: '必须小于当前优惠,请重新输入!',
  69. type: 'default',
  70. })
  71. }
  72. }
  73. }else{
  74. this.$refs.uToast.show({
  75. title: '必须是小数,请重新输入!',
  76. type: 'default',
  77. })
  78. }
  79. // const num = /^[0-9]*$/;
  80. // if (num.test(this.value)) {
  81. // this.$emit('add', this.value);
  82. // this.close()
  83. // }else{
  84. // this.$refs.uToast.show({
  85. // title: '必须是数字,请重新输入!',
  86. // type: 'default',
  87. // })
  88. // }
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. .input{
  95. width: calc(100% - 30rpx);
  96. height: 100rpx;
  97. border: 2rpx solid #333333;
  98. border-radius: 24rpx;
  99. padding-left: 30rpx;
  100. }
  101. .liet{
  102. padding: 30rpx;
  103. background: #fff;
  104. min-height: 100vh;
  105. }
  106. .title {
  107. display: flex;
  108. align-items: center;
  109. text-align: center;
  110. .close {
  111. width: 50rpx;
  112. height: 50rpx;
  113. }
  114. }
  115. .border {
  116. border: 2rpx #E0E0E0 solid;
  117. border-left: none;
  118. border-right: none;
  119. margin: 30rpx 0;
  120. .area {
  121. height: 250rpx;
  122. }
  123. }
  124. .footer11{
  125. display: flex;
  126. justify-content: space-between;
  127. }
  128. .btnClose{
  129. width: 330rpx;
  130. margin: 50rpx auto;
  131. color: #2E4F1C;
  132. background: #fff;
  133. border-radius: 48rpx;
  134. border: 2rpx #2E4F1C solid;
  135. }
  136. .btn {
  137. width: 330rpx;
  138. margin: 50rpx auto;
  139. color: #ffffff;
  140. background: #2E4F1C;
  141. border-radius: 48rpx;
  142. }
  143. </style>