home.js
4.1 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
// pages/main/addtionalreduce/home.js
var app = getApp();
var baseUrl = app.globalData.baseUrl;
Page({
/**
* Page initial data
*/
data: {
datas: ["", ""],
is_declared: false,
hascompleted:false,
additionlist: [],
declareStatus: {
"to_declare ": "待申报",
"declaring": "申报中",
"success": "审核成功",
"failed": "审核失败"
},
additiontitle: {
"children_education": "子女教育",
"continuing_education": "继续教育",
"support_duty": "赡养老人",
"medical_fund": "大病医疗",
"house_fund_rent": "住房",
"house_fund_loan": "住房",
"house_fund": "住房"
},
reducetype:{
"":"月",
"month":"月",
"year":"年"
},
datas02: ["子女教育", "继续教育", "赡养老人", "大病医疗", "住房贷款利息"]
},
/**
* Lifecycle function--Called when page load
*/
onLoad: function (options) {
console.log("onLoad");
},
godeclare: function (e) {
console.log("godeclare", e);
var newdata = this.data.additionlist[e.currentTarget.id]
wx.navigateTo({
url: 'godeclare/godeclare?legal_entity_id=' + newdata.legal_entity_id + "&legal_entity=" + newdata.legal_entity,
})
},
godetail: function () {
wx.navigateTo({
url: 'godetail/godetail',
})
},
lookandadd: function (e) {
var str = e.currentTarget.id.split('-')
var data = this.data.additionlist;
console.log("lookandadd", str);
wx.navigateTo({
url: 'lookandupdate/lookandupdate?status=' + data[str[0]].addition_items[str[1]].addition_category + "&legal_entity_id=" + data[str[0]].legal_entity_id + "&legal_entity=" + data[str[0]].legal_entity,
})
},
/**
* Lifecycle function--Called when page is initially rendered
*/
onReady: function () {
console.log("onReady");
},
/**
* Lifecycle function--Called when page show
*/
onShow: function () {
console.log("onShow");
var that = this
wx.showLoading({
title: '',
})
this.getAdditionList()
},
getAdditionList: function () {
var that = this;
var Authorization = getApp().globalData.Authorization;
wx.request({
url: baseUrl + 'persontax/v1/person-additions',
data: {
limit: 10,
offset: 0
},
header: {
'content-type': 'application/json',
"Authorization": Authorization
},
success: function (res) {
if (res && res.data) {
console.log("res", res)
that.setData({
additionlist: that.handleData(res.data.items)
})
}
wx.hideLoading()
},
complete(res) {
that.setData({
hascompleted: true
})
console.log(res.data)
}
})
},
handleData: function (items) {
for (var i = 0; i < items.length ; i++){
var bigItem = items[i]
for (var j = 0; j < bigItem.addition_items.length; j++) {
var midItem = bigItem.addition_items[j]
if (midItem.addition_category == 'continuing_education'){
var majors = [], professions = []
for (var k = 0; k < midItem.detail_items.length; k++) {
var smallItem = midItem.detail_items[k]
if (smallItem.continue_education_type == 'major'){
majors.push(smallItem)
} else if (smallItem.continue_education_type == 'nomajor'){
professions.push(smallItem)
}
}
items[i].addition_items[j].majors = majors
items[i].addition_items[j].professions = professions
break;
}
}
}
console.log('ddddd', items)
return items
},
/**
* Lifecycle function--Called when page hide
*/
onHide: function () {
},
/**
* Lifecycle function--Called when page unload
*/
onUnload: function () {
},
/**
* Page event handler function--Called when user drop down
*/
onPullDownRefresh: function () {
},
/**
* Called when page reach bottom
*/
onReachBottom: function () {
},
/**
* Called when user click on the top right corner to share
*/
onShareAppMessage: function () {
}
})