Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in / Register
Toggle navigation
X
xinya_mini
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xwq
xinya_mini
Commits
8241fe61
Commit
8241fe61
authored
Apr 26, 2021
by
xwq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口
parent
8ff0b38d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
17 deletions
+38
-17
displayAnswers.js
pages/displayAnswers/displayAnswers.js
+31
-17
index.js
utils/index.js
+7
-0
No files found.
pages/displayAnswers/displayAnswers.js
View file @
8241fe61
// import { from } from "form-data";
// pages/displayAnswers/displayAnswers.js
import
UploadFileManager
from
"
../../jade/UploadFileManager
"
;
import
{
hosts
}
from
"
../../utils/index
"
Page
({
/**
...
...
@@ -34,7 +37,7 @@ Page({
},
fail
:
(
e
)
=>
reject
(
e
),
});
});
})
.
catch
(()
=>
{})
;
},
detectAnswer
:
(
tempPath
)
=>
{
// tempPath -> url
...
...
@@ -63,7 +66,7 @@ Page({
(
params
)
=>
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
request
({
url
:
`
https://test.xinya.me
/api/arithmetic_ocr`
,
url
:
`
${
hosts
}
/api/arithmetic_ocr`
,
method
:
"
POST
"
,
data
:
params
,
success
:
(
res
)
=>
{
...
...
@@ -73,13 +76,15 @@ Page({
reject
(
e
);
},
});
}).
catch
(()
=>
{
})
)
.
then
(
(
res
)
=>
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
"
]]]]]]]
"
,
res
)
//
console.log("]]]]]]]",res)
wx
.
request
({
url
:
"
https://ocr.tencentcloudapi.com
"
,
method
:
"
POST
"
,
...
...
@@ -96,7 +101,7 @@ Page({
}
else
{
resolve
({
...
ocrRes
.
data
,
exercise_ocr_record_id
:
res
.
exercise_
ocr_record_id
,
ocr_record_id
:
res
.
ocr_record_id
,
});
}
},
...
...
@@ -104,7 +109,7 @@ Page({
reject
(
e
);
},
});
})
})
.
catch
(()
=>
{})
);
},
/**
...
...
@@ -116,12 +121,12 @@ Page({
});
},
confirm
:
function
(
e
)
{
const
ret
=
JSON
.
parse
(
wx
.
getStorageSync
(
"
result
"
));
ret
.
errors
=
this
.
data
.
errors
!=
null
?
this
.
data
.
errors
:
0
;
ret
.
errorItems
=
ret
.
errors
;
const
r
=
Object
.
keys
(
ret
).
reduce
((
acc
,
key
)
=>
{
return
acc
+
key
+
"
=
"
+
ret
[
key
]
+
"
&
"
;
},
""
);
//
const ret = JSON.parse(wx.getStorageSync("result"));
//
ret.errors = this.data.errors != null ? this.data.errors : 0;
//
ret.errorItems = ret.errors;
//
const r = Object.keys(ret).reduce((acc, key) => {
//
return acc + key + "=" + ret[key] + "&";
//
}, "");
// const opts = {
// ctitle: options.ctitle,
// answerSrc: options.answerSrc,
...
...
@@ -139,12 +144,13 @@ Page({
});
},
onLoad
:
function
(
options
)
{
// console.log(options.photo);
const
context
=
wx
.
createCanvasContext
(
"
photo_answer
"
);
let
radio
;
wx
.
showLoading
({
title
:
"
结果加载中
"
,
});
console
.
log
(
options
.
photo
,
"
=====
"
,
hosts
);
const
context
=
wx
.
createCanvasContext
(
"
photo_answer
"
);
let
radio
;
this
.
getImageInfopromised
(
options
.
photo
)
.
then
((
resPhoto
)
=>
{
// draw用户拍摄的图片
...
...
@@ -171,6 +177,7 @@ Page({
this
.
setData
({
corrects
,
errors
:
ret
.
Response
.
TextDetections
.
length
-
corrects
,
imgResults
:
ret
.
Response
});
// console.warn("Res sys", radio);
ret
.
Response
.
TextDetections
.
forEach
((
t
,
index
)
=>
{
...
...
@@ -206,9 +213,13 @@ Page({
(
ret
)
=>
new
Promise
((
resolve
,
reject
)
=>
setTimeout
(()
=>
{
wx
.
showLoading
({
title
:
"
结果加载中
"
,
});
wx
.
hideLoading
();
wx
.
canvasToTempFilePath
({
canvasId
:
context
.
canvasId
,
fileType
:
"
jpg
"
,
success
:
(
pic
)
=>
{
const
tempFilePath
=
pic
.
tempFilePath
;
console
.
log
(
tempFilePath
);
...
...
@@ -223,8 +234,8 @@ Page({
)
.
then
((
res
)
=>
{
resolve
({
exercise_
ocr_result
:
{
Response
:
ret
.
Response
},
exercise_ocr_record_id
:
ret
.
exercise_
ocr_record_id
,
ocr_result
:
{
Response
:
ret
.
Response
},
ocr_record_id
:
ret
.
ocr_record_id
,
ocr_photo_id
:
JSON
.
parse
(
res
.
data
).
id
,
});
})
...
...
@@ -243,7 +254,7 @@ Page({
(
res
)
=>
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
request
({
url
:
"
https://xinya.me/api/arithmetic_ocr_result
"
,
url
:
`
${
hosts
}
/api/arithmetic_ocr_result`
,
method
:
"
POST
"
,
data
:
res
,
success
:
(
res
)
=>
{
...
...
@@ -257,6 +268,9 @@ Page({
)
.
catch
((
e
)
=>
{
console
.
error
(
e
);
wx
.
showLoading
({
title
:
"
结果加载中
"
,
});
wx
.
hideLoading
();
wx
.
showToast
({
title
:
"
检查答案出错,请重新拍照检查
"
,
...
...
utils/index.js
View file @
8241fe61
...
...
@@ -139,8 +139,15 @@ const convertURLToJSON = function (url, params = {}) {
// wx.miniProgram.navigateTo({ url: url })
// })
// }
// }
const
hosts
=
"
https://test.xinya.me
"
// const hosts="https://xinya.me"
// const request=function(url){
// }
module
.
exports
=
{
hosts
,
getUrl
,
getCurrentPage
,
Jade
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment