zhaoxiaoqiang
2022-08-03 a02fe2da9c04fd7fb7fd76b8e79912367be59791
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<!--
 * @Author: 小明丶
 * @Date: 2020-05-23 11:05:09
 * @LastEditors: zxq
 * @LastEditTime: 2022-07-08 14:54:57
 * @Description: 上传身份证
-->
<template>
  <div class="upload-IDcard-page">
    <v-navbar title="订单申请"></v-navbar>
    <div class="steps-box">
      <div></div>
      <div class="steps">
        <p></p>
        <div class="step-1">1</div>
        <div class="step-2">2</div>
        <div class="step-3">3</div>
      </div>
    </div>
    <div class="tit-box">
      <p>身份证照片上传</p>
      <p>请确保照片清晰可见,以便顺利申请</p>
    </div>
    <div class="idcard-box">
      <upLoadIdCard :cardBack="idCardMation.idBackUrl" :cardFont="idCardMation.idFrontUrl"></upLoadIdCard>
    </div>
    <div class="id-mation-box">
      <div class="tit">
        <p>请核对身份证信息</p>
      </div>
      <div class="mation">
        <h-cell v-model="idCardMation.usrIdName" isMust  label="姓名"></h-cell>
        <h-cell v-model="idCardMation.usrIdCard" isMust readonly label="身份证号"></h-cell>
        <h-cell v-model="idCardMation.sex" readonly isMust label="性别"></h-cell>
        <h-cell v-model="idCardMation.idCardAddr" isMust label="身份证地址"></h-cell>
        <h-cell v-model="idDate" readonly isLink isMust label="有效期" @click.native="isShoTime = true"></h-cell>
      </div>
    </div>
    <div class="btn-box">
      <button @click="goNext">下一步</button>
    </div>
    <van-popup v-model="isShoTime" position="bottom">
      <div class="text-center-g flex-around-g time-label">
        <p
          class="flex-1-g"
          :class="[timeIndex===0 ? 'active':'']"
          @click="setTimeIndex(0)"
        >开始:{{startDay}}</p>
        <p
          class="flex-1-g"
          :class="[timeIndex===1 ? 'active':'']"
          @click="setTimeIndex(1)"
        >结束:{{endDay}}</p>
      </div>
      <van-datetime-picker
        ref="timepicker"
        item-height='45'
        visible-item-count='4'
        :show-toolbar="false"
        v-model="currentDate"
        @change="setTime"
        :min-date="minDate"
        :max-date="maxDate"
        type="date"
      />
      <van-button class="btn-time" @click="refreshData">确定</van-button>
    </van-popup>
  </div>
</template>
<script>
import Bus from "../../bus";
import Vue from "vue";
import { DatetimePicker } from "vant";
import { Popup } from "vant";
 
