(token)
| 127 | } |
| 128 | |
| 129 | function share(token) { |
| 130 | if (!token) { |
| 131 | return Promise.resolve({}) |
| 132 | } |
| 133 | return new Promise((resolve, reject) => { |
| 134 | let action = 'happy.energy.dailyShare' |
| 135 | let options = { |
| 136 | url: API_URL, |
| 137 | headers: { 'User-Agent': UA }, |
| 138 | body: JSON.stringify({ |
| 139 | token, |
| 140 | action, |
| 141 | ticket: '', |
| 142 | }), |
| 143 | } |
| 144 | HELLO_BIKE.post(options, (error, response, data) => { |
| 145 | if (error) { |
| 146 | HELLO_BIKE.log(TASK_NAME, `分享失败,error:${error}`) |
| 147 | reject(new RequestFailed(action, error)) |
| 148 | return |
| 149 | } |
| 150 | let result = JSON.parse(data) |
| 151 | if (result && result.code === 0) { |
| 152 | resolve(result) |
| 153 | } else { |
| 154 | HELLO_BIKE.log(TASK_NAME, `分享失败,response:${data}`) |
| 155 | reject(new RequestFailed(action, result.msg, result.code === 103)) |
| 156 | } |
| 157 | }) |
| 158 | }) |
| 159 | } |
| 160 | |
| 161 | function getEnergyList(token) { |
| 162 | if (!token) { |
no test coverage detected