// pages/mine/mine.js var app = getApp(); var utils = require("../../utils/http") var qqmapsdk; Page({ data: { top: app.globalData.statusBarHeight, hgt: app.globalData.titleBarHeight, imgUrl: app.globalData.imgUrl, company: '', department: '', personName: '', post: '', wxnum: '', email: '', brief: '', headimgurl: '', phone: '', disabled: false, user: '', disabledname: false }, onLoad: function (opts) { var that = this; if (!!opts.uid) { that.setData({ user: opts.uid }) } else { that.setData({ user: app.globalData.personMsg.id }) } that.personmsg(); }, personmsg: function () { var that = this; utils.$post({ url: app.globalData.webUrl + 'api/card/info', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { user: that.data.user }, success: function (res) { if (res.data.code == '0') { that.setData({ headimgurl: res.data.data.headimgurl, company: res.data.data.company_name, department: res.data.data.department, personName: res.data.data.name, post: res.data.data.position, wxnum: res.data.data.wx, email: res.data.data.email, brief: res.data.data.brief, phone: res.data.data.phone }) if (res.data.data.joinCompany == '1') { that.setData({ disabledname: true }) } else { that.setData({ disabledname: false }) } } } }) }, onReady: function () { }, companyTap: function (e) { this.setData({ company: e.detail.value }) }, departmentTap: function (e) { this.setData({ department: e.detail.value }) }, nameTap: function (e) { this.setData({ personName: e.detail.value }) }, phoneTap: function (e) { this.setData({ phone: e.detail.value }) }, postTap: function (e) { this.setData({ post: e.detail.value }) }, wxnumTap: function (e) { this.setData({ wxnum: e.detail.value }) }, emailTap: function (e) { this.setData({ email: e.detail.value }) }, briefTap: function (e) { this.setData({ brief: e.detail.value }) }, onPlay: function () { }, saveTap: function () { var that = this; if (!that.data.company) { wx.showToast({ title: "公司名不能为空", icon: "none", duration: 2000 }); return false; } if (!that.data.department) { wx.showToast({ title: "部门不能为空", icon: "none", duration: 2000 }); return false; } if (!that.data.post) { wx.showToast({ title: "职务不能为空", icon: "none", duration: 2000 }); return false; } if (!that.data.personName) { wx.showToast({ title: "姓名不能为空", icon: "none", duration: 2000 }); return false; } if (!that.data.wxnum) { wx.showToast({ title: "微信号不能为空", icon: "none", duration: 2000 }); return false; } if (!that.data.email) { wx.showToast({ title: "邮箱不能为空", icon: "none", duration: 2000 }); return false; } if (!that.data.brief) { wx.showToast({ title: "简介不能为空", icon: "none", duration: 2000 }); return false; } if (!that.data.phone) { wx.showToast({ title: "手机号不能为空", icon: "none", duration: 2000 }); return false; } wx.showLoading({ title: '加载中...', }) that.setData({ disabled: true }) utils.$post({ url: app.globalData.webUrl + 'api/card/save', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { company_name: that.data.company, department: that.data.department, position: that.data.post, phone: that.data.phone, name: that.data.personName, wx: that.data.wxnum, email: that.data.email, brief: that.data.brief, }, success: function (res) { if (res.data.code == '0') { wx.showToast({ title: res.data.msg, icon: "none", duration: 2000 }); setTimeout(function () { wx.navigateBack(); }, 1000) } else { that.setData({ disabled: false }) } }, fail() { that.setData({ disabled: false }) } }) }, onPlayNav: function () { }, onShow: function () { this.setData({ top: app.globalData.statusBarHeight, hgt: app.globalData.titleBarHeight, }) }, backTap: function () { wx.navigateBack(); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ // onShareAppMessage: function () { // } })