Skip to content

Commit 8e810c0

Browse files
committed
feat: -
1 parent 8bbbcb2 commit 8e810c0

File tree

4 files changed

+35
-17
lines changed

4 files changed

+35
-17
lines changed

internal/app/handler/problem.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,13 @@ func GetProblemByID(c *gin.Context) {
197197
func FinishProblem(c *gin.Context) {
198198
userId, err := util.GetUserIdFromContext(c)
199199
if err != nil {
200-
util.ResponseError(c, 500, err.Error())
201-
return
200+
id, err := strconv.Atoi(c.Query("userid"))
201+
if err == nil && id > 0 {
202+
userId = uint(id)
203+
} else {
204+
util.ResponseError(c, 500, err.Error())
205+
return
206+
}
202207
}
203208

204209
problemId, err := strconv.Atoi(c.Query("problem_id"))

wx/pages/problem/problem.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
// pages/problem.js
22
const app = getApp()
3+
const util = require('../../utils/util.js')
34

45
Page({
56
data: {
6-
userid: app.globalData.userid,
7+
userid: 0,
78
idx: 0,
89
markmode: 0, // choose markdown plugin: 0.wemark; 1.towxml
910
article: {},
@@ -19,13 +20,16 @@ Page({
1920
if (this.data.markmode != 0) {
2021
content = app.towxml(content, 'markdown', {})
2122
}
22-
this.setData({
23-
article: content
24-
})
23+
this.setData({article: content})
24+
this.setData({userid: app.globalData.userid})
2525
},
2626
finishProblem() {
27-
this.setData({
28-
finished: !this.data.finished
27+
let p = app.globalData.problems[this.data.idx]
28+
let url = '/api/user/problem/finish?problem_id=' + p.ID + '&userid=' + app.globalData.userid
29+
util.request(wx, url, 'GET', {}, function (result) {
30+
this.setData({
31+
finished: true
32+
})
2933
})
3034
},
3135
preProblem() {

wx/pages/problem/problem.wxss

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,32 @@
66
}
77

88
.bottom{
9-
margin: 20rpx;
9+
margin: 30rpx 10rpx;
1010
height: 80rpx;
11+
font-weight: 100;
1112
display: flex;
1213
flex-direction: row;
1314
}
1415

15-
.pre-text{
16+
.pre-btn{
1617
width: 33%;
18+
color: rgb(60, 60, 60);
1719
}
1820

19-
.next-text{
21+
.next-btn{
2022
width: 33%;
23+
color: rgb(60, 60, 60);
2124
}
2225

2326
.finish-btn{
2427
width: 33%;
25-
background-color: rgb(241, 118, 93);
28+
color: rgb(60, 60, 60);
29+
background-color: rgb(223, 104, 80);
30+
vertical-align: middle;
2631
text-align: center;
2732
}
2833

2934
.finish-btn[disabled] {
30-
background: #414d5c;
31-
border-color: #78899c;
35+
background: #4e5358;
36+
border-color: #484b4e;
3237
}

wx/utils/util.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// const host = 'https://sslapi.chaosi-zju.com'
2-
const host = 'http://127.0.0.1:5001'
1+
const host = 'https://sslapi.chaosi-zju.com'
2+
// const host = 'http://127.0.0.1:5001'
33

44
const request = function (wx, path, method, data, func, noloading) {
55
if (noloading == null || !noloading) {
@@ -21,7 +21,11 @@ const request = function (wx, path, method, data, func, noloading) {
2121
var result = res.data.data;
2222
func(result);
2323
} else {
24-
toast(wx, '服务器有问题,数据返回有误', 500)
24+
if(res.data.message !== '') {
25+
toast(wx, res.data.message, 800)
26+
}else{
27+
toast(wx, '服务器有问题,数据返回有误', 800)
28+
}
2529
}
2630
},
2731
fail: function () {

0 commit comments

Comments
 (0)