市北党建引领小程序初始化
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

197 lines
4.2 KiB

// subpages/volunteer/components/volunteerComponents/index.js
const app = getApp()
const api = require("../../../../utils/api.js")
Page({
/**
* 页面的初始数据
*/
data: {
statusHeight: app.globalData.deviceInfo.statusHeight, // 自定义头部状态栏高度
navigationHeight: app.globalData.deviceInfo.navigationHeight,
type: 0,
volunteerTypeArr: ['街道服务队', '社区服务队'],
volunteerType: 0,
volunteerTypeOneInfo: {
name: "",
idCard: "",
mobile: "",
street: "",
deptId: "",
workUnit: "", //工作单位
specialty: "", //特长
serviceType: 0,
workAddr: ""
},
streetArr: ["大港街道", "即墨路街道", "辽宁路街道", "兴隆路街道", "延安路街道", "湖岛街道", "登州路街道", "水清沟街道", "台东街道", "阜新路街道",
"四方街道", "开平路街道", "宁夏路街道", "镇江路街道", "海伦路街道", "敦化路街道", "双山街道", "洛阳路街道", "辽源路街道", "河西街道", "合肥路街道",
"浮山新区街道"
],
communityArr: ['登台村', '将军台社区'],
options: null,
streetData: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.getByLoginUser()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
back() {
//返回上一级,关闭当前页面
wx.navigateBack({
delta: 1
})
},
change(e) {
this.setData({
type: e.target.dataset.type == "0" ? 1 : 0
})
},
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.detail)
this.setData({
volunteerType: e.detail.value,
})
},
bindPickerStreet: function(e) {
this.setData({
["volunteerTypeOneInfo.street"]: this.data.streetArr[e.detail.value]
})
},
bindPickerCommunity: function(e) {
this.setData({
["volunteerTypeOneInfo.community"]: e.detail.value
})
},
bindNameInput: function(e) {
this.setData({
["volunteerTypeOneInfo.name"]: e.detail.value
})
},
bindIDnumberInput: function(e) {
this.setData({
["volunteerTypeOneInfo.idCard"]: e.detail.value
})
},
bindphoneInput: function(e) {
this.setData({
["volunteerTypeOneInfo.mobile"]: e.detail.value
})
},
bindworkUnitInput: function(e) {
this.setData({
["volunteerTypeOneInfo.workUnit"]: e.detail.value
})
},
bindspecialityInput: function(e) {
this.setData({
["volunteerTypeOneInfo.specialty"]: e.detail.value
})
},
submit() {
if (!this.data.volunteerTypeOneInfo.name || !this.data.volunteerTypeOneInfo.idCard || !this.data
.volunteerTypeOneInfo.mobile || !this.data
.volunteerTypeOneInfo.mobile) {
wx.showToast({
title: "请填写必填项",
duration: 2000 //持续的时间
})
return
}
this.data.volunteerTypeOneInfo.serviceType = this.data.volunteerType;
this.data.volunteerTypeOneInfo.allDeptIds = []
this.data.streetData.forEach(f => {
if (this.data.volunteerTypeOneInfo.street == f.label) {
this.data.volunteerTypeOneInfo.allDeptIds.push(f.allDeptIds)
}
})
const _this = this;
api.saveOrder(_this.data.volunteerTypeOneInfo).then(res => {
if (res != 0) {
wx.showToast({
title: "提交成功",
icon: 'success',
duration: 2000 //持续的时间
})
setTimeout(() => {
_this.back()
}, 2000)
}
}).catch(err => {
wx.showToast({
title: err.msg,
duration: 2000 //持续的时间
})
})
},
getByLoginUser() {
api.getByLoginUser().then(res => {
if (res.code !== 0) {
return
}
let arr = res.data.options[0].children.filter((item) => (item.children));
arr.forEach((f => {
f.children[0].children.forEach(s => {
this.data.streetData.push({
allDeptIds: s.value,
label: f.label
})
})
}))
}).catch(err => {
console.log(err)
})
},
})