// pages/minePages/grxxxg/grxxxg.js import { xcxPhoneNumber, xcxsmbd } from "../../../apis/index" Page({ /** * 页面的初始数据 */ data: { checked: false, userType: [{ type: "个人身份", value: 0 }, { type: "企业身份", value: 1 }], userTypeShow: false, enterpriceType: [], enterpriceTypeShow: false, form: { name: "", userType: "", enterpriceType: "", idcard: "", phone: "" }, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let that = this that.init() }, init() { let that = this let userInfo = wx.getStorageSync('USERINFO') that.setData({ 'form.name': userInfo.name, 'form.idcard': userInfo.idcard, 'form.phone': userInfo.phone }) }, close() { let that = this that.setData({ userTypeShow: false, enterpriceTypeShow: false }) }, userType() { let that = this that.setData({ userTypeShow: true }) }, enterpriceType() { let that = this that.setData({ enterpriceTypeShow: true }) }, name(e) { let that = this let value = e.detail.value that.setData({ 'form.name': value }) }, selectUserType(e) { let that = this let item = e.currentTarget.dataset.item that.setData({ 'form.userType': item.type, userTypeShow: false, enterpriceTypeShow: false }) }, selectEnterprice(e) { let that = this let item = e.currentTarget.dataset.item that.setData({ 'form.enterpriceType': item.nsrmc, userTypeShow: false, enterpriceTypeShow: false }) }, idcard(e) { let that = this let value = e.detail.value that.setData({ 'form.idcard': value }) }, getPhoneNumber(e) { let that = this if (!e.detail.code) { wx.showToast({ title: '用户拒绝', icon: "none", duration: 3000 }) } else { wx.showLoading({ title: '正在修改...', }) xcxPhoneNumber({ code: e.detail.code }).then((res) => { wx.hideLoading() if (res.code == 200) { that.setData({ 'form.phone': res.message }) } else { wx.showToast({ title: res.msg || res.message, icon: "none", duration: 5000 }) } }) } }, xiugai() { let that = this let publicId = wx.getStorageSync('PUBLIC_ID') let form = that.data.form if (form.name.length > 1 && form.idcard.length == 18) { wx.showLoading({ title: '正在修改...', }) let forms = { xcxId: publicId.openid, unionid: publicId.unionid, sfzjhm: form.idcard, sjh: form.phone, xm: form.name } xcxsmbd(forms).then((res) => { wx.hideLoading() if (res.code == 200) { wx.showToast({ title: res.msg || res.message, icon: "none", duration: 3000 }) let userInfo = wx.getStorageSync('USERINFO') userInfo.name = that.data.form.name userInfo.idcard = that.data.form.idcard userInfo.phone = that.data.form.phone wx.setStorageSync('USERINFO', userInfo) wx.navigateBack() } else { wx.showToast({ title: res.msg || res.message, icon: "none", duration: 5000 }) } }) } else { wx.showToast({ title: '请检查身份证或姓名是否正确', icon: "none", duration: 5000 }) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })