134 lines
3.0 KiB
JavaScript
134 lines
3.0 KiB
JavaScript
const app = getApp()
|
|
const api = require("../../../utils/request.js");
|
|
Page({
|
|
data: {
|
|
canIUse: wx.canIUse('button.open-type.getUserInfo'),
|
|
array:['男','女'],
|
|
ageArr:[],
|
|
index:0,
|
|
userinfo:{},
|
|
if_checked:false,
|
|
},
|
|
onLoad: function () {
|
|
wx.hideHomeButton()
|
|
let that = this;
|
|
let userinfo = wx.getStorageSync('userinfo');
|
|
that.setData({
|
|
userinfo: userinfo
|
|
})
|
|
},
|
|
onShow: function () {
|
|
let that = this;
|
|
let userinfo = wx.getStorageSync('userinfo');
|
|
// debugger;
|
|
// console.log('registe:'+userinfo);
|
|
that.setData({
|
|
userinfo: userinfo
|
|
})
|
|
},
|
|
nameInput(e){
|
|
let that = this;
|
|
that.setData({
|
|
['userinfo.name']:e.detail.value
|
|
})
|
|
},
|
|
ageInput(e){
|
|
let age = e.detail.value.replace(/\D/g, '');
|
|
console.log('age:'+age)
|
|
this.setData({
|
|
['userinfo.age']: age,
|
|
})
|
|
return e.detail.value.replace(/\D/g, '')
|
|
},
|
|
phoneChange: function (e) {
|
|
let that = this;
|
|
let phone = e.detail.value;
|
|
var phoneReg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
|
|
if (phoneReg.test(phone)) {
|
|
that.setData({
|
|
['userinfo.username']:phone
|
|
})
|
|
that.data.userinfo.username = phone
|
|
} else {
|
|
wx.showToast({
|
|
title: '请输入正确的手机号!',
|
|
icon: 'none'
|
|
})
|
|
}
|
|
},
|
|
numberChange(e){
|
|
let numb = e.detail.value.replace(/\D/g, '');
|
|
this.setData({
|
|
['userinfo.ID_number1']: numb,
|
|
})
|
|
return e.detail.value.replace(/\D/g, '')
|
|
},
|
|
deptChange(e){
|
|
let that = this;
|
|
that.setData({
|
|
['userinfo.companyname']:e.detail.value
|
|
})
|
|
},
|
|
postChange(e){
|
|
let that = this;
|
|
that.setData({
|
|
['userinfo.title']:e.detail.value
|
|
})
|
|
},
|
|
bindPickerChange(e){
|
|
let that = this;
|
|
that.setData({
|
|
index:e.detail.value
|
|
})
|
|
that.data.userinfo.sex = that.data.array[e.detail.value];
|
|
this.setData({
|
|
['userinfo.sex']: that.data.array[e.detail.value],
|
|
})
|
|
},
|
|
onLoad: function () {
|
|
wx.hideHomeButton()
|
|
},
|
|
|
|
zhuce: function (data) {
|
|
api.request('/crm/consumer/improve/', 'POST', data).then(res => {
|
|
getApp().onLaunch()
|
|
wx.switchTab({
|
|
url: '/pages/main/main',
|
|
})
|
|
})
|
|
},
|
|
checkedChange(e){
|
|
let if_checked = !this.data.if_checked;
|
|
this.setData({
|
|
if_checked:if_checked
|
|
})
|
|
},
|
|
clickdenglu(){
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '请先阅读并同意协议',
|
|
})
|
|
},
|
|
tijiao(){
|
|
let userinfo = this.data.userinfo;
|
|
if(userinfo.name!==''&&userinfo.name!==null&&userinfo.name!=='未知'){
|
|
api.request('/crm/consumer/improve/', 'POST', userinfo).then(res => {
|
|
// debugger;
|
|
// console.log('信息补全成功'+res)
|
|
wx.setStorageSync('userinfo', userinfo);
|
|
app.globalData.userinfo = userinfo;
|
|
// let usIn = wx.getStorageSync('userinfo');
|
|
// console.log(usIn)
|
|
wx.switchTab({
|
|
url: '/pages/main/main',
|
|
})
|
|
})
|
|
}else{
|
|
wx.showToast({
|
|
icon: 'none',
|
|
title: '请完善信息后提交',
|
|
})
|
|
}
|
|
},
|
|
})
|