import { getAllFactoryList, feedbackMillInformation } from "../../../api/ztb" const util = require('../../../utils/util') const app = getApp() Page({ /** * 页面的初始数据 */ data: { safeBottom: app.globalData.safeBottom, fatoryName: null, fatoryNameList: [], typeList: [ {value: '1', text: '价格'}, {value: '2', text: '纸厂排队'}, {value: '3', text: '最近扣点'} ], postForm: { content: '', millId: null, type: null } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { wx.showLoading({ title: '加载中', mask: true }) getAllFactoryList().then(result => { var fatoryNameList = [] result.data.forEach(element => { fatoryNameList.push({value: element.paperMillId, text: element.name}) }) this.setData({ fatoryNameList, safeBottom: app.globalData.safeBottom }) wx.hideLoading() }).catch(err => { wx.hideLoading() util.showToast(err) }) }, 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] }) }, showPicker: function(e){ this.pickerView = this.pickerView || this.selectComponent('#picker-view') if(e.currentTarget.id == 'millId'){ this.pickerView.showPicker(this.data.fatoryNameList, this.data.postForm.millId, 1) } else { this.pickerView.showPicker(this.data.typeList, this.data.postForm.type, 2) } this.setData({ picking: true }) }, onPickerChange: function ({detail}) { this.setData({ picking: false }) if(!detail){ return } if(detail.type == 1){ this.data.postForm.millId = detail.value this.setData({ fatoryName: detail.text }) } else if(detail.type == 2){ this.data.postForm.type = detail.value this.setData({ typeName: detail.text }) } }, subFeedBack: function () { if (util.isEmpty(this.data.postForm.millId)) { util.showToast('请选择纸厂') return } if (util.isEmpty(this.data.postForm.type)) { util.showToast('请选类型') return } if (util.isEmpty(this.data.postForm.content)) { util.showToast('请填写内容') return } wx.showLoading({ title: '处理中', mask: true }) feedbackMillInformation(this.data.postForm).then(res => { wx.hideLoading() if (res.code == 0) { util.showToast('提交成功!') wx.redirectTo({ url: '/pages/article/sucessful/index'}) } else { util.showToast('提交失败失败!原因:' + res.message) } }).catch(err => { wx.hideLoading() util.showToast(err) }) }, bindInput: function (e) { this.setData({ 'postForm.content': e.detail.value }) } })