123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- const app = getApp();
- Page({
- data: {
- //身份证手持页
- // 上传的案例图片集合
- scsfzImages: [],
- // 案例图片数目是否达到了最大数目
- scsfzImagesNum: false, //加号图标 显示
- scsfzimg: true, //上传图片 隐藏
- scsfzinitial: true, //初始图片 隐藏
- // 身份证头像页
- sfztxyImages: [],
- sfztxyImagesNum: false, //加号图标 显示
- sfztxyimg: true, //上传图片隐藏
- // sfztxyinitial: true, //初始图片 隐藏
- // 身份证反面页
- sfzfmImages: [],
- sfzfmImagesNum: false, //加号图标 显示
- sfzfmimg: true, //上传图片 隐藏
- // sfzfminitial: true, //初始图片 隐藏
- // 设置上传案例图片的最大数目
- maxImages: 1,
- loadingHidden: false, //加载中
- name: '', //姓名
- number: '', //证件号码
- hold: '', //手持身份证
- positive: '', //身份证正面
- opposite: '', //身份证反面
- initial: [], //头部信息
- SubmissionHidden: true, //提交隐藏显示
- isShow: false,
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this;
- // 获取信息
- let initial_url = 'my/authentication/ididentitychange';
- let initial_data = {
- };
- app.postRequest(initial_url, initial_data, function (res) {
- if (res.code == 201) {
- console.log(res.data.hold);
- that.setData({
- initial: res.data, // 初始数据
- initialcode: res, //获取未上传状态
- name: res.data.name, //姓名
- number: res.data.number, //证件号码
- })
- }
- if (res.data.status == 2){ //如果审核通过 隐藏掉提交按钮
- that.setData({
- SubmissionHidden: false
- })
- } else if (res.code != 201) {
- that.setData({
- SubmissionHidden: false
- })
- }else{
- that.setData({
- SubmissionHidden: true
- })
- }
- })
- },
- //获取姓名
- ObtainName: function (e) {
- var name = e.detail.value;
- console.log(name);
- this.setData({
- name: name
- });
- },
- //获取身份证
- Obtainsfz: function (e) {
- var number = e.detail.value;
- console.log(number);
- this.setData({
- number: number
- });
- },
- // 上传手持身份证
- scsfzclick: function (e) {
- var _this = this;
- wx.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success(res) {
- let tempFilesSize = res.tempFiles[0].size;
-
- if (tempFilesSize > 1024 * 1024 * 3){
- wx.showModal({
- title: '提示',
- content: '图片不得超过3MB',
- showCancel: false,
- })
- return;
- }
- wx.showToast({
- title: '上传中...',
- icon: 'loading'
- });
- // 头部信息
- let dt_url = 'my/images/tempimages';
- let dt_filePath = res.tempFilePaths[0];
- app.Multigraph(dt_url, dt_filePath,function(res){
-
- if (res.code==201){
- // console.log(res.data.img_name);
- _this.setData({
- scsfzImages: dt_filePath,
- scsfzImagesNum: true,
- scsfzimg: false,
- hold:res.data.img_name, //手持身份证
- });
-
- wx.showToast({
- title: '上传成功',
- icon: 'none', // 不显示图标
- duration: 2000
- })
- return;
- }
- app.Tips(res.msg);
-
- });
-
- }
- })
- },
- // 正面页
- sfztxyclick: function (e) {
- var _this = this;
- wx.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success(res) {
- let tempFilesSize = res.tempFiles[0].size;
- if (tempFilesSize > 1024 * 1024 * 3) {
- wx.showModal({
- title: '提示',
- content: '图片不得超过3MB',
- showCancel: false,
- })
- return;
- }
- wx.showToast({
- title: '上传中...',
- icon: 'loading'
- });
- // 头部信息
- let dt_url = 'my/images/tempimages';
- let dt_filePath = res.tempFilePaths[0];
- app.Multigraph(dt_url, dt_filePath, function (res) {
- if (res.code == 201) {
- // console.log(res.data.img_name);
- _this.setData({
- sfztxyImages: dt_filePath,
- sfztxyImagesNum: true,
- sfztxyimg: false,
- positive: res.data.img_name,
- });
- wx.showToast({
- title: '上传成功',
- icon: 'none', // 不显示图标
- duration: 2000
- })
- return;
- }
- app.Tips(res.msg);
- });
- }
- })
- },
- // 反面页
- sfzfmclick: function (e) {
- var _this = this;
- wx.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success(res) {
- // console.log(res.tempFilePaths[0]);
- // tempFilePath可以作为img标签的src属性显示图片
- let tempFilesSize = res.tempFiles[0].size;
- if (tempFilesSize > 1024 * 1024 * 3) {
- wx.showModal({
- title: '提示',
- content: '图片不得超过3MB',
- showCancel: false,
- })
- return;
- }
-
- wx.showToast({
- title: '上传中...',
- icon: 'loading'
- });
- // 头部信息
- let dt_url = 'my/images/tempimages';
- let dt_filePath = res.tempFilePaths[0];
- app.Multigraph(dt_url, dt_filePath, function (res) {
- if (res.code == 201) {
- // console.log(res.data.img_name);
- _this.setData({
- sfzfmImages:dt_filePath,
- sfzfmImagesNum: true,
- sfzfmimg: false,
- opposite:res.data.img_name,
- });
-
- wx.showToast({
- title: '上传成功',
- icon: 'none', // 不显示图标
- duration: 2000
- })
- return;
- }
- app.Tips(res.msg);
- });
- }
- })
- },
- //最后提交认证
- Submission: function (e) {
- var _this =this;
- console.log(this.data.name)
- console.log(this.data.number)
- console.log(this.data.hold)
- console.log(this.data.positive)
- console.log(this.data.opposite)
- if (this.data.name == '') {
- var _name = '请填写您的真实姓名'
- Tips(_name)
- } else if (this.data.number == '') {
- var _number = '请填写本人身份证号码'
- Tips(_number)
- } else if (this.data.hold == '') {
- var _hold = '请上传手持身份证'
- Tips(_hold)
- } else if (this.data.positive == '') {
- var _positive = '请上传身份证头像页'
- Tips(_positive)
- } else if (this.data.opposite == '') {
- var _opposite = '请上传身份证反面页'
- Tips(_opposite)
- } else {
- let income_url = 'my/authentication/ididentity';
- let income_data = {
- name: this.data.name, //姓名
- number: this.data.number, //证件号码
- hold: this.data.hold, //手持身份证
- positive: this.data.positive, //身份证正面
- opposite: this.data.opposite, //身份证反面
- };
- app.postRequest(income_url, income_data, function (res) {
- console.log(res)
- if (res.code == 201) {
- wx.showToast({
- title: '提交成功',
- icon: 'success',
- duration: 2000
- })
- _this.onLoad();
- return
- }
- // console.log(res.data.name)
- // console.log(res.data.number)
- if (res.data.name){
- _this.setData({
- text1: res.data.name,
- isShow: true,
- });
- }
- if (res.data.number) {
- _this.setData({
- text2: res.data.number,
- isShow: true,
- });
- }
- setTimeout(function () {
- _this.setData({
- text1: '',
- text2: '',
- isShow: false,
- });
- }, 2000)
-
- })
- }
- },
- })
- // 提示框
- function Tips(text) {
- wx.showToast({
- title: text,
- icon: 'none', // 不显示图标
- duration: 2500
- })
- }
|