You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

235 lines
4.6 KiB
JavaScript

2 years ago
// pages/helpSignUp/index.js
const app = getApp();
const commonUtil = require('../../utils/commonUtil.js');
const dateUtil = require('../../utils/dateUtil.js');
Page({
/**
* 页面的初始数据
*/
data: {
inputShowed: false,
inputVal: "",
searchListShow:false,
agencyArray:[],
agencyUserId: '',
agencyUserSearchKey: '',
},
getAgencyList: function(searchKeys) {
console.log(searchKeys);
var that = this;
that.data.agencyUserSearchKey = searchKeys;
// 60秒后重新获取验证码
wx.request({
url: app.globalData.ip + '/agency/getListByKeys',
data: {
keys: searchKeys,
},
header: app.globalData.header,
method: "GET",
success: function (res) {
console.log(res);
if (res.data.status == 200) {
that.setData({
agencyArray: res.data.data
});
}
},
fail: function (res) {
}
})
},
showInput: function () {
this.setData({
inputShowed: true
});
},
hideInput: function () {
this.setData({
inputVal: "",
inputShowed: false
});
},
clearInput: function () {
this.setData({
inputVal: ""
});
},
inputTyping: function (e) {
this.setData({
inputVal: e.detail.value
});
if(e.detail.value.length > 0){
this.setData({
searchListShow: true
});
this.getAgencyList(e.detail.value);
}else{
this.setData({
searchListShow: false
});
}
},
setValue:function(e){
console.log( e.currentTarget.dataset.text)
let str = e.currentTarget.dataset.text
let agencyUserId = e.currentTarget.dataset.userid
this.setData({
inputVal: str,
agencyUserId: agencyUserId,
searchListShow: false
});
},
formSubmit(e) {
var that = this;
that.setData({
loading:true
})
console.log('form发生了submit事件携带数据为', e.detail.value)
let values = e.detail.value;
if(app.isEmptyCheck(e.detail.value.userName)){
wx.showToast({
duration: 2000,
title: '请输入姓名',
icon: 'none',
mask: true
})
that.setData({
loading:false
})
} else if(app.isEmptyCheck(e.detail.value.tel)){
wx.showToast({
duration: 2000,
title: '请输入手机号',
icon: 'none',
mask: true
})
that.setData({
loading:false
})
} else if(app.isEmptyCheck(that.data.agencyUserId) && app.isNotEmptyCheck(that.data.agencyUserSearchKey)){
wx.showToast({
duration: 2000,
title: '代理不存在,请先创建代理',
icon: 'none',
mask: true
})
that.setData({
loading:false
})
} else if(app.isEmptyCheck(that.data.agencyUserId)){
wx.showToast({
duration: 2000,
title: '请选择代理',
icon: 'none',
mask: true
})
that.setData({
loading:false
})
} else {
values['agencyUserId'] = that.data.agencyUserId;
console.log(values);
wx.request({
url: app.globalData.ip + '/user/resource/agencyAddUserResource',
data: values,
header: app.globalData.header,
method: "POST",
success: function (addres) {
console.log(addres);
if (addres.data.status == 200) {
wx.reLaunch({
url: '/pages/helpSignUpSuccess/index',
})
that.setData({
loading:false
})
} else {
wx.showToast({
icon: "none",
title: addres.data.msg,
duration: 2000
});
that.setData({
loading:false
})
}
},
fail: function () {
wx.showToast({
icon: "none",
title: '报名失败,请联系管理员',
duration: 2000
});
that.setData({
loading:false
})
}
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})