MCPcopy Create free account
hub / github.com/Semporia/Scripts / doTask

Function doTask

jd_mcxhd.js:106–138  ·  view source on GitHub ↗
(itemToken,taskToken=null)

Source from the content-addressed store, hash-verified

104}
105
106function doTask(itemToken,taskToken=null) {
107 let body = {"itemToken":itemToken}
108 return new Promise(resolve => {
109 $.get(taskUrl('doTask', body), async (err, resp, data) => {
110 try {
111 if (err) {
112 console.log(`${JSON.stringify(err)}`)
113 console.log(`${$.name} API请求失败,请检查网路重试`)
114 } else {
115 if (safeGet(data)) {
116 data = JSON.parse(data);
117
118 if (data.retCode === '200') {
119 console.log(`任务完成成功`)
120 if(taskToken) {
121 await queryTask(taskToken)
122 await $.wait(5*1000)
123 await viewTask(taskToken)
124 await checkTask(itemToken)
125 }
126 } else {
127 console.log(`任务完成失败,${data.retMessage}`)
128 }
129 }
130 }
131 } catch (e) {
132 $.logErr(e, resp)
133 } finally {
134 resolve();
135 }
136 })
137 })
138}
139function queryTask(taskToken){
140 return new Promise(resolve => {
141 $.get({

Callers 2

jd_mcxhd.jsFile · 0.70
taskListFunction · 0.70

Calls 9

checkTaskFunction · 0.85
taskUrlFunction · 0.70
safeGetFunction · 0.70
queryTaskFunction · 0.70
viewTaskFunction · 0.70
getMethod · 0.45
logMethod · 0.45
waitMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected