| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- import {
- postApprove
- } from '../../services/index.js'
- import {
- uploadImg
- } from '../../services/uploadFile.js'
- import {
- imgServerUrl,
- imgServerUrl_new
- } from '../../config/config.js'
- import { isIDNum } from '../../utils/base'
- var app = getApp()
- Page({
- data: {
- imgServerUrl: imgServerUrl,
- imgServerUrl_new: imgServerUrl_new,
- realName: '',
- idNum: '',
- idFrontPic: '',
- idBackPic: '',
- idPersonPic: '',
- showMessage: false,
- message: '',
- canUpdate: false,
- from: ''
- },
- onLoad: function (options) {
- if (options.from) {
- this.setData({
- from: options.from
- })
- }
- },
- testCanUpdate() {
- let {
- realName,
- idNum,
- idFrontPic,
- idBackPic,
- // idPersonPic
- } = this.data;
- this.setData({
- canUpdate: false
- })
- if (realName == "") {
- return false;
- }
- if (!isIDNum(idNum)) {
- return false;
- }
- if (idFrontPic == "") {
- return false;
- }
- if (idBackPic == "") {
- return false;
- }
- this.setData({
- canUpdate: true
- })
- },
- callPhone() {
- wx.makePhoneCall({
- phoneNumber: '4006920099',
- success: () => {
- this.setData({
- showMessage: false
- })
- }
- })
- },
- chooseImage(e) {
- let index = e.currentTarget.dataset.index
- var up_type;
- switch (index) {
- case 1:
- up_type = '1';
- break;
- case 2:
- up_type = '2';
- break;
- case 3:
- up_type = '3';
- break;
- }
- uploadImg(up_type).then(res => {
- let image = res.data.imgUrl
- if (index == 1) {
- this.setData({
- idFrontPic: image
- }, _ => {
- this.testCanUpdate()
- })
- } else if (index == 2) {
- this.setData({
- idBackPic: image
- }, _ => {
- this.testCanUpdate()
- })
- } else if (index == 3) {
- this.setData({
- idPersonPic: image
- }, _ => {
- this.testCanUpdate()
- })
- }
- })
- },
- changeName(e) {
- this.setData({
- realName: e.detail.value.trim()
- }, _ => {
- this.testCanUpdate()
- })
- },
- changeId(e) {
- this.setData({
- idNum: e.detail.value.trim()
- }, _ => {
- this.testCanUpdate()
- })
- },
- submit(e) {
- this.testCanUpdate();
- let {
- realName,
- idNum,
- idFrontPic,
- idBackPic,
- // idPersonPic
- } = this.data;
- if (realName == "") {
- wx.showToast({
- title: '请输入姓名',
- icon: 'none'
- })
- return false;
- }
- if (!isIDNum(idNum)) {
- wx.showToast({
- title: '请输入18位身份证号码',
- icon: 'none'
- })
- return false;
- }
- if (idFrontPic == "") {
- wx.showToast({
- title: '请上传身份证正面照',
- icon: 'none'
- })
- return false;
- }
- if (idBackPic == "") {
- wx.showToast({
- title: '请上传身份证反面照',
- icon: 'none'
- })
- return false;
- }
- // if (idPersonPic == "") {
- // wx.showToast({
- // title: '请上传手持身份证照片',
- // icon: 'none'
- // })
- // return false;
- // }
- wx.showLoading({
- title: '正在创建...',
- mask: true
- })
- wx.hideLoading()
- wx.showLoading({
- title: '正在提交...',
- mask: true
- })
- let paramsObj = {
- realName: realName,
- idCardNumber: idNum,
- idFrontPic: idFrontPic,
- idBackPic: idBackPic,
- // idPersonPic: idPersonPic,
- minaType: 1, //1:代表小程序
- user_id: app.globalData.userId,
- user_token: app.globalData.userToken,
- member_id: app.globalData.memberId
- }
- Object.assign(paramsObj);
- postApprove(paramsObj).then(data => {
- wx.hideLoading()
- if (data.errcode === 2009 || data.errcode === 2011) {
- this.setData({
- showMessage: true,
- })
- return
- }
- wx.showToast({
- title: '提交成功',
- })
- if (this.data.from === 'clock') {
- wx.redirectTo({
- url: '../result/index?type=auth&status=2&from=clock',
- })
- return
- }
- wx.redirectTo({
- url: '../result/index?type=auth&status=2',
- })
- })
- // 身份认证上报订阅信息
- wx.aldPushSubscribeMessage({
- eventId: '5ea25ae37739104342928e96'
- });
- },
- onError(err) {
- app.aldstat.sendEvent('报错', {
- 'err': err
- });
- },
- })
|