parent
0d30235861
commit
84379210be
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,151 @@ |
||||
<template> |
||||
<view class="sourseSignIn"> |
||||
<view class="scanSuc" v-if="scanResult"> |
||||
<view class="className"> |
||||
{{ className }} |
||||
</view> |
||||
<view class="courseName"> |
||||
{{ courseName }} |
||||
</view> |
||||
<view class="signBtn" @click="signIn" v-if="!isSignin"> |
||||
<view>签到</view> |
||||
<view>{{ nowTime }}</view> |
||||
</view> |
||||
<view class="signBtn" v-else> |
||||
<img src="./signSuc.png" alt="" /> |
||||
<view>已签到</view> |
||||
</view> |
||||
</view> |
||||
<view class="scanFail" v-else> |
||||
<img src="./error.png" alt="" /> |
||||
<view>无法识别二维码</view> |
||||
</view> |
||||
</view> |
||||
</template> |
||||
|
||||
<script> |
||||
import { decodeChinse } from '@/utils/encodeChinese.js' |
||||
export default { |
||||
data() { |
||||
return { |
||||
courseId: '', |
||||
className: '', |
||||
courseName: '', |
||||
scanResult: true, |
||||
isSignin: false, |
||||
} |
||||
}, |
||||
onLoad(options) { |
||||
try { |
||||
const obj = JSON.parse(JSON.parse(options.objStr)) |
||||
console.log(obj) |
||||
this.courseId = obj.courseId |
||||
console.log(this.courseId) |
||||
this.className = decodeChinse(obj.className) |
||||
this.courseName = decodeChinse(obj.courseName) |
||||
uni.setNavigationBarTitle({ title: this.courseName }) |
||||
this.init() |
||||
} catch (e) { |
||||
this.scanResult = false |
||||
} |
||||
}, |
||||
computed: { |
||||
nowTime() { |
||||
const currentDate = new Date() |
||||
let hours = currentDate.getHours() |
||||
if (hours < 10) hours = '0' + hours |
||||
let minutes = currentDate.getMinutes() |
||||
if (minutes < 10) minutes = '0' + minutes |
||||
let second = currentDate.getSeconds() |
||||
if (second < 10) second = '0' + second |
||||
const formattedDate = `${hours}:${minutes}:${second}` |
||||
return formattedDate |
||||
}, |
||||
}, |
||||
methods: { |
||||
signIn() { |
||||
const data = { |
||||
courseId: this.courseId, |
||||
} |
||||
console.log(data) |
||||
this.http.quickPost(`/course/singin`, data, true).then((response) => { |
||||
console.log(response) |
||||
if (response.data.code == 500) { |
||||
uni.showToast({ title: response.data.msg, icon: 'none', duration: 1000 }) |
||||
} else if (response.data.code == 200) { |
||||
this.isSignin = true |
||||
} |
||||
}) |
||||
}, |
||||
init() { |
||||
|
||||
this.http.quickGet(`/course/singin/${this.courseId}`,true).then((response) => { |
||||
console.log(response); |
||||
if(response.data.msg == '已签到'){ |
||||
this.isSignin = true |
||||
} |
||||
}) |
||||
}, |
||||
}, |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss"> |
||||
.sourseSignIn { |
||||
height: 100%; |
||||
overflow: hidden; |
||||
|
||||
background: linear-gradient(0deg, #d1e9fe, #ffffff); |
||||
|
||||
.scanSuc { |
||||
font-family: PingFang SC; |
||||
.className { |
||||
font-weight: bold; |
||||
font-size: 30rpx; |
||||
color: #000000; |
||||
line-height: 46rpx; |
||||
margin: 30rpx; |
||||
} |
||||
.courseName { |
||||
font-weight: 500; |
||||
font-size: 30rpx; |
||||
color: #4d4d4d; |
||||
line-height: 46rpx; |
||||
margin-left: 30rpx; |
||||
} |
||||
.signBtn { |
||||
margin: 0 auto; |
||||
margin-top: 300rpx; |
||||
background-color: #4899f7; |
||||
color: #fff; |
||||
border-radius: 50%; |
||||
width: 250rpx; |
||||
height: 250rpx; |
||||
text-align: center; |
||||
display: flex; |
||||
// font-weight: bold; |
||||
flex-direction: column; |
||||
align-items: center; |
||||
justify-content: center; |
||||
img { |
||||
width: 50rpx; |
||||
height: 50rpx; |
||||
margin-bottom: 5rpx; |
||||
} |
||||
} |
||||
} |
||||
.scanFail { |
||||
margin: 0 auto; |
||||
margin-top: 500rpx; |
||||
height: 200rpx; |
||||
text-align: center; |
||||
font-weight: bold; |
||||
font-size: 30rpx; |
||||
img { |
||||
width: 50rpx; |
||||
height: 50rpx; |
||||
margin-bottom: 5rpx; |
||||
} |
||||
} |
||||
} |
||||
</style> |
After Width: | Height: | Size: 7.7 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,115 @@ |
||||
<template> |
||||
<view class="courseWrapper"> |
||||
<view v-if="courseList.length"> |
||||
<view class="courseItem" v-for="course in courseList" :key="course.courseId"> |
||||
<view class="courseName">{{ course.courseName }}</view> |
||||
<view class="courseTime">{{ course.courseTime }}</view> |
||||
<view class="courseSource" @click="courseDialog">课程资料</view> |
||||
<view class="signInfo" :style="{ background: course.status ? '#28D17C' : '#FBA02A' }">{{ |
||||
course.status ? '已签到' : '未签到' |
||||
}}</view> |
||||
</view> |
||||
</view> |
||||
<view class="mycourseWrapper" v-else> 暂未配置课程 </view> |
||||
</view> |
||||
</template> |
||||
|
||||
<script> |
||||
export default { |
||||
data() { |
||||
return { |
||||
courseList: [], |
||||
} |
||||
}, |
||||
onLoad(options) { |
||||
console.log('进入course') |
||||
const classId = options.id |
||||
const className = options.name |
||||
console.log(options) |
||||
uni.setNavigationBarTitle({ title: className }) |
||||
this.getCourseList(classId) |
||||
}, |
||||
methods: { |
||||
async getCourseList(classId) { |
||||
this.http.quickGet(`/course/myCourse/class/${classId}`, true).then((res) => { |
||||
console.log(res) |
||||
this.courseList = res.data.rows |
||||
}) |
||||
}, |
||||
courseDialog() { |
||||
const url = 'https://www.bjkeyware.com' |
||||
uni.showModal({ |
||||
title: '请去PC端下载资料', |
||||
content: 'PC端网址:'+url, |
||||
showCancel: false, |
||||
confirmText: '复制网址', |
||||
success: function (res) { |
||||
if (res.confirm) { |
||||
uni.setClipboardData({ |
||||
data: url, |
||||
success: function () { |
||||
uni.showToast({ |
||||
title: '复制成功', |
||||
}) |
||||
}, |
||||
fail: function () { |
||||
uni.showToast({ |
||||
title: '复制失败', |
||||
}) |
||||
}, |
||||
}) |
||||
console.log('用户点击确定') |
||||
} |
||||
}, |
||||
}) |
||||
}, |
||||
}, |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
.courseWrapper { |
||||
} |
||||
.mycourseWrapper { |
||||
text-align: center; |
||||
line-height: 300rpx; |
||||
} |
||||
.courseItem { |
||||
position: relative; |
||||
margin: 25rpx; |
||||
width: 700rpx; |
||||
height: 210rpx; |
||||
margin-bottom: 0; |
||||
padding: 30rpx; |
||||
background: #ffffff; |
||||
border-radius: 10rpx; |
||||
font-family: PingFang SC; |
||||
font-weight: 500; |
||||
font-size: 24rpx; |
||||
line-height: 50rpx; |
||||
} |
||||
.courseName { |
||||
/* width: 369rpx; */ |
||||
/* height: 29rpx; */ |
||||
font-weight: bold; |
||||
font-size: 30rpx; |
||||
color: #000000; |
||||
} |
||||
.courseTime { |
||||
color: #4d4d4d; |
||||
} |
||||
.courseSource { |
||||
color: #2853e4; |
||||
} |
||||
.signInfo { |
||||
width: 110rpx; |
||||
/* height: 40rpx; */ |
||||
line-height: 40rpx; |
||||
border-radius: 20rpx; |
||||
text-align: center; |
||||
color: #fff; |
||||
position: absolute; |
||||
top: 85rpx; |
||||
right: 25rpx; |
||||
} |
||||
</style> |
@ -0,0 +1,16 @@ |
||||
function encodeChinese(str){ |
||||
if(!str){ |
||||
return '' |
||||
} |
||||
return encodeURIComponent(str) |
||||
} |
||||
|
||||
function decodeChinse(str){ |
||||
if(str){ |
||||
return decodeURIComponent(str) |
||||
} |
||||
} |
||||
|
||||
export { |
||||
encodeChinese,decodeChinse |
||||
} |
Loading…
Reference in new issue