xusd
7 days ago 998218675eb243d43912c203174a6b72b299c0f8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// 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;
      }
    },
  },
});