riku
2023-11-29 9b09d13712c0c005891450a3bf4b6d848ec0ff37
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
// 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'
import $f from "../../../service/baserequest";
 
const app = getApp()
 
Page({
  behaviors: [bInputCheck, bLoadingToast],
  /**
   * 页面的初始数据
   */
  data: {
    icon1: $f.baseIconUrl + 'res/companyinfo-1.png',
 
    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: '其他', value: '1'},
        ]
      },
      {
        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,
        })
      },
    })
  },
})