Skip to content

Commit fe8cc19

Browse files
fix:拍照签到流程优化。关于图片不显示bug:经反复测试,发现是图片格式问题,只有png和jpg能够成功,heif高压缩的图片语法显示的。现在已经在上传过程中有所提示
1 parent c0036ea commit fe8cc19

File tree

4 files changed

+171
-26
lines changed

4 files changed

+171
-26
lines changed

README.MD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464

6565

6666

67+
## 逆向
68+
69+
1. [模拟超星网课 Android 客户端 · HonKit (hiczp.com)](https://www.hiczp.com/wang-luo/mo-ni-chao-xing-wang-ke-android-ke-hu-duan.html)
70+
71+
72+
6773
## 其他项目推荐
6874

6975
| 项目地址 | 开发语言 | 备注 |

biz/course.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,21 @@ async function chaoxingPanUpload(context, activity, filePath) {
251251
let _token = tokenResponse.data._token
252252
let uploadResponse = await CourseApi.chaoxingPanUpload(filePath,
253253
getLoginParams()['_uid'], _token)
254+
console.log(`uploadResponse`, uploadResponse)
255+
254256
if (uploadResponse.data.msg === 'success') {
255-
return {
257+
let obj = {
256258
objectId: uploadResponse.data.data.objectId,
257259
previewUrl: uploadResponse.data.data.previewUrl,
258260
}
261+
console.log(`uploadResponse.data.msg === 'success')`, obj)
262+
return obj
259263
}
260264
// uni.showToast({
261265
// title:'上传失败',
262266
// icon:'error'
263267
// })
268+
console.error(`function chaoxingPanUpload`, '上传失败', uploadResponse.data?.msg)
264269
return uploadResponse.data?.msg || '上传失败'
265270
}
266271

manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"name" : "学习通手动挡签到",
33
"appid" : "__UNI__C397F39",
44
"description" : "",
5-
"versionName" : "1.2.3",
6-
"versionCode" : 123,
5+
"versionName" : "1.2.5",
6+
"versionCode" : 125,
77
"transformPx" : false,
88
/* 5+App特有相关 */
99
"app-plus" : {

pages/activity/nvue-swiper-page.nvue

Lines changed: 157 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
if (newVal == this.myIndex) {
9696
this.isShow = true
9797
if (!this.initDone) {
98-
this.$nextTick(function(){
98+
this.$nextTick(function() {
9999
this.$refs.paging.reload(true)
100100
this.initDone = true
101101
})
@@ -257,41 +257,175 @@
257257
console.log('allInOneSign.type', type)
258258
let result = null,
259259
isShowToast = true;
260-
uni.showLoading({
261-
title: '签到中',
262-
mask: true,
263-
})
264260
switch (type) {
265261
case Constant.signType.generalSign:
262+
uni.showLoading({
263+
title: '签到中',
264+
mask: true,
265+
})
266266
result = await CourseBiz.generalSign(this, activity)
267267
break;
268268
case Constant.signType.photoSign:
269-
let uploadData = await CourseBiz.chaoxingPanUpload(this, activity, params.filePath)
270-
if (uploadData) {
271-
// isShowToast = false
272-
result = await CourseBiz.photoSign(
273-
this,
274-
this.checkedActivity,
275-
uploadData.objectId
276-
)
277-
// uni.hideLoading()
278-
// if (responseData !== true) {
279-
// plus.nativeUI.toast(responseData)
280-
// return null;
281-
// }
282-
// // plus.nativeUI.toast('签到成功')
269+
isShowToast = false
270+
/**
271+
* @description 确认选择该图片进行签到
272+
*/
273+
const chooseImageHandler = async (res, uploadData) => {
274+
console.log(`chooseImageHandler`, res, uploadData)
275+
uni.closePreviewImage()
276+
if (Number(res.tapIndex) !== 0) {
277+
uni.showToast({
278+
title: '取消签到',
279+
icon: 'error',
280+
})
281+
return null;
282+
}
283+
uni.showLoading({
284+
title: '签到中',
285+
mask: true,
286+
})
287+
288+
let responseData = await CourseBiz.photoSign(this,
289+
this.checkedActivity, uploadData.objectId)
290+
uni.hideLoading()
291+
if (responseData !== true) {
292+
// 这里出问题了
293+
uni.showToast({
294+
title: responseData,
295+
position: 'center'
296+
})
297+
return null;
298+
}
299+
uni.showToast({
300+
title: '签到成功',
301+
icon: 'success'
302+
})
303+
304+
}
305+
306+
/**
307+
* @description 获取图片信息成功,提示是否选择该图片
308+
*/
309+
const previewHandler = (image, uploadData) => {
310+
uni.hideLoading()
311+
uni.showModal({
312+
title: '提示',
313+
content: '上传图片成功,请长按',
314+
success: () => {
315+
uni.previewImage({
316+
current: 0,
317+
urls: [image.path],
318+
longPressActions: {
319+
itemList: ['选择该图片签到', '取消签到'],
320+
success: (res) => chooseImageHandler(res,
321+
uploadData),
322+
},
323+
})
324+
}
325+
})
326+
}
327+
328+
/**
329+
* @description 压缩图片成功回调
330+
*/
331+
const compressImageSuccessHandler = async ({
332+
tempFilePath
333+
}) => {
334+
console.log(`compressImageSuccessHandler `, tempFilePath)
283335
// uni.showToast({
284-
// title:'签到成功',
285-
// icon:'success'
336+
// title: '压缩图片成功',
337+
// position: 'center'
286338
// })
287-
} else
288-
result = uploadData
339+
let uploadData = await CourseBiz.chaoxingPanUpload(this, activity, tempFilePath)
340+
console.log(`uploadData`, uploadData)
341+
if (uploadData?.objectId === undefined) {
342+
uni.hideLoading()
343+
console.error(`uploadData?.objectId === undefined`, `上传失败`)
344+
uni.showToast({
345+
title: '上传失败',
346+
icon: 'error'
347+
})
348+
throw new Error('上传图片失败')
349+
}
350+
console.log(`uploadData.previewUrl`, uploadData.previewUrl)
351+
uni.getImageInfo({
352+
src: uploadData.previewUrl,
353+
success: (res) => previewHandler(res, uploadData),
354+
fail() {
355+
uni.hideLoading()
356+
plus.nativeUI.confirm(
357+
`请确认图片的格式是不是jpg或者png\n下面是图片地址:\n${uploadData.previewUrl}\n可以复制到浏览器打开看下是什么情况`,
358+
(e) => {
359+
if (e.index === 0)
360+
uni.setClipboardData({
361+
data: uploadData.previewUrl
362+
})
363+
else if (e.index === 1)
364+
uni.showToast({
365+
title: '取消签到',
366+
icon: 'error'
367+
})
368+
}, {
369+
title: '上传成功但获取预览图失败',
370+
buttons: ['复制链接', '知道了']
371+
})
372+
}
373+
})
374+
}
375+
376+
uni.showLoading({
377+
title: '压缩并上传中',
378+
mask: true,
379+
})
380+
381+
/**
382+
* @description 先压缩图片,避免超时
383+
*/
384+
uni.compressImage({
385+
src: params.filePath,
386+
success: compressImageSuccessHandler,
387+
fail: () => {
388+
uni.hideLoading()
389+
uni.showToast({
390+
title: '压缩图片失败',
391+
icon: 'error'
392+
})
393+
}
394+
})
395+
// let uploadData = await CourseBiz.chaoxingPanUpload(this, activity, params.filePath)
396+
// if (uploadData) {
397+
// // isShowToast = false
398+
// result = await CourseBiz.photoSign(
399+
// this,
400+
// this.checkedActivity,
401+
// uploadData.objectId
402+
// )
403+
// // uni.hideLoading()
404+
// // if (responseData !== true) {
405+
// // plus.nativeUI.toast(responseData)
406+
// // return null;
407+
// // }
408+
// // // plus.nativeUI.toast('签到成功')
409+
// // uni.showToast({
410+
// // title:'签到成功',
411+
// // icon:'success'
412+
// // })
413+
// } else
414+
// result = uploadData
289415
break;
290416
case Constant.signType.QRCodeSign:
417+
uni.showLoading({
418+
title: '签到中',
419+
mask: true,
420+
})
291421
console.log('allInOneSign.params', params)
292422
result = await CourseBiz.QRCodeSign(this, activity, params.enc)
293423
break;
294424
case Constant.signType.locationSign:
425+
uni.showLoading({
426+
title: '签到中',
427+
mask: true,
428+
})
295429
console.log('Constant.signType.locationSign', Constant.signType.locationSign)
296430
result = await CourseBiz.locationSign(this, activity, {
297431
address: params.address,

0 commit comments

Comments
 (0)