const app = getApp(); const verify = require("../../../common/js/verify.js"); const { arrayFindKey } = require("../../../common/js/common.js"); let self; Page({ /** * 页面的初始数据 */ data: { info: {}, sex: ['保密', '男', '女'], sex_index: 1, type: ['请选择用户类型', '高层次人才', '职业经理人协会会员', '政府人员', '晋江人力资本公司vip会员', '其他'], type_index: 0, status: 0, comment: '', }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { self = this; app.get('teahouse/user/getUserInfo', function (res) { if (res) { self.setData({ info: { name: res.name, mobile: res.mobile, idcard: res.idcard, company: res.company, job: res.job, } }); self.setData({ sex_index: res.sex }); self.setData({ type_index: arrayFindKey(self.data.type, res.type) }); self.setData({ comment: res.comment }); self.setData({ status: res.status }); } }); }, changeSex(e) { let index = e.detail.value; this.setData({ sex_index: index }); }, changeType(e) { let index = e.detail.value; this.setData({ type_index: index }); }, vmodel(e) { this.setData({ ['info.' + e.currentTarget.dataset.value]: e.detail.value }) }, onSubmit() { let info = self.data.info; if (verify.isEmpty(info.name)) { app.msg('姓名不能为空'); return false; } if (verify.isEmpty(info.mobile) && !verify.isMobile(info.mobile)) { app.msg('电话格式不正确'); return false; } if (info.type_index == 0) { app.msg('请选择用户类型'); return false; } info.sex = self.data.sex_index; info.type = self.data.type[self.data.type_index]; app.post('teahouse/user/editUserInfo', info, function (res) { app.msg('提交成功,等待审核', () => { wx.switchTab({ url: '/pages/home/home/home', }); }); }); }, /** * 用户点击右上角分享 */ onShareAppMessage() { return { title: "晋爱人才", path: "/pages/home/home/home", }; } })