123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- // nova-travel/page/cauth/cauth.js
- var qiniuUploader = require("../../../../utils/qiniuUploader");
- var Parse = getApp().Parse;
- var company = getApp().globalData.company
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- focus: false,
- fileList: [],
- fileList_1: [],
- uploadURL: "", //七牛参数
- domain: "", //七牛参数
- uptokenURL: "", //七牛参数
- optionId: "",
- auth: true,
- activeColor:getApp().globalData.activeColor,
- titleColor:getApp().globalData.titleColor
- },
- bindKeyInput(e) {
- this.setData({
- [e.currentTarget.dataset.prop]: e.detail.value
- })
- },
- submit() {
- const _this = this
- if (!this.data.name || !this.data.mobile || !this.data.id) {
- wx.showToast({
- title: '请填写完整信息',
- icon: 'none',
- duration: 2000
- })
- return
- }
- let name = /[\u4e00-\u9fa5]/,
- text = this.data.name;
- if (!name.test(text)) {
- wx.showToast({
- title: '请输入您的真实姓名',
- icon: 'none',
- duration: 2000
- })
- return
- }
- let str = this.data.mobile;
- let exist = /^1[34578]\d{9}$/.test(str);
- if (exist == false) {
- wx.showToast({
- title: '手机号码格式有误',
- icon: 'none',
- duration: 2000
- })
- return
- }
- let idReg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/gi
- let id = this.data.id
- if (!idReg.test(id)) {
- wx.showToast({
- title: '请输入正确的身份证号',
- icon: 'none',
- duration: 2000
- })
- return
- }
- wx.request({
- url: "https://server.fmode.cn/api/apig/idcard", //请求接口的url
- method: "POST", //请求方式
- data: {
- company: company,
- cardNo: id,
- realName: text
- }, //请求参数
- header: {
- "content-type": "application/json", // 默认值
- },
- success: (res) => {
- console.log(res.data);
- console.log(res.data.data.result);
- if (res.data.data.result.isok) {
- let User = Parse.Object.extend("_User")
- let user = new User()
- user.id = Parse.User.current().id
- user.set("authentication", {
- "id": _this.data.id,
- "name": _this.data.name,
- "mobile": _this.data.mobile
- })
- user.set('realname',_this.data.name)
- user.set('idcard',_this.data.id)
- user.save().then(res => {
- // 弹窗
- wx.showToast({
- title: '提交成功',
- icon: 'none',
- duration: 2000
- })
- // 重新拉取数据
- _this.getUserInfo()
- })
- } else {
- wx.showToast({
- title: '请输入正确的身份证号和姓名',
- icon: 'none',
- duration: 2000
- })
- }
- },
- })
- },
- getUserInfo() {
- const _this = this
- let User = new Parse.Query("_User")
- User.equalTo("objectId", Parse.User.current().id)
- User.first().then(res => {
- let user = res.toJSON()
- console.log(user)
- if (user.authentication && user.authentication.id) {
- console.log(user.authentication)
- user.authentication.id = user.authentication.id.replace(/^(.{3})(?:\d+)(.{4})$/, "$1***********$2")
- user.authentication.mobile = user.authentication.mobile.replace(/^(.{3})(?:\d+)(.{4})$/, "$1****$2")
- _this.setData({
- userInfo: user.authentication,
- auth: true
- })
- } else {
- _this.setData({
- auth: false
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.getUserInfo()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|