| | |
| | | /** |
| | | * |
| | | * 信息输入逻辑 |
| | | * 包括输入信息存储、输入规范性检测、错误提示等 |
| | | * @see "/data/sceneInfo.js" |
| | | */ |
| | | module.exports = Behavior({ |
| | | data: { |
| | |
| | | attached: function () {} |
| | | }, |
| | | methods: { |
| | | selectChange(e) { |
| | | const index = e.currentTarget.dataset.index |
| | | const options = e.detail.options |
| | | this.setData({ |
| | | [`msg[${index}].options`]: options |
| | | }) |
| | | }, |
| | | |
| | | pickerChange(e) { |
| | | console.log(e); |
| | | const { |
| | | index, |
| | | mode |
| | | } = e.currentTarget.dataset |
| | | let i = e.detail.value.concat(e.detail.code) |
| | | if (mode == 'region') { |
| | | this.setData({ |
| | | [`msg[${index}].value`]: i |
| | | }) |
| | | } else if (mode == 'selector') { |
| | | this.setData({ |
| | | [`msg[${index}].selectIndex`]: i, |
| | | [`msg[${index}].value`]: this.data.msg[index].options[i].value |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | changeMsg(e) { |
| | | let id = e.detail.params.id |
| | | let value = e.detail.params.value |
| | |
| | | [nPath]: false |
| | | }) |
| | | } |
| | | } |
| | | }, |
| | | |
| | | onSubmit: function () { |
| | | console.log('onSubmit'); |
| | | if (!this.submitCheck()) return |
| | | |
| | | let msg = this.data.msg |
| | | if (msg) { |
| | | let info = {} |
| | | msg.forEach(m => { |
| | | info[m.id] = m.value |
| | | }); |
| | | // console.log(info); |
| | | this.setData({info}) |
| | | this.triggerEvent('onSubmit', info) |
| | | // wx.showToast({ |
| | | // title: 'onSubmit', |
| | | // duration: 1000, |
| | | // icon: 'none', |
| | | // success: (res) => {}, |
| | | // fail: (res) => {}, |
| | | // complete: (res) => {}, |
| | | // }) |
| | | } |
| | | }, |
| | | |
| | |
| | | } |
| | | } |
| | | //输入框 |
| | | else if (m.value === "") { |
| | | else if (m.value === "" || m.value === null || m.value === undefined) { |
| | | this.showErrorMsg(i) |
| | | return false |
| | | } |
| | |
| | | }) |
| | | }).exec(); |
| | | }).exec(); |
| | | }, |
| | | |
| | | onSubmit: function () { |
| | | console.log('onSubmit'); |
| | | if (!this.submitCheck()) return |
| | | |
| | | let msg = this.data.msg |
| | | if (msg) { |
| | | let info = {} |
| | | msg.forEach(m => { |
| | | info[m.id] = m.value |
| | | }); |
| | | this.setData({info}) |
| | | this.triggerEvent('onSubmit', info) |
| | | this.submit() |
| | | } |
| | | }, |
| | | } |
| | | }) |