api请求过程中,有一个值无法传递成功?
Page({ data: { text: '', style: '', resolution:'', num:0, taskId:'' }, onInput1: function (e) { this.setData({ text: e.detail.value.trim() }) }, onInput2: function (e) { this.setData({ style: e.detail.value.trim() }) }, onInput3: function (e) { this.setData({ resolution: e.detail.value.trim() }) }, onInput4: function (e) { this.setData({ num: parseInt(e.detail.value.trim())||0 }) }, submitData: function () { var text = this.data.text; var style = this.data.style; var resolution = this.data.resolution; var num = this.data.num; wx.request({ method: 'POST', data: { text: text, style: style, resolution:resolution, num:num }, header:{ "Content-Type":"application/json" }, success: function(res) { if (res.data.error_code !== undefined) { console.log(res.data.error_msg); } else { wx.setStorageSync('taskId', res.data.taskId); //存储taskId到本地 getResult(res.data.taskId); //调用getResult函数并传递参数 } }, fail: (res) => { console.log('请求失败'); } }) }, getResult: function (taskId) { wx.request({ method: 'POST', data: { taskId: taskId //将参数作为taskId传递 }, header:{ "Content-Type":"application/json" }, success: (res) => { if (res.data.error_code !== undefined) { console.log(res.data.error_msg); } else if (res.data.result.status === 2) { //结果已生成,显示图片 console.log(res.data.result.image); } else { //继续查询结果 getResult(taskId); } }, fail: (res) => { console.log('请求失败'); } }) }, onClear: function () { this.setData({ text: '', style: '', resolution: '', num: 0 }) } })