Vue.use(Popup);
Vue.use(DatetimePicker);
export default {
  data() {
    return {
      readOnlyName: false,
      readOnlyId: false,
      readOnlySex: false,
      minDate: new Date(1990, 0, 1),
      maxDate: new Date(2030, 11, 31),
      startDay: "", // 开始时间
      endDay: "", //结束时间
      timeIndex: 0,
      isShoTime: false,
      timePicker: null,
      currentDate: new Date(1990, 0, 1),
      idCardMation: {}, //身份证相关信息
      //idCardUserInfo:{},//身份证照片信息
    };
  },
  computed: {
    idDate() {
      if (
        this.idCardMation.idCardValidBegin &&
        this.idCardMation.idCardValidEnd
      ) {
        return (
          this.idCardMation.idCardValidBegin +
          "-" +
          this.idCardMation.idCardValidEnd
        );
      }
    },
    // cardBack() {
    //   return this.idCardMation.idBackUrl;
    // },
    // cardFont() {
    //   return this.idCardMation.idFrontUrl;
    // }
  },
  created() {
    this.$api.createInitIdInfo().then(res => {
      this.idCardMation = res.body;
      if (this.idCardMation.usrIdName) {
        this.readOnlyName = true;
      }
      if (this.idCardMation.usrIdCard) {
        this.readOnlyId = true;
      }
      if (this.idCardMation.sex) {
        this.readOnlySex = true;
      }
    });
  },
  beforeUpdate(){
    let _this = this
    Bus.$on('getIdUserInfo',(msg)=>{
      _this.idCardMation = msg
    })
  },
  methods: {
    //设置时间
    setTime(picker, arr) {
      if (!this.timepicker && picker) {
        this.timePicker = picker;
      }
      let v = arr ? arr : picker.getValues(),
        time = v[0] + "." + v[1] + "." + v[2];
      if (this.timeIndex === 0) {
        this.startDay = time;
      } else {
        this.endDay = time;
      }
    },
    setTimeIndex(index) {
      this.timeIndex = index;
      this.setPickerValue();
    },
    // 设置日期的值
    setPickerValue() {
      if (this.timePicker) {
        let timeArr = [];
        if (this.timeIndex === 0) {
          timeArr = this.startDay;
        } else {
          timeArr = this.endDay;
        }
        this.currentDate = new Date(timeArr);
      }
    },
    // 时间切换刷新统计数据
    refreshData() {
      if (this.timePicker) {
        let arr = this.timePicker.getValues();
        this.setTime(null, arr);
        this.idCardMation.idCardValidBegin = this.startDay;
        this.idCardMation.idCardValidEnd = this.endDay;
      }
      this.isShoTime = false;
    },
    // 下一步
    goNext() {
      let v = this.$tool;
      if(v.checkValEmpty(this.idCardMation.idFrontUrl)){
        v.toast('请上传身份证正面')
        return
      }
      if(v.checkValEmpty(this.idCardMation.idBackUrl)){
        v.toast('请上传身份证反面')
        return
      }
      if(v.checkValEmpty(this.idCardMation.idCardAddr)){
        v.toast('请输入身份证详细地址')
        return
      }
      // if(!v.checkValEmpty(this.idCardMation.idCardAddr)){
      //   v.toast('请输入正确的身份证详细地址')
      //   return
      // }
      this.$api.saveIdInfo({...this.idCardMation,}).then(res => {
          let str = location.host
          //保存成功后获取人脸识别地址
          // this.$api.getFaceUrl({
          //   callbackUrl:`https://${str}/aic_cus/#/order-handling/face-recognition`
          // }).then(res=>{
          //   window.location.href = res.body.faceUrl
          // })
          this.$router.push({
            path: "/order-handling/face-recognition",
            query: {isFaceBack:'1'}
          });
      });
    }
  }
};
</script>
<style lang="less" scoped>
.upload-IDcard-page {
  & {
    min-height: 100vh;
  }
  .steps-box {
    & {
      display: flex;
    }
    div {
      width: 50%;
    }
    .steps {
      height: 65px;
      position: relative;
      p {
        border-bottom: 1px dashed #b3b3b3;
        height: 32px;
      }
      .step-1 {
        text-align: center;
        line-height: 30px;
        color: #fff;
        width: 30px;
        height: 30px;
        background: rgba(81, 148, 254, 1);
        box-shadow: 0px 0px 8px 0px rgba(81, 148, 254, 0.64);
        border-radius: 50%;
        position: absolute;
        left: -15px;
        top: 19px;
      }
      .step-2 {
        text-align: center;
        line-height: 28px;
        width: 28px;
        height: 28px;
        background: rgba(255, 255, 255, 1);
        border: 1px solid rgba(113, 123, 133, 1);
        border-radius: 50%;
        position: absolute;
        left: 55px;
        top: 19px;
      }
      .step-3 {
        text-align: center;
        line-height: 28px;
        width: 28px;
        height: 28px;
        background: rgba(255, 255, 255, 1);
        border: 1px solid rgba(113, 123, 133, 1);
        border-radius: 50%;
        position: absolute;
        left: 130px;
        top: 19px;
      }
    }
  }
  .tit-box {
    & {
      width: 343px;
      height: 75px;
      background: rgba(255, 255, 255, 1);
      box-shadow: 0px 0px 10px 0px rgba(47, 103, 192, 0.1);
      border-radius: 5px;
      margin: auto;
      box-sizing: border-box;
      padding: 16px 17px;
    }
    p:nth-of-type(1) {
      margin-bottom: 10px;
      font-size: 16px;
      font-family: PingFang SC;
      font-weight: 500;
      color: rgba(51, 51, 51, 1);
    }
    p:nth-of-type(2) {
      font-size: 12px;
      font-family: PingFang SC;
      font-weight: 500;
      color: rgba(153, 153, 153, 1);
    }
  }
  .idcard-box {
    & {
      margin-top: 29px;
    }
  }
  .id-mation-box {
    & {
      box-sizing: border-box;
      padding-left: 17px;
      margin-top: 27px;
    }
    .tit {
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: 500;
      color: rgba(51, 51, 51, 1);
    }
    .mation {
      box-sizing: border-box;
      padding: 0 26px;
    }
  }
  .btn-box {
    text-align: center;
    margin-top: 32px;
    padding-bottom: 37px;
    button {
      width: 320px;
      height: 44px;
      background: rgba(81, 148, 254, 1);
      border-radius: 22px;
      color: #fff;
      border: 0;
      outline: none;
    }
  }
  .time-label {
    .lh(65px);
    color: @c-text-999;
 
    .active {
      color: @c-text-default;
    }
  }
  .btn-time {
    display: block;
    text-align: center;
    line-height: 40px;
    width: 320px;
    height: 40px;
    background-color: @c-bg-default;
    color: @c-text-fff;
    border-radius: 22px;
    margin: 15px auto;
  }
}
</style>