// components/personal-data-dom/index.js const $$ = require('../../utils/util'); const app = getApp(); // 获取信息 function getUserInfoApi() { return $$.request({ url: 'paUser/getUserInfo', type: 'get', service: 'cust' }); } Component({ /** * 组件的属性列表 * submitData: object form数据 * type: string 判断当前使用组件的页面realNameAuthentication为实名认证页面 * isCheck: boolean 判断是否只读不可修改 * isImproveData: boolean 判断是否是完善资料,则不显示证件信息 */ properties: { submitData: { type: Object, value: {}, }, type: { type: String, value: '', }, isCheck: { type: Boolean, value: false, }, isImproveData: { type: Boolean, value: false, }, }, /** * 组件的初始数据 */ select: {}, // 下拉框资源 location: [], data: {}, pageLifetimes: { show() { $$.showLoading(); this._getSelectOptionData(); this._getLocationData(); this._getUserInfo(); }, }, /** * 组件的方法列表 */ methods: { // _handleChange(e) { let key = e.currentTarget.dataset.key; if (key === 'clearidcard') { this.triggerEvent('handleChange', { key: 'idcard', value: '' }); } else { this.triggerEvent('handleChange', { key, value: e.detail }); } }, // 展示弹出层 _handleShowPopup(e) { if (this.data.isCheck) { return false; } let type = e.currentTarget.dataset.type; let title = e.currentTarget.dataset.title; let selectData = []; if (type === 'location') { let selectOption = JSON.parse(JSON.stringify(this.location)); let indexArr = $$.getLocationIndex(this.location, this.data.submitData); selectData = [{ values: selectOption, defaultIndex: indexArr[0] }, { values: selectOption[indexArr[0]].children, defaultIndex: indexArr[1] }, { values: selectOption[indexArr[0]].children[indexArr[1]].children || [], defaultIndex: indexArr[2] }, ]; selectData.forEach((x) => { x.values.forEach((y) => { delete y.children; }); }); } else { let selectOption = this.select[type]; selectData = selectOption; } this.triggerEvent('handleShowPopup', { visible: true, title: title, type: type, selectData: selectData, }); }, // 获取手机号码 _handleGetPhoneNumber(e) { console.log('eeeee', e); this.triggerEvent('handleGetPhoneNumber', e.detail.code); }, // 获取个人信息 async _getUserInfo() { console.log('个人信息') console.log(app.globalData.access_token, 'app.globalData.access_token1111111') const res = await getUserInfoApi(); $$.hideLoading(); if (res.type) { if (res.data.trueName !== null) this.triggerEvent('getUserInfo', res.data); wx.setStorage({ key: 'userInfo', data: res.data }); } }, // 请求下拉框资源 async _getSelectOptionData() { const res = await $$.commonRequest({ url: `${$$.url.assets}selectOption.json`, type: 'get' }); if (res) { this.select = { cardType: [], sex: [], }; this.select.cardType = res.data.cardType || []; this.select.sex = res.data.sex || []; } }, // 获取省市区等地理资源 async _getLocationData() { $$.showLoading(); const res = await $$.commonRequest({ url: `${$$.url.assets}locationSelect.json`, type: 'get' }); $$.hideLoading(); if (res) { let location = []; $$.province.forEach((x) => { location.push(res[x][0]); }); this.location = location; } }, }, });