liangjin
2021-04-04 6ab8cacad8580c7d297609d6583b46b89310ff6f
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
<!--
 * @Author: 小明丶
 * @Date: 2019-08-23 17:52:37
 * @LastEditors: 小明丶
 * @LastEditTime: 2020-12-14 18:10:05
 * @Description:
 -->
<template>
  <div class="register-home ">
    <div style="min-height: 570px;">
      <v-navbar title="注册" fixed back>
        <div slot="left-back" style="display: flex;">
          <svg class="icon" aria-hidden="true" style="width:25px;height:44px;" @click="back">
            <use xlink:href="#iconzuojiantou"></use>
          </svg>
        </div>
      </v-navbar>
 
 
      <div class="register-home-box">
 
 
        <!-- 步骤一 -->
        <div class="step1" v-if="step == 0">
          <van-field v-model.trim="form.merName" clearable maxlength='80' placeholder="请输入商户名称" />
          <van-field v-model.trim="form.licenseNo" clearable maxlength='20' placeholder="请输入营业执照号" />
          <van-field v-model.trim="form.legalName" clearable maxlength='12' placeholder="请输入法人姓名" />
          <van-field v-model.trim="form.legalIdNo" clearable maxlength='18' placeholder="请输入法人身份证号" />
          <van-field v-model.trim="form.addrText" clearable :readonly="true" right-icon="arrow"
            @click="isShowArea = !isShowArea" placeholder="请选择省市区" />
          <van-field v-model.trim="form.dtlAddr" clearable maxlength='64' placeholder="请输入您的详细地址" />
          <!-- 扫码进入页面的没有邀请码 -->
          <van-field v-if="ShowqrCode"  v-model.trim="form.inviteCode"
            :placeholder="getQr ? '已扫描':'邀请码'" />
          <van-button :color="$store.state.backColor" class="btn" @click="nextStep">下一步</van-button>
          <!-- <van-cell v-if="ShowqrCode" :readonly="true" :value="form.licenseNo"
            placeholder="邀请码">
          </van-cell> -->
        </div>
 
 
 
 
 
 
 
 
        <!-- 步骤二 -->
        <div class="step2" v-if="step == 1">
          <van-field v-model.trim="form.priName" clearable maxlength='12' placeholder="请输入负责人姓名" />
          <van-field v-model.trim="form.priMblNo" type="tel" clearable maxlength='11' placeholder="请输入负责人手机号" />
 
          <div class="tips" :style="{color:$store.state.backColor}">*该手机号将作为登录用户名,密码将通过短信下发至手机</div>
 
          <van-field style="margin-top: 0.3rem" v-model.trim="form.priEmail" clearable placeholder="请输入联系人邮箱" />
 
 
          <van-button :color="$store.state.backColor" class="btn" @click="nextStep">下一步</van-button>
        </div>
 
 
 
 
 
 
 
 
        <!-- 步骤三 -->
        <div class="step3" v-if="step == 2">
 
          <div>
            <p class="content-box">
              <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;【审慎阅读】</b>您的申请注册流程中点击同意前,应当认真阅读以下协议。请您务必审慎阅读、充分理解协议中相关条款内容。阅读协议的过程中,<u>如果您不同意相关协议或其中任何条款规定,您应立即停止注册程序。</u>
            </p>
            <div class="agreement-title" :style="{color:$store.state.backColor}"  @click="showAgreementFunc(1)">《平台使用协议》</div>
            <!--<div class="agreement-title" @click="showAgreementFunc(2)">《智分期商户协议》</div>-->
          </div>
 
          <van-button :color="$store.state.backColor" class="btn" @click="nextStep">{{ saveText }}</van-button>
        </div>
 
 
 
 
 
 
 
 
      </div>
 
      <van-popup v-model="ShowAgreen">
        <div class="agreenBox">
          <div class="agreen-html" v-html="Agreend"></div>
          <div class="close-agreen" @click="ShowAgreen = false">
            <van-icon name="close" :color="$store.state.backColor"/>
          </div>
        </div>
      </van-popup>
 
 
      <van-popup v-model="isShowArea" position="bottom" :close-on-click-overlay="false">
        <van-area ref='Area' :area-list='areaList' @cancel="closeAreaModal" @confirm="setAreaValue"></van-area>
      </van-popup>
    </div>
    <div style="font-size: 12px; color: #666;text-align: center;width: 100%;margin-top: 20px;">
      客服电话:028-60102895
    </div>
  </div>
</template>
 
