// pages/login/login.js import WxValidate from '../../utils/wxValidate' const app = getApp() Page({ /** * 页面的初始数据 */ data: { // 主体高度 infoHeight: '', frameStyle: { useTop: true, name: '个人信息', leftArrow: true, useBar: false }, form: {}, // index: 0, // 上传图片 fileList: [], }, afterRead: function (event) { const { file } = event.detail; // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式app.globalData.fileUrl: console.log(file); wx.uploadFile({ url: `${app.globalData.imageUrl}/files/court/elimg/upload`, filePath: file.url, name: 'file', formData: {}, success: (res) => { console.log(res); if (res.statusCode == '200') { let data = [{ name: JSON.parse(res.data).name, url: `${app.globalData.imageUrl}` + JSON.parse(res.data).uri }] const { fileList = [] } = this.data; fileList.push({ ...file, url: res.data }); this.setData({ fileList }); } else { wx.showToast({ title: `${res.data.errmsg}`, icon: 'fail', duration: 2000 }) } }, }); }, // //选择 // bindPickerChange: function (e) { // console.log('picker发送选择改变,携带值为', e.detail.value) // this.setData({ // index: e.detail.value // }) // }, back: function () { wx.navigateBack({ url: '/pages/me/index' }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (e) { // 计算高度 this.searchHeight() const that = this; // 获取用户信息 wx.getStorage({ key: 'token', success: function (res) { wx.request({ url: `${app.globalData.publicUrl}/courtAdmin/api/user`, //接口地址 method: "post", data: { "id": "", "phone": "", "type": "", "status": "" }, header: {}, success: res => { that.setData({ form: res.data.data }); console.log(res.data.data); console.log(res.data.data.id); }, error: err => { console.log(err); } }) } }) }, //提交 formSubmit: function (e) { let value = e.detail.value; console.log(value); wx.getStorage({ key: 'token', success: function (res) { console.log(res); wx.request({ url: `${app.globalData.publicUrl}/courtAdmin/api/user`, //接口地址 method: "post", data: value, header: {}, success: res => { wx.showToast({ title: '保存成功', icon: 'success', duration: 2000 }) console.log(res); }, }) } }) }, // 计算高度 searchHeight: function () { let frameStyle = this.data.frameStyle; let client = app.globalData.client; // 减去状态栏 let infoHeight = client.windowHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2); // 是否减去底部菜单 if (frameStyle.useBar) infoHeight = infoHeight - 50; if (infoHeight) this.setData({ infoHeight: infoHeight }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })