liangjin
2021-04-01 a734e1028dbc6e91a12ee03b1eeba27cdc94cd26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<!--
 * @Author: 小明丶
 * @Date: 2019-08-22 16:55:53
 * @LastEditors: 小明丶
 * @LastEditTime: 2019-08-27 13:50:17
 * @Description: 
 -->
<template>
  <div class="facepay">
 
    <v-navbar title="扫码收款" @right-click="$router.push('/order/dmf')" fixed>
        <div slot="right" style="color: #896EDB">明细</div>
    </v-navbar>
 
 
    <div class="input-box">
      <p class="tag">¥</p>
      <input v-model="price" autofocus readonly  type="text" class="input-money" placeholder="输入收款金额" >
    </div>
    <p class="icon-box">
      <span>支持方式:</span>
 
      <svg class="icon"  aria-hidden="true">
        <use xlink:href="#iconshoujifenqi"></use>
      </svg>
 
    </p>
    <div class="calc">
      <ul class="number-box">
        <li class="number-item" v-for="(item, index) in 9" :key="index" @click="numberClick(item)">{{item}}</li>
        <li class="number-item"></li>
        <li class="number-item" @click="numberClick(0)">0</li>
        <li class="number-item" @click="numberClick('.')">.</li>
      </ul>
      <div class="handler-box">
        <div class="icon-delete" @click="deleteNumber">
          <svg class="icon"  aria-hidden="true">
            <use xlink:href="#iconcha"></use>
          </svg>
        </div>
        <div class="icon-submit" @click="submit">
          收款
        </div>
      </div>
    </div>
 
  </div>
</template>
 
<script>
  import {Notify} from 'vant';
  export default {
    name: "facepay",
    data() {
      return {
        price: ''
      }
    },
    methods: {
 
      // 删除price最后一位
      deleteNumber() {
        this.price = this.price.slice(0, this.price.length - 1)
      },
      //提交生成二维码
      submit() {
        if(this.price=='0' || this.price=='0.'){
          Notify({
            message: '收款金额不能为0!',
          });
          return
        }
        if (!this.price.length) {
          Notify({
            message: '请输入收款金额!',
          });
          return
        }else{
 
 
          // 点击收款逻辑
          this.$router.push('/product/facepay-qrcode');
 
 
          // this.$api.facepay_create({payAmt:+this.price,term:0}).then(res=>{
          //   let url = res.body.payQrCodeUrl;
          //   let id = res.body.orderId;
          //   this.$router.push(`/facepay/code?url=${url}&id=${id}`)
          // })
        }
      },
      //数字的逻辑输入判断
      numberClick(v) {
        let index = this.price.indexOf('.');
        if (v !== '.') {
          if (this.price.length === 8) {
            return
          }
          if (index > -1 && this.price.slice(index + 1, this.price.length).length == 2) {
            // 最多输入两位小数
            this.$tool.toast('最多输入两位小数!')
            return
          }
          if(this.price.length===1 && this.price ==='0'){
            return
          }
        } else {
          if (!this.price.length) {
            return
          }
          // if (this.price.slice(0, 1) !== '0') {
          //     return
          // }
          if (index > -1) {
            return
          }
        }
        this.price += v;
      }
    }
  }
</script>
 
<style lang="less" scoped>
.facepay{
  padding-top: 44px;
  background-color: @c-f5;
  min-height: calc(100vh - 44px);
 
 
  .input-box {
    color: @c-default;
    padding: 30px 25px;
    position: relative;
    margin-top: 15px;
 
    .tag {
      position: absolute;
      left: 40px;
      top: 50%;
      transform: translateY(-50%);
      font-size: 24px;
    }
  }
 
  .icon-box {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding-left: 30px;
    color: @c-default;
    .icon{
      width: 35px;
      height: 35px;
    }
  }
 
  .input-money {
    color: @c-default;
    height: 55px;
    line-height: 55px;
    width: 100%;
    text-align: right;
    padding-right: 15px;
    box-sizing: border-box;
    border: 2px solid @c-default;
    outline: none;
    font-size: 18px;
  }
 
  .calc {
    position: fixed;
    bottom:0;
    width: 100%;
    font-size: 24px;
    text-align: center;
    background-color: #fff;
    .icon-delete {
      height: 70px;
      .flex(center,center);
      .icon{
        width: 40px;
        height: 40px;
      }
    }
 
    .icon-submit {
      height: 210px;
      line-height: 210px;
      color: #fff;
      background-color: @c-default;
    }
 
    &::after {
      content: "";
      clear: both;
      display: block;
    }
  }
 
  .handler-box {
    width: 25%;
    float: left;
  }
 
  .number-box {
    width: 75%;
    float: left;
 
    .number-item {
      width: 33.3333%;
      float: left;
      height: 70px;
      line-height: 70px;
      box-sizing: border-box;
    }
  }
 
 
}
</style>