// pages/mUser/personalauthentication/personalauthentication.js import userservice from '../../../service/userservice' import authservice from '../../../service/authservice' import bInputCheck from '../../../base/behaviors/bInputCheck' import bLoadingToast from '../../../base/behaviors/bLoadingToast' const app = getApp() Page({ behaviors: [bInputCheck, bLoadingToast], /** * 页面的初始数据 */ data: { idTypes: [ {value: '0', name: '身份证'}, ], idTypeIndex: 0, msg: [{ name: "姓名", id: "piName", input: true, value: '', noValue: false, }, { name: "证件类型", id: "piIdType", type: 'picker', pickerMode: 'selector', value: '', noValue: false, selectIndex: 0, options: [ {name: '未选择', value: '-1'}, {name: '身份证', value: '0'}, ] }, { name: "证件编号", id: "piId", input: true, value: "", noValue: false, }, { name: "职位", id: "piPosition", type: 'picker', pickerMode: 'selector', value: '', noValue: false, selectIndex: 0, options: [ {name: '未选择', value: '-1'}, {name: '管理员', value: '0'}, {name: '职员', value: '1'}, ] }, ], }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { this.setData({ loadingText: '上传中', loadCompleteText: '上传完成' }) this.getPersonalInfo() }, changeIDType(e) { let i = e.detail.value this.setData({ idTypeIndex: i }) }, getPersonalInfo() { var that = this userservice.getBaseInfo(app.globalData.accessToken.userId, { success(data) { const msg = that.data.msg if (data.personalInfo != null) { const info = data.personalInfo msg[0].value = info.piName msg[1].value = info.piIdType for (let i = 0; i < msg[1].options.length; i++) { const o = msg[1].options[i]; if (o.name == msg[1].value) { msg[1].selectIndex = i break } } msg[2].value = info.piId msg[3].value = info.piPosition for (let i = 0; i < msg[3].options.length; i++) { const o = msg[3].options[i]; if (o.name == msg[3].value) { msg[3].selectIndex = i break } } that.setData({ msg, info }) } } }, app.globalData.accessToken.openId) }, //提交个人信息 _submit() { var that = this this.setData({loading: true}) authservice.authPersonal(app.globalData.accessToken.openId, this.data.info, { success(res) { that.setData({loading: false}) wx.navigateBack({ delta: 1, }) }, }) }, })