// pages3/complaint/complaint.js const Http = require("../../utils/HttpBasics"); var config = require("../../config/config.js"); var app = getApp(); const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px' Page({ /** * 页面的初始数据 */ data: { navigationBarHeight, titleVale: "", //标题 descrideVal: "", //描述 goHomeUrl: "", }, setDescrideVal(e) { //赋值标题 let descrideVal = e.detail.value this.setData({ descrideVal: descrideVal }) }, setTitVal(e) { //赋值描述 let titleVale = e.detail.value this.setData({ titleVale: titleVale }) }, save() { //提交 if (!this.data.titleVale) { wx.showToast({ title: '请输入标题', icon: "none", duration: 2000 }) return } else if (!this.data.descrideVal) { wx.showToast({ title: '请输入类容', icon: "none", duration: 2000 }) return } let parameter = { title: this.data.titleVale, explains: this.data.descrideVal } Http.post({ url: config.api.suggest, data: parameter }).then(item => { let this_ = this wx.showToast({ title: "提交成功!", icon: 'none', duration: 2000, success: () => { setTimeout(() => { wx.switchTab({ url: this_.data.goHomeUrl }) }, 2000) } }); }).catch(err => { wx.showToast({ title: err.errMsg, icon: 'none', duration: 2000, // mask: false }); }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ goHomeUrl: app.globalData.goHomeUrl }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })