// components/event/handleSubmit/waitResponse/waitResponse.js import { $wuxActionSheet } from '../../../../dist/index' import { BASEURL } from '../../../../utils/config' // var global = require('./config.js') Component({ /** * 组件的属性列表 */ properties: { waitResponseData: { // 属性名 type: Object, value: {} }, optionsCascader:{ type:Array, value: [] } }, /** * 组件的初始数据 */ data: { BASEURL: BASEURL(), userTagKey: wx.getStorageSync('userTagKey'), visibleCascader: false, //显示分类 isBlock:true, focus: false,//默认没获取焦点 viewData:"" }, /** * 组件的方法列表 */ methods: { // 审核操作 showActionSheetEvent() { const that = this let buttons = [{ text: '审核通过' }, { text: '驳回' }] $wuxActionSheet().showSheet({ // titleText: '自定义操作', buttons: buttons, buttonClicked(index, item) { let state = "" const text = item.text if (item.text === "审核通过") { state = 4 } else if (item.text === "驳回") { state = 2 } const waitResponseData = Object.assign(that.data.waitResponseData, { eventState: state, eventName: text }) that.setData({ waitResponseData }) return true }, cancelText: '取消', cancel() {}, }) }, // 打开选择分类 onOpenCascader() { this.triggerEvent('onOpenCascader') // 触发父组件事件 }, // 填写意见 bindInputAdvice: function (e) { this.setData({//失去焦点以后view隐藏 isBlock: true }) const waitResponseData = Object.assign(this.data.waitResponseData, { advice: e.detail.value }) this.setData({ waitResponseData, viewData: e.detail.value }) }, // Textarea的显示层级太高导致遮挡,通过点击view代替Textarea显示 clickTextarea() { this.setData({ isBlock: false, focus: true }) }, // 提交居民意见 bindFormSubmit() { this.triggerEvent('bindFormSubmit', this.data.waitResponseData) // 触发父组件事件 }, // 上传图片 onChange(e) { // console.log('onChange', e) const { file } = e.detail if (file.status === 'uploading') { this.setData({ progress: 0, }) wx.showLoading() } else if (file.status === 'done') { this.setData({ imageUrl: file.url, }) } let images = [] e.detail.fileList.forEach((item, index, array) => { if (item.res !== undefined) { const imageUrl = JSON.parse(e.detail.fileList[index].res.data).data images.push(imageUrl) } }) const waitResponseData = Object.assign(this.data.waitResponseData, { images: images }) this.setData({ waitResponseData }) }, onSuccess(e) { // console.log('onSuccess', e) }, onFail(e) { // console.log('onFail', e) }, // 上传完成 onComplete(e) { // console.log('onComplete', e) wx.hideLoading() }, // 点击图片放大 onPreview(e) { // console.log('onPreview', e) const { file, fileList } = e.detail wx.previewImage({ current: file.url, urls: fileList.map((n) => n.url), }) }, // 打开选择分类 onOpenCascader() { this.setData({ visibleCascader: true }) }, // 关闭选择分类 onCloseCascader() { this.setData({ visibleCascader: false }) }, // 改变选择分类 onChangeCascader(e) { // title1: e.detail.options.map((n) => n.label).join('/') // console.log('onChangeCascader', e.detail) const waitResponseData = Object.assign(this.data.waitResponseData, { categoryId: e.detail.options[e.detail.options.length - 1].value, // 分类ID String categoryName: e.detail.options[e.detail.options.length - 1].label, // 分类名称 }) this.setData({ waitResponseData }) } } })