diff --git a/messenger.js b/messenger.js index df094ca..0eecc3a 100644 --- a/messenger.js +++ b/messenger.js @@ -20,10 +20,10 @@ module.exports = { .then((result) => { if (result.messageId && result.response === '250 Ok') { console.log(result) - return { _state: 'SMS_SENT_SUCCESS' } + return { _state: 'MSG_SENT_SUCCESS' } } console.log(result) - return { _state: 'SMS_SEND_FAIL' } + return { _state: 'MSG_SEND_FAIL' } }) .catch((err) => { console.log(err) @@ -84,9 +84,9 @@ module.exports = { }) resp.on('end', () => { if (parseInt(returnCode) === 100) { - resolve({ _state: 'SMS_SENT_SUCCESS' }) // 100: 发送成功 (表示已和我们接口连通) + resolve({ _state: 'MSG_SENT_SUCCESS' }) // 100: 发送成功 (表示已和我们接口连通) } else { - resolve({ _state: 'SMS_SEND_FAIL', error: { returnCode } }) // 短信接口错误代码:http://www.dxton.com/help_detail/2.html + resolve({ _state: 'MSG_SEND_FAIL', error: { returnCode } }) // 短信接口错误代码:http://www.dxton.com/help_detail/2.html } }) }) @@ -113,9 +113,9 @@ module.exports = { function (result) { let { Code } = result if (Code === 'OK') { - return { _state: 'SMS_SENT_SUCCESS' } + return { _state: 'MSG_SENT_SUCCESS' } } else { - return { _state: 'SMS_SEND_FAIL', error: result } + return { _state: 'MSG_SEND_FAIL', error: result } } }, function (error) { @@ -135,11 +135,11 @@ module.exports = { data: msgParam, // 模版中的变量的值,例如 { passcode: '234345', purpose: '注册' } }) - return { _state: 'SMS_SENT_SUCCESS', result } // 调用成功,请注意这时不代表发送成功。// { code:0, errCode:0, success:true } 错误码参见 https://uniapp.dcloud.net.cn/uniCloud/send-sms.html + return { _state: 'MSG_SENT_SUCCESS', result } // 调用成功,请注意这时不代表发送成功。// { code:0, errCode:0, success:true } 错误码参见 https://uniapp.dcloud.net.cn/uniCloud/send-sms.html } catch (error) { // 调用失败 例如 {"code":undefined,"msg":"短信发送失败:账户余额不足"} return { - _state: 'SMS_SEND_FAIL', + _state: 'MSG_SEND_FAIL', error, // { errCode, errMsg } } } @@ -161,9 +161,9 @@ module.exports = { function ({ SendStatusSet, RequestId } = {}) { let { SerialNo, PhoneNumber, Fee, Code, Message, IsoCode } = SendStatusSet[0] if (Code === 'Ok') { - return { _state: 'SMS_SENT_SUCCESS' } + return { _state: 'MSG_SENT_SUCCESS' } } else { - return { _state: 'SMS_SEND_FAIL', error: { SendStatusSet, RequestId } } + return { _state: 'MSG_SEND_FAIL', error: { SendStatusSet, RequestId } } } }, function (error) {