// pages/article/feedback/index.js import { getAllFactoryList,feedbackMillInformation} from "../../api/ztb" const util = require('../../../utils/util') Page({ /** * 页面的初始数据 */ data: { millIdList:[], fatoryNameList: [], fatoryNameIndex: null, typeIdList:['1','2','3'], typeList:['价格','纸厂排队','最近扣点'], typeIndex:null, postForm:{ content:'', millId:null, type:null } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getAllFactoryListFct() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, PickerChange(e) { console.log(e); this.setData({ fatoryNameIndex: e.detail.value, 'postForm.millId':this.data.millIdList[e.detail.value] }) }, typeChange(e) { console.log(e); this.setData({ typeIndex: e.detail.value, 'postForm.type':this.data.typeIdList[e.detail.value] }) }, getAllFactoryListFct:function(){ this.data.fatoryNameList=[] this.data.millIdList=[] var jxFatoryNameList=[] var jxMillIdList=[] getAllFactoryList().then(res=>{ res.data.forEach(element => { jxFatoryNameList.push(element.name) jxMillIdList.push(element.paperMillId) }); this.setData({ fatoryNameList: jxFatoryNameList, millIdList:jxMillIdList }) }) }, subFeedBack:function(){ if(this.data.postForm.millId==''||this.data.postForm.millId==null){ util.showToast('请选择纸厂') return } if(this.data.postForm.type==''||this.data.postForm.type==null){ util.showToast('请选类型') return } if(this.data.postForm.content==''||this.data.postForm.content==null){ util.showToast('请填写内容') return } this.feedbackMillInformationFct(this.data.postForm) }, textareaBindblur:function(e){ // console.log(e.detail.value) this.setData({ 'postForm.content':e.detail.value }) }, feedbackMillInformationFct:function(model){ feedbackMillInformation(model).then(res=>{ if(res.code==0){ util.showToast('提交成功!') util.navigateTo('/pages/article/sucessFul/index') }else{ util.showToast('提交失败失败!原因:'+res.message) } }) } })