riku
2022-10-17 eb7366f400867d3f401fe60f06d848d6d1448457
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
// pages/m_user/personalauthentication/personalauthentication.js
import userservice from '../../../service/userservice'
import authservice from '../../../service/authservice'
import b_inputCheck from '../../../base/behaviors/b_inputCheck'
import b_loadingToast from '../../../base/behaviors/b_loadingToast'
 
const app = getApp()
 
Page({
  behaviors: [b_inputCheck, b_loadingToast],
  /**
   * 页面的初始数据
   */
  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,
        })
      },
    })
  },
})