home.js
4.3 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
// pages/home/home.js
var app = getApp();
var baseUrl = app.globalData.baseUrl;
Page({
/**
* 页面的初始数据
*/
data: {
load_finish: false,
text_tip: "自然人信息不完善,立即完善",
taxlist: ['']
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
console.log('onLoad')
if (app.globalData.OSSUrl.length == 0) {
app.configOssUrl()
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
console.log('onShow')
this.getTaxList()
},
getTaxList: function() {
var that = this;
wx.showLoading({
title: '加载中',
})
var Authorization = app.globalData.Authorization;
console.log('Authorization', Authorization)
if (!Authorization || Authorization.length < 10) {
return
}
wx.request({
url: baseUrl + 'persontax/v1/personal-taxes',
method: "GET",
header: {
'content-type': 'application/json', // 默认值
"Authorization": Authorization
},
data: {
'all': true
},
success: function(res) {
console.log('succ',res)
if(res.statusCode ==200){
that.handleData(res.data);
}else{
wx.showModal({
title: res.data.message,
content: '',
showCancel:false,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
wx.redirectTo({
url: '../../getPhone/getPhone',
})
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
},
fail(res) {
console.log(res.data)
},
complete() {
wx.hideLoading()
that.setData({
load_finish: true
})
}
})
},
handleData: function(data) {
if (data.items && data.items.length > 0) {
var datalist = []
for (var i = 0; i < data.items.length; i++) {
data.items[i].newmobile = this.formatMobile(data.items[i].mobile)
data.items[i].newidnum = this.formatIdNum(data.items[i].id_card_no)
if (i==0){
data.items[i].relative = "本人"
}else{
data.items[i].relative = data.items[i].family_ties
}
datalist.push(data.items[i])
}
this.setData({
taxlist: datalist
})
this.getStatus(datalist)
}
console.log('handleData', this.data.taxlist)
},
formatMobile: function(mobile) {
if (mobile && mobile > 7) {
return mobile.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2');
} else {
return mobile
}
},
formatIdNum: function(idnum) {
if (idnum && idnum.length >= 6 && idnum.length < 10) {
return idnum.substring(0, 2) + '****' + idnum.substring(idnum.length - 2, idnum.length);
} else if (idnum.length >= 10) {
return idnum.substring(0, 4) + '****' + idnum.substring(idnum.length - 4, idnum.length);
} else {
return idnum
}
},
getStatus: function(data) {
console.log('data', data)
if (data[0].family_ties.length < 1 && data[0].name.length > 0 && data[0].taxpayer_status.length > 0 && data[0].id_card_type.length > 0 && data[0].id_card_no.length > 0 && data[0].mobile.length > 0) {
this.setData({
text_tip: '去查看'
})
} else {
this.setData({
text_tip: '自然人信息不完善,立即完善'
})
}
},
goadd: function(e) {
console.log(e)
wx.navigateTo({
url: 'addinfo/addinfo',
})
},
goedit: function(e) {
console.log(e)
wx.navigateTo({
url: 'editinfo/editinfo?id=' + e.currentTarget.id,
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})