city_card/pages/checkIn/checkInDetail.js

157 lines
5.2 KiB
JavaScript
Raw Normal View History

2023-07-15 14:25:28 +08:00
var a = getApp();
Page({
data: {
token: a.globalData.token,
array: [],
index: 0,
sexSelected: "",
communityArray: [],
communityIndex: 0,
communitySelected: "",
neighbourArray: [ "请选择所在小区" ],
neighbourIndex: 0,
date: "请选择出生日期",
partyDate: "请选择入党时间",
floorNum: "",
roomNum: "",
affair: "",
realName: "",
workUnit: "",
isLoading: !1
},
bindPickerChange: function(a) {
this.setData({
index: a.detail.value,
sexSelected: this.data.sexAll[a.detail.value - 1].dataId
});
},
bindDateChange: function(a) {
this.setData({
date: a.detail.value
});
},
bindPartyDateChange: function(a) {
this.setData({
partyDate: a.detail.value
});
},
bindCommunityPickerChange: function(a) {
this.setData({
communityIndex: a.detail.value,
communitySelected: this.data.communityAll[a.detail.value - 1].communityId
});
},
bindNeighbourPickerChange: function(a) {
this.setData({
neighbourIndex: a.detail.value
});
},
submitCheckIn: function() {
var e = this;
if (!e.data.isLoading) {
var t = {
userName: e.data.realName,
sexId: e.data.sexSelected,
sexName: e.data.sexAll[e.data.index - 1].dataName,
birthday: e.data.date,
joinTime: e.data.partyDate,
workUnit: e.data.workUnit,
workUnitValue: "非ID",
community: e.data.communitySelected,
residential: e.data.communityAll[e.data.neighbourIndex - 1].residential,
residentialValue: e.data.communityAll[e.data.neighbourIndex - 1].residentialValue,
building: e.data.floorNum,
buildingValue: "非ID",
houseNumber: e.data.roomNum,
houseNumberValue: "非ID",
ability: e.data.affair,
areaCode: wx.getStorageSync("areaCode")
};
e.setData({
isLoading: !0
}), a.restAjax.post(a.restAjax.path(a.apis.submitCheckIn, [ a.baseUrls.requestUrl ]), t, {
headers: {
token: a.globalData.token
}
}, function(a, t) {
wx.showToast({
title: "报到成功",
icon: "success"
}), setTimeout(function() {
e.setData({
isLoading: !1
}), wx.navigateBack({
delta: 1
});
}, 1500);
}, function(a, t) {
console.log(t), e.setData({
isLoading: !1
});
});
}
},
getSex: function() {
var e = this;
a.restAjax.get(a.restAjax.path(a.apis.getDictionary, [ a.baseUrls.serviceUrl, "4ef46940-76ab-4758-b5f0-0cbc93ffc660" ]), {}, {
headers: {
token: a.globalData.token
}
}, function(a, t) {
console.log(t);
for (var n = [ "请选择性别" ], i = 0; i < t.length; i++) n.push(t[i].dataName);
e.setData({
array: n,
sexAll: t
});
}, function(a, e) {
console.log(e);
});
},
getMyCommunity: function() {
var e = this;
a.restAjax.get(a.restAjax.path(a.apis.mycommunity, [ a.baseUrls.requestUrl ]), {}, {
headers: {
token: a.globalData.token
}
}, function(a, t) {
for (var n = [ "请选择所在社区" ], i = e.data.neighbourArray, o = 0; o < t.length; o++) n.push(t[o].communityName),
"ID" == t[o].residentialValue ? e.getResidential(t[o].residential) : i.push(t[o].residential);
e.setData({
communityArray: n,
communityAll: t
});
}, function(a, e) {
console.log(e);
});
},
getResidential: function(e) {
var t = this;
a.restAjax.get(a.restAjax.path(a.apis.getResidential, [ a.baseUrls.communityUrl, e ]), {}, {
headers: {
token: a.globalData.token
}
}, function(a, e) {
var n = t.data.neighbourArray;
n.push(e.residentialName), t.setData({
neighbourArray: n
});
}, function(a, e) {
console.log(e);
});
},
onLoad: function(a) {
this.getSex(), this.getMyCommunity(), this.setData({
curCommunityName: wx.getStorageSync("curCommunityName") ? wx.getStorageSync("curCommunityName") : "切换社区",
curCommunityId: wx.getStorageSync("curCommunityId") ? wx.getStorageSync("curCommunityId") : ""
});
},
onReady: function() {},
onShow: function() {},
onHide: function() {},
onUnload: function() {},
onPullDownRefresh: function() {},
onReachBottom: function() {},
onShareAppMessage: function() {}
});