<script>
  import createUserProtocol from '@/utils/createUserProtocol';
  import {
    SET_APP_LOADING
  } from '@/store/mutations-types';
  import {
    mapState,
    mapMutations
  } from 'vuex';
  export default {
    name: "register-home",
    data() {
      return {
        form: {
          //第一步
          inviteCode: '', //邀请码
          merName: '', //商户名称
          licenseNo: '', //营业执照号
          legalName: '', //法人姓名
          legalIdNo: '', //法人身份证号
          orgId: '',
          orgType: '',
          // orgId: '100001',
          // orgType: '1',
          dtlAddr: '',
          addr: {
            province: {
              code: '',
              name: ''
            },
            city: {
              code: '',
              name: ''
            },
            area: {
              code: '',
              name: ''
            },
            dtlAddr: '' //详细地址
          },
          addrText: '',
 
 
          //第二步
          priName: '', //负责人姓名
          priMblNo: '', //请输入负责人手机号
          priEmail: '', //请输入联系人邮箱
 
          protocol: ''
        },
        isShowArea: false,
        getQr: false,
 
        saveText: '下一步',
        step: 0,
        ShowAgreen: false,
        Agreend: '',
 
 
        ShowqrCode:true,
 
        //第一步验证
        ruleOne: [
          {
            key: "legalName",
            message: "请输入法人代表姓名",
            type: "isEmpty"
          },
          {
            key: "legalIdNo",
            message: "请输入法人代表身份证号",
            type: "isEmpty"
          },
          {
            key: "legalIdNo",
            message: "请输入正确的身份证号",
            type: "isIdCard"
          },
          {
            key: "addrText",
            message: "请选择省市区",
            type: "isEmpty"
          },
          {
            key: "dtlAddr",
            message: "请输入详细地址",
            rule: /\S/
          },
        ],
 
 
 
 
        //第二步验证
        ruleTwo: [{
            key: "priName",
            message: "请输入负责人姓名",
            type: "isEmpty"
          },
          {
            key: "priMblNo",
            message: "请输入负责人手机号",
            type: "isEmpty"
          },
          {
            key: "priMblNo",
            message: "请输入正确的负责人手机号",
            type: "isTel"
          },
          {
            key: "priEmail",
            message: "请输入联系人邮箱",
            type: "isEmpty"
          },
          {
            key: "priEmail",
            message: "请输入正确的联系人邮箱",
            type: "isEmail"
          },
        ],
 
 
 
      }
    },
    computed: {
      ...mapState(['areaList']),
      orgId() {
        return this.$route.query.orgId || '';
      }
    },
    created() {
      console.log(localStorage.sib_mer_sysPlat == 'undefined')
      if(this.$route.query.orgId){
        this.form.orgId = this.$route.query.orgId || '';
        this.form.orgType = this.$route.query.orgType || '';
        this.ShowqrCode = false;
      }
      this.initWXToken(location.origin + location.pathname);
    },
    methods: {
      ...mapMutations([SET_APP_LOADING]),
      back() {
        if (this.step === 0) {
          this.$router.go(-1)
        }
        this.step--;
      },
 
      //显示协议
      showAgreementFunc(which) {
        this.ShowAgreen = true;
        let protocol = createUserProtocol(this.form); //协议二
        this.form.protocol = protocol;
        which === 1 ? this.Agreend = agreement5 : this.Agreend = protocol;
      },
 
      // 验证form参数
      validatorForm(rule = []) {
        return this.$validator(this.form, rule).check(item => {
          this.$notify(item.message)
        })
      },
 
      //关闭地区弹窗
      closeAreaModal() {
        this.isShowArea = false;
        this.$refs.Area.reset()
      },
 
 
      //保存 地区选择
      setAreaValue(arr) {
        this.form.addrText = arr[0].name + '-' + arr[1].name + '-' + arr[2].name;
        this.form.addr = {
          province: {
            code: arr[0].code,
            name: arr[0].name
          },
          city: {
            code: arr[1].code,
            name: arr[1].name
          },
          area: {
            code: arr[2].code,
            name: arr[2].name
          },
        }
        this.isShowArea = false;
        this.$refs.Area.reset()
      },
 
 
 
      nextStep() {
 
        /**
         *  第一步
         * */
        if (this.step === 0) {
          if (!this.validatorForm(this.ruleOne)) return
          // if(!this.$route.query.orgId){
          //   if (!this.getQr) {
          //     this.$notify('请识别二维码');
          //     return;
          //   }
          // }
        }
 
 
        /**
         *  第二步
         * */
        if (this.step === 1) {
          if (!this.validatorForm(this.ruleTwo)) return
          this.saveText = '同意协议';
        }
 
 
 
        /**
         *  第三步
         * */
        if (this.step === 2) {
          this.form.addr.dtlAddr = this.form.dtlAddr
          this.form.protocol = createUserProtocol(this.form); //协议二
          let sysPlat = localStorage.sib_mer_sysPlat
          if (sysPlat === 'undefined' || sysPlat === '1') {
            sysPlat = 1
          }
          if (sysPlat === '2') {
            sysPlat = 2
          }
          this.form.sysPlat = sysPlat
          console.log(this.form);
          this.$api.merRegist(this.form).then(res => {
            this.$toast.success(`注册成功,请耐心等待审核!`);
            if(sessionStorage.isddxt == 1){
              this.$router.push('/?platNo=ddxt');
            }else{
              this.$router.push('/');
            }
 
          }).catch(err=>{
            this.step -= 1;
          });
        }
        this.step++;
      },
 
 
 
      //代理所属渠道
      getRegIDAndType() {
        let _this = this;
        console.log('js 调用原生android 方法=====》');
        window.sessionStorage.removeItem('scene_regInfos');
        if (window.android && window.android.fetchQrCode) {
          _this.SET_APP_LOADING(true);
          window.android.fetchQrCode();
          let count = 0;
          let setInterId = setInterval(function () {
            let _tempStr = window.sessionStorage.getItem(
              'scene_regInfos'
            );
            count++;
            if (_tempStr && _tempStr.length > 0) {
              // QRGoBack 这个值不能修改这里的只是和android 值同步的
              if (_tempStr == 'QRGoBack') {
                // _this.getQr = false;
                _this.SET_APP_LOADING(false);
              } else {
                _tempStr = JSON.parse(_tempStr);
                _this.form.orgId = _tempStr.orgId;
                _this.form.orgType = _tempStr.orgType;
                if(_tempStr.orgId){
                  // _this.ShowqrCode = false;
                }
                _this.getQr = true;
                _this.SET_APP_LOADING(false);
              }
              clearInterval(setInterId);
            }
          }, 60);
        } else {
          wx.scanQRCode({
            needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
            scanType: ['qrCode', 'barCode'], // 可以指定扫二维码还是一维码,默认二者都有
            success: function (res) {
              var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
              if (result && (result + '').indexOf('orgId') > -1) {
                result = JSON.parse(result);
                _this.form.orgId = result.orgId;
                _this.form.orgType = result.orgType;
                if(result.orgId){
                  // _this.ShowqrCode = false;
                }
                _this.getQr = true;
              } else {
                _this.$notify('无效的二维码');
              }
            }
          });
        }
      },
 
 
      initWXToken(parUrl) {
        this.$api.getTokenInfo({
          url: parUrl
        }).then(
          function (res) {
            if (res.errorCode === 0) {
              // 第二步骤   只需要首页地址分享 ,需要在每次变化时调用
              wx.config({
                debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
                appId: res.body.appId,
                timestamp: res.body.timestamp, // 必填,生成签名的时间戳
                nonceStr: res.body.nonceStr, // 必填,生成签名的随机串
                signature: res.body.signature, // 必填,签名,见附录1
                jsApiList: [
                  'checkJsApi',
                  'scanQRCode',
                  'getLocation'
                ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2
              });
            }
          },
          function (error) {
            if (error.response) {
              console.log(error.response);
            }
          }
        );
      }
 
    }
  }
</script>
 
<style scoped lang="less">
  .agreement-title {
    margin-top: 25px;
    color: @c-default;
  }
 
 
  .agreenBox {
    width: 80vw;
    height: 70vh;
    padding: 60px 20px 30px 20px;
    position: relative;
  }
 
  .agreen-html {
    width: 100%;
    height: 100%;
    overflow: scroll;
    box-sizing: border-box;
  }
 
 
  .close-agreen {
    .lh(30px);
    .flex(center, center);
 
    .van-icon {
      font-size: @font-16;
    }
  }
 
 
  .register-home {
    padding-top: 44px;
    padding-bottom: 100px;
 
    .van-cell {
      margin-top: 10px;
    }
 
    .register-home-box {
      padding: 10px 20px 50px;
 
 
    }
 
    .tips {
      font-size: @font-12;
      padding-left: 0.32rem;
      margin-top: 8px;
      color: @c-default;
    }
 
    .btn {
      width: 340px;
      height: 44px;
      border: none;
      margin: 40px auto;
      font-size: @font-16;
      border-radius: 22px;
      background-color: @c-bg-default;
      color: @c-text-fff;
    }
  }
</style>