纸通宝小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

79 lines
2.1 KiB

// pages/home/authory/index.js
import { certificateIdentity} from "../../api/user"
const util = require('../../../utils/util')
const event = require('../../../utils/event')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
form: { },
typeList: [{text: '身份证', value: 1}, {text: '身份证', value: 2}],
disable: true, // 是否不可以编辑, false:可编辑;true:不可编辑
auth: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
// this.pickerView = this.pickerView || this.selectComponent('#picker-view')
const that = this
wx.getStorage({
key: 'identityAuthToken',
success (res) {
that.setData({ form: JSON.parse(res.data)})
}
})
},
showPicker: function (e) {
if (this.data.flag) {
return
}
this.pickerView.showPicker(this.data.typeList, null, 1)
},
onPickerChange: function (e) {
if (!e.detail) {
return
}
if (e.detail.type == 1) {
this.setData({ ['form.bankName']: e.detail.text, ['form.bankId']: Number(e.detail.value) })
}
},
bindForm: function (e) {
// var form_data = 'form.' + e.target.id
this.data.form[e.target.id] = e.detail.value
},
submitForm: function(){
wx.showLoading({ title: '处理中', mask: true })
certificateIdentity(this.data.form).then(res => {
wx.hideLoading()
app.globalData.userInfo.isAuth = 1
app.globalData.userInfo.realName = this.data.form.realName
this.data.auth = true
this.wuxDialog = this.wuxDialog || this.selectComponent('#wux-dialog')
this.wuxDialog.open({
resetOnClose: true,
title: '温馨提示',
maskClosable: false,
content: '个人信息认证成功',
buttons: [ {
text: '确定',
type: 'primary',
onTap(e) {
wx.navigateBack()
}
}]
})
}).catch(error => {
wx.hideLoading()
util.showToast(error)
})
},
onUnload: function () {
if(this.data.auth){
event.emit('EventMessage', { what: 82, desc: 'Auth Success' })
}
}
})