const navigationBarHeight = (getApp().statusBarHeight + 50) + "px"
const Http = require("../../utils/HttpBasics");
var config = require("../../config/config.js");
var app = getApp();
Page({
  data: {
    navigationBarHeight,
  },
  setDescrideVal(e) { //赋值标题
    let descrideVal = e.detail.value
    this.setData({
      descrideVal: descrideVal,
      titleVale: "", //标题
      descrideVal: "", //描述
    })
  },
  setTitVal(e) { //赋值描述
    let titleVale = e.detail.value
    this.setData({
      titleVale: titleVale
    })
  },
  save() { //提交
    if (!this.data.titleVale){
      tt.showToast({
        title: '请输入标题',
        icon: "none",
        duration: 2000
      })
      return
    }else if(!this.data.descrideVal){
      tt.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=>{
      tt.showToast({
        title: "提交成功！",
        icon: 'none',
        duration: 2000,
        success: () => {
          setTimeout(() => {
            tt.reLaunch({
              url: '/index/index'
            })
          }, 2000)
        }
      });
    }).catch(err => {
      tt.showToast({
        title: err.errMsg,
        icon: 'none',
        duration: 2000,
        // mask: false
      });
    })

  },
  onLoad: function (options) {

  }
})