diff --git a/.gitignore b/.gitignore index 001d9f8..a5b0a74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ api_docs/ .idea/ res/ +docs/ +pandocs + # Windows [Dd]esktop.ini diff --git a/README.md b/README.md index 1cc3d02..e4cc0f9 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,6 @@ # 简介 educoder微信小程序,帮助使用[educoder平台](https://www.educoder.net)的应用,方便在手机上使用。 -## 源码 ## 小程序码 ![小程序码](/images/weacode.jpg) - -# 功能介绍 - -## 教室 -- 学员可以输入邀请码进入课堂 - -- 进入教室界面会显示在位,头像为彩色,若退出课堂界面则会显示灰色头像 - -- 教员在教室界面中可以直观地看到学员在位情况,可以选择学员让其起立回答问题,并且对学员可以进行加分、减分操作 - -- 在分数列表中可以看到加减分记录(数据在后台可以导出) - -- 学员可以收到教员让其起立提问、回答的提示,还可以点击“我要提问、回答” - -- 教室内有讨论区,可以交流 - -## 课程资源 - -- 在课程界面进入“资源”可以查看本课堂的课程文件资源 - -- 支持打开ppt doc xls pdf文件 - -## 试卷作答 - -- 学员在课程内可以看到老师发布的试卷,并且回答 - -- 试卷截止后并且老师选择了公开答案,学生可以看到公布的答案 - -- 老师可以创建试卷,发布试卷,查看学员作答分数 - -## 其他 -账号的注册、登陆、找回密码、头像更改等 diff --git a/changelog.txt b/changelog.txt index 3aba882..cc915bc 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,21 @@ +##v0.14.2 + * F 更改头像界面图片初次加载失败 + * F 电脑端用户界面图标及文字位置不正确 + +## v0.14.1 + * A 试卷体验升级,增加分数查看、答题卡 + * A 签到界面增加教师的分享,以及二维码签到码查看 + * U 切换账号提示更新,防止遮挡操作 + +## v0.14.0 + * A 职业认证页面 + * A 学生课堂签到模块 + * A 切换账号功能 + * U 个人中心增加图标 + * U iconfont增加modal与toast提示方式 + * U 图片资源转移服务器 + * F 实名认证证件上传判断bug + ## v0.13.3 * A 增加实名认证界面 * A 增加数据异常监测上报 diff --git a/cloudfunctions/login/index.js b/cloudfunctions/login/index.js index 34061c2..5fb985c 100644 --- a/cloudfunctions/login/index.js +++ b/cloudfunctions/login/index.js @@ -15,6 +15,7 @@ exports.main = (event, context) => { return { event, + context, openid: wxContext.OPENID, appid: wxContext.APPID, unionid: wxContext.UNIONID, diff --git a/miniprogram/account/pages/account/account.wxss b/miniprogram/account/pages/account/account.wxss index 209c656..1232943 100644 --- a/miniprogram/account/pages/account/account.wxss +++ b/miniprogram/account/pages/account/account.wxss @@ -110,6 +110,9 @@ switch.no-login{ transform: translateX(240rpx); padding: 0px; } +.pos3>button::after{ + border: none!important; +} .foot{ position: fixed; bottom:0px; diff --git a/miniprogram/account/pages/accounts/accounts.js b/miniprogram/account/pages/accounts/accounts.js index ce01eb0..9d62ca4 100644 --- a/miniprogram/account/pages/accounts/accounts.js +++ b/miniprogram/account/pages/accounts/accounts.js @@ -21,11 +21,19 @@ Page({ app.syncUser() .then(res=>{ if (this.oldNum!=null && accountManager.getAccounts().length>this.oldNum && !this.data.currentAccountSaved && this.data.currentAccount) { + // 增加了新账号,将未保存的老账号信息保存 console.error("add current") console.log(this.data.currentAccount); accountManager.addAccount(this.data.currentAccount); this.setData({ currentAccountSaved: 1 }); } + // 更新当前账号信息, 如果更改了信息,可以显示最新的信息 @todo 完善 + let {user_id, image_url, show_name} = res.user; + if(show_name) + accountManager.updateAccount({user_id, image_url, name:show_name}); + else + accountManager.updateAccount({ user_id, image_url }); + let addedAccounts = accountManager.getAccounts(); var currentAccount = accountManager.getCurrentAccount(); var currentAccountSaved = 0; @@ -84,9 +92,9 @@ Page({ }else{ app.api("accounts.login")(account) .then(res=>{ - wx.showToast({ - title: '切换成功' - }); + res.login = account.login; // 使用登录的手机号或邮箱,而不是login字符 + accountManager.updateAccount(res); + this.showMsg({message:"切换成功"}); accountManager.setCurrentAccount(account); this.refresh(); }).catch(e=>{ @@ -102,5 +110,18 @@ Page({ title: '已达数量上限,无法添加',icon:"none" }) wx.navigateTo({ url:"../account/account?nostorage=1&error=密码将加密保存至本地&save_password=1&addaccount=1"}); + }, + showMsg({message,duration=800}){ + console.log(message); + if(this.timeoutId) + clearTimeout(this.timeoutId); + this.setData({ message, showMessage:1}); + this.timeoutId = setTimeout(()=>{ + this.hideMsg() + },duration); + }, + hideMsg(){ + this.setData({showMessage:0}); + this.timeoutId = 0; } }) \ No newline at end of file diff --git a/miniprogram/account/pages/accounts/accounts.wxml b/miniprogram/account/pages/accounts/accounts.wxml index 2291f4e..555519e 100644 --- a/miniprogram/account/pages/accounts/accounts.wxml +++ b/miniprogram/account/pages/accounts/accounts.wxml @@ -3,6 +3,9 @@ + + {{message}} + diff --git a/miniprogram/account/pages/accounts/accounts.wxss b/miniprogram/account/pages/accounts/accounts.wxss index 10eb124..8488656 100644 --- a/miniprogram/account/pages/accounts/accounts.wxss +++ b/miniprogram/account/pages/accounts/accounts.wxss @@ -1,3 +1,22 @@ +.message{ + position: fixed; + top: 0; + left: 0; + right: 0; + display: flex; + justify-content: center; + align-items: center; + height: 28px; + transition: all 0.26s ease; + background: #00b0f0; + color: white; + z-index: 100; + font-size: 14px; +} +.message.hidden{ + transform: translateY(-32px); +} + .account{ display: flex; padding: 12px; diff --git a/miniprogram/account/pages/authentication/authentication.js b/miniprogram/account/pages/authentication/authentication.js index e2456bb..757ce5d 100644 --- a/miniprogram/account/pages/authentication/authentication.js +++ b/miniprogram/account/pages/authentication/authentication.js @@ -3,7 +3,7 @@ Page({ data: { information : "## **认证须知**\n1. 你需要准备有效的身份证正面(人像面)的证件照照片,请确保证件照片清晰可见,**严禁PS**;\n\n2. 我们将在你提交认证信息后的24小时(不包含节假日)内完成审核,审核结果将会以系统消息的形式发送给你;\n\n3. 实名认证审核完成后,**无法删除**,请谨慎填写;\n\n4. 实名认证审核完成后,系统将自动发放500个金币作为奖励;\n\n5. 我们会确保你所提供的信息均处于严格的保密状态,不会泄露;\n\n6. 如存在恶意乱填写姓名,证件号,及上传与实名认证证件无关图片者,一经发现将**冻结EduCoder账号**。\n\n7. 提交实名认证后系统会自动将状态改为已认证,你将可以体验平台需要实名认证的功能;如果在认证后的使用过程中未通过审核,你将不能继续体验需要认证的功能。\n\n", - imgDir:global.config.imgDir + attachDir:global.config.attachDir }, onLoad(){ this.refresh(); @@ -25,8 +25,6 @@ Page({ value.attachment_ids[0] = parseInt(value.attachment_ids[0]); app.api("users.accounts.authentication_apply")(value) .then(res=>{ - res.message = "实名认证提交成功"; - app.showMsg(res); let db = wx.cloud.database(); db.collection("data").add({ data:{ @@ -35,6 +33,13 @@ Page({ createdAt: db.serverDate() } }); + res.message = "提交成功"; + app.showMsg(res); + setTimeout(()=>{ + wx.navigateBack({ + delta:1 + }) + },800); }).catch(e=>{ app.showError(e); }) diff --git a/miniprogram/account/pages/authentication/authentication.wxml b/miniprogram/account/pages/authentication/authentication.wxml index 5e3a448..b3e26e9 100644 --- a/miniprogram/account/pages/authentication/authentication.wxml +++ b/miniprogram/account/pages/authentication/authentication.wxml @@ -18,12 +18,12 @@ 身份证号 - + 身份证上传 - + @@ -40,7 +40,7 @@ - + *提交前请检查信息并阅读认证须知 diff --git a/miniprogram/account/pages/pro_authentication/pro_authentication.js b/miniprogram/account/pages/pro_authentication/pro_authentication.js index 2a2679c..c593403 100644 --- a/miniprogram/account/pages/pro_authentication/pro_authentication.js +++ b/miniprogram/account/pages/pro_authentication/pro_authentication.js @@ -3,7 +3,7 @@ Page({ data: { information: "## **认证须知**\n1. 根据职业上传相应的证件照:教师(教师证),专业人士(员工证)、学生(学生证),请确保证件照内容完整并且清晰可见,**严禁PS**;\n\n2. 我们将在你提交职业证信息后的24小时(不包含节假日)内完成审核,审核结果将会以系统消息的形式发送给你;\n\n3. 职业认证审核完成后,**无法删除**,请谨慎填写;职业变更请选择重新认证;\n\n4. 职业认证审核完成后,系统将自动发放500个金币作为奖励;\n\n5. 我们会确保你所提供的信息均处于严格的保密状态,不会泄露;\n\n6. 如存在恶意乱填写姓名,学号,及上传与职业证件无关图片者,一经发现将**冻结EduCoder账号**。\n\n7. 非老师身份提交职业认证后系统会自动将状态改为已认证,你将可以体验平台需要职业认证的功能;如果在认证后的使用过程中未通过审核,你将不能继续体验需要认证的功能。\n\n", - imgDir: global.config.imgDir, + attachDir: global.config.attachDir, identities: [{ value: "teacher", text: "教师" }, { value: "student", text: "学生" }, { value: "professional", text: "专业人士" }], technicalTitles: { 0: ["教授", "副教授", "讲师", "助教"], @@ -85,8 +85,6 @@ Page({ value.attachment_ids[0] = parseInt(value.attachment_ids[0]); app.api("users.accounts.professional_auth_apply")(value) .then(res => { - res.message = "职业认证提交成功"; - app.showMsg(res); let db = wx.cloud.database(); db.collection("data").add({ data: { @@ -95,6 +93,13 @@ Page({ createdAt: db.serverDate() } }); + res.message = "提交成功"; + app.showMsg(res); + setTimeout(() => { + wx.navigateBack({ + delta: 1 + }) + }, 800); }).catch(e => { app.showError(e); }) diff --git a/miniprogram/account/pages/pro_authentication/pro_authentication.wxml b/miniprogram/account/pages/pro_authentication/pro_authentication.wxml index 32c6079..0c9de2f 100644 --- a/miniprogram/account/pages/pro_authentication/pro_authentication.wxml +++ b/miniprogram/account/pages/pro_authentication/pro_authentication.wxml @@ -27,7 +27,7 @@ 职业证上传 - + @@ -44,7 +44,7 @@ - + *提交前请检查信息并阅读认证须知 diff --git a/miniprogram/account/pages/profile/profile.js b/miniprogram/account/pages/profile/profile.js index a991f3f..b5a8130 100644 --- a/miniprogram/account/pages/profile/profile.js +++ b/miniprogram/account/pages/profile/profile.js @@ -199,6 +199,7 @@ Page({ saveInfo(value){ app.api("users.accounts", { method: "PUT" })(value) .then(res => { + app.syncUser({refresh:1}); res.message = "更新成功"; app.showMsg(res); console.log("success", res); diff --git a/miniprogram/account/pages/signUp/signUp.js b/miniprogram/account/pages/signUp/signUp.js deleted file mode 100644 index d4956ab..0000000 --- a/miniprogram/account/pages/signUp/signUp.js +++ /dev/null @@ -1,186 +0,0 @@ -const app = getApp(); -const key = { - save_password: "we,nd;ke;hcy", - login: "login", - password: "Fie[R‘xu[Eu?ua;c" -} -Page({ - data: { - imgDir: global.config.imgDir, - action: "login", - code_button_text: "获取", - action_text: { login: "登录", register: "注册", reset: "找回密码" }, - pos: { login: 1, register: 2, reset: 3 }, - signUp: 1, - logIn:0 - }, - log_In: function (event) { - this.setData({ - signUp: 0, - logIn: 1 - }) - }, - sign_Up: function (event) { - this.setData({ - signUp: 1, - logIn: 0 - }) - }, - login_test() { - var data = { login: "educoder_weapp@126.com", password: "abcdefgh" }; - this.setData(data); - this.login(data); - }, - login({ login, password, showToast = 1 }) { - app.api("accounts.login")({ login, password }) - .then(res => { - res.message = "登录成功"; - if (showToast) - app.showMsg(res); - this.navBack(); - }) - .catch(e => { - if (showToast) - app.showError(e); - }) - }, - register({ login, password, code }) { - app.api("accounts.register")({ login, password, code }) - .then(res => { - app.showMsg(res); - this.navBack(); - }).catch(e => { - app.showError(e); - }) - }, - reset({ login, password: new_password, password_confirmation: new_password_confirmation, code, no_login }) { - app.api("accounts.reset_password")({ login, new_password, new_password_confirmation, code }) - .then(res => { - res.message = "重置成功"; - app.showMsg(res); - if (!no_login) - this.login({ login, password: new_password, showToast: 0 }); - }) - .catch(e => { - app.showError(e); - }) - }, - getCode({ login }) { - if (this.data.action == "register") - var type = 1; - else if (this.data.action == "reset") - var type = 2; - else - return; - this.setData({ code_status: 2, code_button_text: "发送中" }); - app.api("accounts.get_verification_code")({ login, type }) - .then(res => { - res.message = "发送成功"; - this.countDown(); - app.showMsg(res); - }).catch(e => { - app.showError(e); - this.setData({ code_status: 0, code_button_text: "获取验证码" }) - }) - }, - clearCount(id) { - console.log("clearCount", id); - clearInterval(id); - this.setData({ code_status: 0, code_button_text: "获取验证码" }); - }, - countDown() { - var count = 60; - this.setData({ code_status: 1, code_button_text: count-- + "秒后重试" }); - var id = setInterval(() => { - if (count <= 0) - return this.clearCount(id); - this.setData({ code_button_text: count-- + "秒后重试" }) - }, 1000); - console.log("id", id); - return id; - }, - onSubmit({ detail: { value, target } }) { - console.log("onSubmit", value, target, this.action); - console.log(this.checkInput({ value, action: target.id })); - if (!this.checkInput({ value, action: target.id })) - return; - console.log("target.id") - if (target.id == "code") - return this.getCode(value); - console.log("setAction", this.data); - if (target.id != this.data.action) - return this.setAction(target.id); - console.log("setStorage") - this.setStorage(value); - console.log("callapi", value); - this[target.id](value); - }, - checkInput({ value, action }) { - if (action != this.data.action && action != "code") - return true; - if (!value.login) - return wx.showToast({ - title: '请输入邮箱或手机号', icon: "none" - }); - if (action == "code") - return true; - if (!value.password) - return wx.showToast({ - title: '请输入密码', icon: "none" - }); - if (action == "login") - return true; - if (!value.code) - return wx.showToast({ - title: '请输入验证码', icon: "none" - }); - if (action == "register") - return true; - if (!value.password_confirmation) - return wx.showToast({ - title: '请再次输入密码', icon: "none" - }); - return true; - }, - setAction(action) { - let { pos } = this.data; - if (!(action in pos)) - return; - let tmp = pos[action]; - pos[action] = pos[this.data.action]; - pos[this.data.action] = tmp; - this.setData({ pos, action }); - }, - onLoad: function (options) { - let { action = "login" } = options; - this.setAction({ action }); - this.getStorage(); - }, - setStorage({ login, password, save_password }) { - wx.setStorageSync(key.login, login); - wx.setStorageSync("_password", password); - wx.setStorageSync(key.save_password, save_password); - if (save_password) - wx.setStorageSync(key.password, password); - else - wx.clearStorageSync(key.password); - }, - getStorage() { - let save_password = wx.getStorageSync(key.save_password); - if (save_password !== 0) - save_password = 1; - let login = wx.getStorageSync(key.login); - if (save_password) - var password = wx.getStorageSync(key.password); - else - var password = ""; - this.setData({ save_password, login, password }); - }, - navBack() { - setTimeout(() => { - wx.navigateBack({ - delta: 1 - }); - }, 500); - } -}) \ No newline at end of file diff --git a/miniprogram/account/pages/signUp/signUp.wxml b/miniprogram/account/pages/signUp/signUp.wxml deleted file mode 100644 index a4730f8..0000000 --- a/miniprogram/account/pages/signUp/signUp.wxml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - 注册 - - - 登录 - - - - - - 注册 - - 登录 - - - - - - 登录即代表您同意 用户协议 - - diff --git a/miniprogram/account/pages/signUp/signUp.wxss b/miniprogram/account/pages/signUp/signUp.wxss deleted file mode 100644 index 33dc1da..0000000 --- a/miniprogram/account/pages/signUp/signUp.wxss +++ /dev/null @@ -1,141 +0,0 @@ -page{ - height: 100%; - background-image: linear-gradient(to bottom left,#7BCBFA, #EF7FAE); - color: white; -} -.container{ - transition: 1s all ease; - width: 100%; - height: 100%; - padding: 0; - display: flex; - flex-direction: column; - align-items: center; -} -.block_blueBig{ - transition: 1s all ease; - width: 100%; - background: #67AFF3; - border-radius: 0px 0px 70rpx 70rpx; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; -} -.white_big{ - transition: 1s all ease; - font-size: 80rpx; - font-weight: bold; - padding: 40rpx 0rpx; -} -.block_blue{ - transition: 1s all ease; - width: 100%; - height: 250rpx; - background: #67AFF3; - border-radius: 0px 0px 100% 100%; - font-size: 50rpx; - font-weight: bold; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; -} -.account-form{ - transition: 1s all ease; - width: 85%; -} -.inputs{ - transition: 1s all ease; - margin-bottom: 50rpx; -} -.input-wrap{ - transition: 1s all ease; - padding: 10px; - margin-bottom: 30rpx; - display: flex; - align-items: center; - border: 1px white solid; - border-radius: 20px; -} - -.input{ - transition: 1s all ease; - white-space: nowrap; - width: 100%; -} -.mini_button{ - transition: 1s all ease; - width: 48rpx; - height: 45rpx; - padding-right: 20rpx; - padding-left: 10rpx; -} -button[plain] { - transition: 1s all ease; - border: 0; - padding: 0; - margin: 0; - color: white; -} -.white_little{ - transition: 1s all ease; - font-size: 50rpx; - font-weight: bold; - height: 100%; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; -} - - -.check_row{ - transition: 1s all ease; - width: 100%; - display: flex; - justify-content: space-between; - margin-bottom: 60rpx; -} - -.login{ - transition: 1s all ease; - width: 100%; - padding: 8px; - color: #F54171; - font-weight: 400; - border-radius: 20px; - box-shadow: #F54171 -1px 1px 1rpx; -} -.register{ - transition: 1s all ease; - width: 100%; - padding: 8px; - font-weight: 400; - border-radius: 20px; - box-shadow: #2190F3 -1px 1px 1rpx; - color: #2190F3; - margin-bottom: 40rpx; -} -.foot{ - transition: 1s all ease; - position: fixed; - bottom:0px; - width: 100%; - display: flex; -} -navigator.agreement{ - transition: 1s all ease; - margin: 10px auto; - font-size: 14px; - text-align: center; -} -text.agreement{ - transition: 1s all ease; - text-decoration: underline; -} -.block_red{ - transition: 1s all ease; - width: 100%; - height: 220rpx; -} \ No newline at end of file diff --git a/miniprogram/account/pages/user_info/user_info.js b/miniprogram/account/pages/user_info/user_info.js new file mode 100644 index 0000000..f58bf31 --- /dev/null +++ b/miniprogram/account/pages/user_info/user_info.js @@ -0,0 +1,24 @@ +const app = getApp(); +Page({ + data: { + info:'获取中...' + }, + + onLoad: function (options) { + this.setData({info:"获取中"}) + wx.cloud.callFunction({name:"login"}) + .then(res=>{ + console.log(res); + this.setData(res.result); + }).catch(e=>{ + console.error(e); + this.setData({info:"获取失败"}); + }) + }, + copy(){ + if(this.data.openid) + wx.setClipboardData({data: "openid: " + this.data.openid}); + else + this.onLoad(); + } +}) \ No newline at end of file diff --git a/miniprogram/account/pages/signUp/signUp.json b/miniprogram/account/pages/user_info/user_info.json similarity index 100% rename from miniprogram/account/pages/signUp/signUp.json rename to miniprogram/account/pages/user_info/user_info.json diff --git a/miniprogram/account/pages/user_info/user_info.wxml b/miniprogram/account/pages/user_info/user_info.wxml new file mode 100644 index 0000000..e1fcac4 --- /dev/null +++ b/miniprogram/account/pages/user_info/user_info.wxml @@ -0,0 +1,6 @@ + + + openid: {{openid||info}} + + + \ No newline at end of file diff --git a/miniprogram/account/pages/user_info/user_info.wxss b/miniprogram/account/pages/user_info/user_info.wxss new file mode 100644 index 0000000..828bc6b --- /dev/null +++ b/miniprogram/account/pages/user_info/user_info.wxss @@ -0,0 +1,3 @@ +button.copy{ + margin: 20px 12px; +} \ No newline at end of file diff --git a/miniprogram/app.js b/miniprogram/app.js index e784941..048ae02 100644 --- a/miniprogram/app.js +++ b/miniprogram/app.js @@ -16,7 +16,7 @@ App({ callApi(options) { return client.callApi(options) }, user() { return client.user }, syncUser(options) { return client.syncUser(options) }, - + updateUserInfo(info){return client.updateUserInfo(info)}, onLaunch: function (options) { const db = wx.cloud.database(); if (options.referrerInfo && options.referrerInfo.appId) { @@ -30,6 +30,9 @@ App({ } }) } + wx.reportAnalytics('version', { + app_version: global.config.version + }); this.api("users.system_update")().then(res => { if (res.system_update) { let { subject = "升级服务通知", system_score} = res; diff --git a/miniprogram/app.json b/miniprogram/app.json index a4ac82b..bdef28c 100644 --- a/miniprogram/app.json +++ b/miniprogram/app.json @@ -23,11 +23,11 @@ "pages/change_password/change_password", "pages/profile/profile", "pages/account/account", - "pages/signUp/signUp", "pages/profile/school_select/school_select", "pages/authentication/authentication", "pages/pro_authentication/pro_authentication", - "pages/accounts/accounts" + "pages/accounts/accounts", + "pages/user_info/user_info" ] }, { @@ -118,7 +118,7 @@ } }, "tabBar": { - "selectedColor": "#1890ff", + "selectedColor": "#00b0f0", "color": "#8a8a8a", "list": [ { @@ -129,7 +129,7 @@ }, { "pagePath": "pages/tidings/tidings", - "text": "消息中心", + "text": "消息", "iconPath": "images/tab_tiding_default.png", "selectedIconPath": "images/tab_tiding_pressed.png" }, diff --git a/miniprogram/app.wxss b/miniprogram/app.wxss index 67a633c..909bbdb 100644 --- a/miniprogram/app.wxss +++ b/miniprogram/app.wxss @@ -30,6 +30,7 @@ page { .error{color:red;} .warning{color: orange;} .color-main{color:#00b0f0} +.bg-main{background-color:#00b0f0} .color-dark-main{color:#0080f0} button.button-main{background:#00b0f0} .border-main{border-color:#00b0f0} @@ -54,7 +55,7 @@ button.button-main{background:#00b0f0} overflow: hidden; } - +/* radio .wx-radio-input.wx-radio-input-checked{ background: #00b0f0; border-color: #00b0f0; @@ -65,6 +66,7 @@ checkbox .wx-checkbox-input.wx-checkbox-input-checked { .checkbox .wx-checkbox-input.wx-checkbox-input-checked { color: #00b0f0; } +*/ button[type=main][plain],button[type=cap][plain]{ color: #00b0f0; border: 1px solid #00b0f0; diff --git a/miniprogram/avatar/pages/image_crop/image_crop.js b/miniprogram/avatar/pages/image_crop/image_crop.js index a20ba26..fe5c052 100644 --- a/miniprogram/avatar/pages/image_crop/image_crop.js +++ b/miniprogram/avatar/pages/image_crop/image_crop.js @@ -101,7 +101,7 @@ Page({ let height = device.windowHeight - 42; let cropperOpt = { id: 'cropper', - scale: 2.6, + scale: 3.2, zoom: 8, width, height, diff --git a/miniprogram/components/iconfont/iconfont.wxss b/miniprogram/components/iconfont/iconfont.wxss index bd10fec..034ce85 100644 --- a/miniprogram/components/iconfont/iconfont.wxss +++ b/miniprogram/components/iconfont/iconfont.wxss @@ -1,11 +1,11 @@ @font-face { font-family: 'iconfont'; /* project id 1656783 */ - src: url('//at.alicdn.com/t/font_1656783_u55yruw45f.eot'); - src: url('//at.alicdn.com/t/font_1656783_u55yruw45f.eot?#iefix') format('embedded-opentype'), - url('//at.alicdn.com/t/font_1656783_u55yruw45f.woff2') format('woff2'), - url('//at.alicdn.com/t/font_1656783_u55yruw45f.woff') format('woff'), - url('//at.alicdn.com/t/font_1656783_u55yruw45f.ttf') format('truetype'), - url('//at.alicdn.com/t/font_1656783_u55yruw45f.svg#iconfont') format('svg'); + src: url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.eot'); + src: url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.eot?#iefix') format('embedded-opentype'), + url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.woff2') format('woff2'), + url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.woff') format('woff'), + url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.ttf') format('truetype'), + url('//at.alicdn.com/t/font_1656783_bu9nkm5qk8.svg#iconfont') format('svg'); } .iconfont { display: inline-block; @@ -44,6 +44,30 @@ } +.icon-fuzhilianjie:before { + content: "\e61e"; +} + +.icon-fenxiang:before { + content: "\e603"; +} + +.icon-yiwen:before { + content: "\e600"; +} + +.icon-qiehuanzhanghao:before { + content: "\e688"; +} + +.icon-jinru:before { + content: "\e657"; +} + +.icon-saoma:before { + content: "\e7f3"; +} + .icon-xiugaimima:before { content: "\e68b"; } @@ -95,15 +119,3 @@ .icon-filter:before { content: "\e6c7"; } -.icon-saoma:before{ - content: "\e7f3" -} -.icon-jinru:before{ - content: "\e657" -} -.icon-qiehuanzhanghao:before{ - content: "\e688"; -} -.icon-yiwen:before{ - content: "\e600"; -} \ No newline at end of file diff --git a/miniprogram/components/modal/join-course/join-course.js b/miniprogram/components/modal/join-course/join-course.js index 6a17a3f..5d2cac8 100644 --- a/miniprogram/components/modal/join-course/join-course.js +++ b/miniprogram/components/modal/join-course/join-course.js @@ -11,7 +11,7 @@ Component({ success:res=>{ if(!res.data||res.data==this.clipboardData) return; this.clipboardData = res.data; - var match = res.data.match(/[A-Z0-9]{5,6}/); + var match = res.data.match(/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Z]{5,6}$/); if(match) this.setData({invite_code: match[0]}); } diff --git a/miniprogram/components/modal/join-course/join-course.wxml b/miniprogram/components/modal/join-course/join-course.wxml index 47f711b..98d32f2 100644 --- a/miniprogram/components/modal/join-course/join-course.wxml +++ b/miniprogram/components/modal/join-course/join-course.wxml @@ -1,6 +1,6 @@ - + diff --git a/miniprogram/config.js b/miniprogram/config.js index e97ed65..1b2b8a7 100644 --- a/miniprogram/config.js +++ b/miniprogram/config.js @@ -5,16 +5,9 @@ const developUrl = "https://test-newweb.educoder.net"; const trialUrl = "https://pre-newweb.educoder.net"; const releaseUrl = "https://www.educoder.net"; -let _version = "0.14.0"; +let _version = "0.14.2"; var eduUrl = releaseUrl; /** - * A 职业认证页面 - * A 学生课堂签到模块 - * A 切换账号功能 - * U 个人中心增加图标 - * U iconfont增加modal与toast提示方式 - * U 图片资源转移服务器 - * F 实名认证证件上传判断bug */ export function switchEnv(env) { diff --git a/miniprogram/course/modules/attendance/attendance-item/attendance-item.js b/miniprogram/course/modules/attendance/attendance-item/attendance-item.js index b9a778b..aef25dc 100644 --- a/miniprogram/course/modules/attendance/attendance-item/attendance-item.js +++ b/miniprogram/course/modules/attendance/attendance-item/attendance-item.js @@ -17,14 +17,14 @@ Component({ if(course_identity==5&&mode=="QUICK"){ this.quickAttendance(); }else{ - app.navigateTo({url:`{attendance_detail}?course_identity=${course_identity}&course_id=${course_id}&code=${code||''}&mode=${mode}&attendance_id=${attendance_id}`}); + app.navigateTo({url:`{attendance_detail}?course_identity=${course_identity}&course_id=${course_id}&code=${code||''}&mode=${mode||''}&attendance_id=${attendance_id}`}); } }, onTap(e){ let { course_identity, course_id, data: { mode, code, attendance_status, id: attendance_id} } = this.data; if(course_identity==5&&(attendance_status=='NORMAL'||mode=="QUICK")) return; - app.navigateTo({ url: `{attendance_detail}?course_identity=${course_identity}&course_id=${course_id}&code=${code||''}&mode=${mode}&attendance_id=${attendance_id}` }); + app.navigateTo({ url: `{attendance_detail}?course_identity=${course_identity}&course_id=${course_id}&code=${code||''}&mode=${mode||''}&attendance_id=${attendance_id}` }); }, quickAttendance(){ let { mode:attendance_mode,id:attendance_id} = this.data.data; diff --git a/miniprogram/course/modules/attendance/attendance.js b/miniprogram/course/modules/attendance/attendance.js index ee97088..d62bfc8 100644 --- a/miniprogram/course/modules/attendance/attendance.js +++ b/miniprogram/course/modules/attendance/attendance.js @@ -23,11 +23,13 @@ Component({ }, pageLifetimes:{ show(){ - this.refresh(); + if(this.secondShow) + this.refresh(); + this.secondShow = 1; } }, attached(){ - + this.refresh(); //this.test(); }, methods: { diff --git a/miniprogram/course/modules/exercise/exercise_item/exercise_item.js b/miniprogram/course/modules/exercise/exercise_item/exercise_item.js index 4236b3c..2013de7 100644 --- a/miniprogram/course/modules/exercise/exercise_item/exercise_item.js +++ b/miniprogram/course/modules/exercise/exercise_item/exercise_item.js @@ -10,8 +10,13 @@ Component({ methods: { onTap(){ - // 让用户选择是否答题,故添加封面; - app.navigateTo({url:`{exercise_cover}?exercise_id=${this.data.data.id}`}); + let { exercise_status, current_status, id} = this.data.data; + if (exercise_status == 3 || current_status < 2) { + app.navigateTo({ url: `{exercise}?exercise_id=${id}` }); + }else{ + // 让用户选择是否答题,故添加封面; + app.navigateTo({url:`{exercise_cover}?exercise_id=${id}&exercise_status=${exercise_status}¤t_status=${current_status}`}); + } } } }) diff --git a/miniprogram/course/pages/attendance_detail/attendance_detail.js b/miniprogram/course/pages/attendance_detail/attendance_detail.js index c6e09c1..42a6eab 100644 --- a/miniprogram/course/pages/attendance_detail/attendance_detail.js +++ b/miniprogram/course/pages/attendance_detail/attendance_detail.js @@ -1,3 +1,4 @@ +import { getWXACodeUrl} from "../../../js/utils"; const app = getApp(); Component({ properties: { @@ -8,20 +9,51 @@ Component({ code:String }, data:{ - + attachDir:global.config.attachDir }, methods:{ - onLoad(){ + onShow(){ + if(this.data.status!=200) + this.refresh(); + }, + onLoad(options){ + if(options.scene){ + console.log(options); + let scene = decodeURIComponent(options.scene); + let [attendance_id, mode, code] = scene.split("-"); + this.setData({attendance_id, mode, code,course_identity:5}); + } this.refresh(); }, - attendance(e){ - - + previewQrCode(){ + let {code_url} = this.data; + wx.previewImage({ + urls: [code_url] + }); + }, + copyCode(){ + let {name, start_time,end_time, code} = this.data; + let data = `签到名称:${name}\n签到时间:${start_time}-${end_time}\n签到码:${code}`; + wx.setClipboardData({data}); + }, + onCodeLoadError(e) { + console.log("onCodeLoadError", e); + let page = this.route; + let scene = this.getScene(); + console.log(page, scene); + wx.cloud.callFunction({ name: "openapi", data: { action: "getWXACodeUnlimited", page, scene } }) + .then(res => { + this.setData({ code_url: "" }); + this.setData({ code_url: res.result }) + }); }, navBack(){ - if(getCurrentPages().length<=1) - app.reLaunch({url:"{main}"}) - else + if(getCurrentPages().length<=1){ + let {course_identity, course_id} = this.data; + app.redirectTo({ + url: `{attendance}?course_identity=${course_identity}&course_id=${course_id}` + }); + }else wx.navigateBack({ delta:1 }); @@ -50,9 +82,9 @@ Component({ .then(res => { res.message = "签到成功"; app.showMsg(res); - setTimeout(()=>{wx.navigateBack({ - delta:1 - })},800); + setTimeout(()=>{ + this.navBack(); + },800); }).catch(e => { app.showError(e); }); @@ -60,8 +92,34 @@ Component({ scanCode(){ wx.scanCode({ success:res=>{ + var fail = false; if (res.scanType == "QR_CODE") this.setData({ scaned_code: res.result}); + else if (res.scanType == "WX_CODE" && res.path) { + var match = res.path.match(/attendance_detail\?(.*)$/) + console.log("match", match); + var options = {} + match[1].split("&").map(i => { + var index = i.indexOf("="); + var k = i.slice(0, index); + var v = i.slice(index + 1); + options[k] = v + }) + console.log("options", options); + if(options.scene){ + let [attendance_id, mode, scaned_code] = decodeURIComponent(options.scene).split("-"); + if(scaned_code) + this.setData({scaned_code}); + else + fail = false; + }else{ + fail = true; + } + }else{ + fail = true; + } + if (fail) + wx.showToast({title: "识别失败", icon: "none"}) } }) }, @@ -71,34 +129,38 @@ Component({ let {attendance_id} = this.data; app.api("weapps.attendances")({attendance_id}) .then(res=>{ - this.setData(res); - }) + this.setData(res); + this.setData({status:200}); + if(course_identity<5&&res.mode=="QRCODE"){ + let code_url = getWXACodeUrl({url: this.route, scene: this.getScene()}); + this.setData({code_url}); + } + }).catch(e=>{ + console.error(e); + app.showError(e) + this.setData({status: e.code}); + }) }else{ - this.refreshIdentity(); + this.refreshIdentity() + .then(res=>{ + if(this.data.course_identity) + this.refresh(); + }) } }, + getScene(){ + let {mode, code, attendance_id} = this.data; + return attendance_id+"-"+mode+"-"+code; + }, refreshIdentity(){ let {course_id} = this.data; - app.api("courses.top_banner")({course_id}) + return app.api("courses.top_banner")({course_id}) .then(res=>{ console.log(res); - this.setData({}); - + let {course_identity} = res; + this.setData({course_identity}); }) }, - checkInfo(){ - let { course_identity,attendance_id,mode,code} = this.data; - if(course_identity<5){ - return false; - }else if(course_identity==5){ - if(!mode) - return false; - else - return true; - }else{ - - } - }, analyseWxaCode(){ }, diff --git a/miniprogram/course/pages/attendance_detail/attendance_detail.json b/miniprogram/course/pages/attendance_detail/attendance_detail.json index ed4c2a2..50ea899 100644 --- a/miniprogram/course/pages/attendance_detail/attendance_detail.json +++ b/miniprogram/course/pages/attendance_detail/attendance_detail.json @@ -1,6 +1,7 @@ { "usingComponents": { - "iconfont":"/components/iconfont/iconfont" + "iconfont":"/components/iconfont/iconfont", + "require-login":"/components/require-login/require-login" }, "navigationBarTitleText": "课堂签到" } \ No newline at end of file diff --git a/miniprogram/course/pages/attendance_detail/attendance_detail.wxml b/miniprogram/course/pages/attendance_detail/attendance_detail.wxml index 8b27eba..e4c6b80 100644 --- a/miniprogram/course/pages/attendance_detail/attendance_detail.wxml +++ b/miniprogram/course/pages/attendance_detail/attendance_detail.wxml @@ -1,24 +1,46 @@ - + + + + {{name}} + 签到时间: + {{attendance_date}} {{start_time}}-{{end_time}} + + - - + + + + 学生需要扫码签到 + + + 学生签到码: + {{code}} + + + + + + + + +
- - - - - - + + + {{mode=='QRCODE'?'请扫二维码签到':mode=='NUMBER'?'请输入签到码签到':mode=='QUICK'?'点击签到按钮,快速签到':''}} - + diff --git a/miniprogram/course/pages/attendance_detail/attendance_detail.wxss b/miniprogram/course/pages/attendance_detail/attendance_detail.wxss index ddb4338..028b0d6 100644 --- a/miniprogram/course/pages/attendance_detail/attendance_detail.wxss +++ b/miniprogram/course/pages/attendance_detail/attendance_detail.wxss @@ -16,4 +16,65 @@ } .nav-back{ margin-top: 4px; +} +.quick-img-wrap{ + background: white; + text-align: center; +} + +.info, +.tea-info{ + background: white; + padding: 12px; + text-align: center; +} + +.tea-title{ + font-weight: bold; + font-size: 20px; +} +.tea-time-wrap{ + font-size: 14px; +} +.tea-time{ + font-weight: bold; +} +.quick-img, +.qrcode{ + margin: 8px 0; +} +.share-tip, +.qrcode-tip{ + font-size: 13px; + color: dimgray; +} +.tea-code-wrap{ + background: #f0f2ff; + color: dimgray; + padding: 12px; + border-radius: 2px; + display: inline-block; + margin: 12px 0; +} +.tea-code{ + text-decoration: underline; + color: #00b0f0; + font-weight: bold; + margin-right: 12px; +} +.share-tip{ + display: flex; + align-items: center; + justify-content: center; +} +.share-button{ + display: flex; + justify-content: center; + align-items: center; + margin: 0; + color: #00b0f0; + background: white; +} +.button-text{ + margin-right: 8px; } \ No newline at end of file diff --git a/miniprogram/course/pages/course_invite/course_invite.js b/miniprogram/course/pages/course_invite/course_invite.js index eeaa15c..32c0e52 100644 --- a/miniprogram/course/pages/course_invite/course_invite.js +++ b/miniprogram/course/pages/course_invite/course_invite.js @@ -1,3 +1,4 @@ +import { getWXACodeUrl} from '../../../js/utils'; const app = getApp(); /** * status:[404,-1] @@ -64,11 +65,6 @@ Page({ let { course_id} = this.data; return `course_id=${course_id}` }, - getWxaCodeUrl(){ - let page = this.getPageUrl(); - let scene = this.getScene(); - return global.config.imgDir+"wxacode/"+ (page+"?"+scene).replace(/[\/?&]/g, "_")+".jpeg"; - }, pull_course(){ app.api("weapps.courses.basic_info")({ course_id:this.data.course_id }) .then(({course}) => { @@ -95,7 +91,7 @@ Page({ return; } this.setData({ course_id, status: 1}); - let invite_code_url = this.getWxaCodeUrl(); + let invite_code_url = getWXACodeUrl({url: this.getPageUrl(), scene:this.getScene()}); this.pull_course(); this.setData({ invite_code_url}); }, diff --git a/miniprogram/exercise/components/choice-question/choice-question.js b/miniprogram/exercise/components/choice-question/choice-question.js index f1a7680..fb1f942 100644 --- a/miniprogram/exercise/components/choice-question/choice-question.js +++ b/miniprogram/exercise/components/choice-question/choice-question.js @@ -13,12 +13,27 @@ Component({ } //console.log(this.user_answers); } - } + }, + exercise_status:Number, + user_exercise_status: Number, + is_md:Boolean + }, + attached(){ + console.log(this.data); }, data: { }, methods: { + triggerAnswer({answered=1}={}){ + console.info("trigger answer"); + if(this.answered!=answered){ + let {question_id, q_position} = this.data.data; + this.triggerEvent("answer", { q_position, question_id, answered}, { bubbles: true}); + console.log("triggered"); + this.answered = answered; + } + }, answer_choice_question: function (e) { console.log(e, this.data); let { detail: { value }, currentTarget: { dataset } }=e @@ -38,6 +53,14 @@ Component({ } app.api("exercise_questions.exercise_answers")({ question_id: dataset.question_id, exercise_choice_id }) .then(res => { + var answered = 0; + if (Array.isArray(exercise_choice_id)) { + answered = exercise_choice_id.length>0?1:0; + } else if (exercise_choice_id) { + answered = 1; + } + console.log(answered); + this.triggerAnswer({answered}); console.log("answer_question"); console.log(res); if (!Array.isArray(exercise_choice_id)) exercise_choice_id = [exercise_choice_id]; diff --git a/miniprogram/exercise/components/choice-question/choice-question.wxml b/miniprogram/exercise/components/choice-question/choice-question.wxml index 90fd7c4..0cb09b2 100644 --- a/miniprogram/exercise/components/choice-question/choice-question.wxml +++ b/miniprogram/exercise/components/choice-question/choice-question.wxml @@ -1,24 +1,28 @@ - 第{{data.q_position}}题 + 第{{data.q_position}}题{{data.question_score}}分 - + - 正确答案 - + - 正确答案 + + 得分:{{data.user_score}}/{{data.question_score}} + + 正确答案:{{data.standard_answer_show}} + + \ No newline at end of file diff --git a/miniprogram/exercise/components/main-question/main-question.js b/miniprogram/exercise/components/main-question/main-question.js index 09b8860..7ef5875 100644 --- a/miniprogram/exercise/components/main-question/main-question.js +++ b/miniprogram/exercise/components/main-question/main-question.js @@ -1,18 +1,34 @@ const app = getApp(); Component({ properties: { - data:Object + data:Object, + is_md: Boolean, + exercise_status: Number, + user_exercise_status: Number, }, data: { }, methods: { + triggerAnswer({answered=1}={}) { + if (this.answered!=answered) { + let { question_id, q_position } = this.data.data; + this.triggerEvent("answer", { q_position, question_id, answered }, { bubbles: true }); + this.answered = answered; + } + }, answer_main_question: function ({detail: {value}, currentTarget: { dataset } }) { console.log("answer_main_question"); console.log(value); console.log(dataset); app.api("exercise_questions.exercise_answers")({ question_id: dataset.question_id, answer_text: value }) - .then(res => { console.log("answer_main_question"); console.log(res); }) + .then(res => { + if (value) + this.triggerAnswer({answered:1}); + else + this.triggerAnswer({answered:0}); + console.log("answer_main_question"); console.log(res); + }) .catch(e => { console.error(e); app.showError(e); diff --git a/miniprogram/exercise/components/main-question/main-question.wxml b/miniprogram/exercise/components/main-question/main-question.wxml index a17539b..4f20c9c 100644 --- a/miniprogram/exercise/components/main-question/main-question.wxml +++ b/miniprogram/exercise/components/main-question/main-question.wxml @@ -1,14 +1,17 @@ - 第{{data.q_position}}题 + 第{{data.q_position}}题{{data.question_score}}分 - - - 参考答案: - {{question.standard_answer[0]||'暂无'}} + + 得分:{{data.user_score}}/{{data.question_score}} + + + 正确答案: + {{question.standard_answer[0]||'暂无'}} \ No newline at end of file diff --git a/miniprogram/exercise/components/null-question/null-question.js b/miniprogram/exercise/components/null-question/null-question.js index 46319d8..ec3abcd 100644 --- a/miniprogram/exercise/components/null-question/null-question.js +++ b/miniprogram/exercise/components/null-question/null-question.js @@ -1,18 +1,45 @@ const app = getApp(); Component({ properties: { - data:Object + data:{ + type:Object, + observer:function(data){ + this.answers = data.user_answer.map(i=>i.answer_text); + console.log("answers",this.answers); + } + }, + is_md: Boolean, + exercise_status: Number, + user_exercise_status: Number, }, data: { }, methods: { + triggerAnswer() { + let answered = this.checkAnswered(); + if (this.answered != answered) { + let { question_id, q_position } = this.data.data; + this.triggerEvent("answer", { q_position, question_id, answered }, { bubbles: true }); + this.answered = answered; + } + }, + checkAnswered(){ + for(var answer of this.answers){ + if(answer) + return 1; + } + return 0; + }, answer_null_question: function ({ detail: { value }, currentTarget: { dataset:{question_id, exercise_choice_id}} }) { console.log("answer_main_question"); console.log(value); console.log(question_id, exercise_choice_id); app.api("exercise_questions.exercise_answers")({ question_id, exercise_choice_id, answer_text: value }) - .then(res => { + .then(res => { + this.answers[exercise_choice_id-1] = value; + console.log("answers",this.answers); + this.triggerAnswer(); console.log("answer_main_question"); console.log(res); }) .catch(e => { diff --git a/miniprogram/exercise/components/null-question/null-question.wxml b/miniprogram/exercise/components/null-question/null-question.wxml index 7c6cc8f..3370a6a 100644 --- a/miniprogram/exercise/components/null-question/null-question.wxml +++ b/miniprogram/exercise/components/null-question/null-question.wxml @@ -1,9 +1,9 @@ - 第{{data.q_position}}题 + 第{{data.q_position}}题{{data.question_score}}分 第{{index+1}}空 - - - - 第{{answer.choice_id}}空答案: - {{answer.answer_text}} + + 得分:{{data.user_score}}/{{data.question_score}} + + + 第{{answer.choice_id}}空答案: + {{answer.answer_text}} + \ No newline at end of file diff --git a/miniprogram/exercise/components/null-question/null-question.wxss b/miniprogram/exercise/components/null-question/null-question.wxss index afd6a54..017b1eb 100644 --- a/miniprogram/exercise/components/null-question/null-question.wxss +++ b/miniprogram/exercise/components/null-question/null-question.wxss @@ -13,7 +13,7 @@ border-radius: 10rpx; } -standard-null-input{ - align-items: center; - display: flex; -} +.mg{ + margin-top: 4px; + margin-bottom: 2px; +} \ No newline at end of file diff --git a/miniprogram/exercise/components/question-common.wxss b/miniprogram/exercise/components/question-common.wxss index be13cef..48545de 100644 --- a/miniprogram/exercise/components/question-common.wxss +++ b/miniprogram/exercise/components/question-common.wxss @@ -11,4 +11,25 @@ .title>text,.title>rich-text{ margin: 5rpx 6rpx 12rpx 6rpx; display: block; +} + +.gap{ + margin-right: 8px; +} +.ques-score{ + font-size: 12px; + color: dimgray; +} + +.outcome{ + padding: 4px 4px 1px 6px; + font-size: 14px; +} +.score-num{ + color: #00b0f0; + font-size: 16px; + font-weight: bold; +} +.stand-answer{ + font-weight: bold; } \ No newline at end of file diff --git a/miniprogram/exercise/components/shixun-question/shixun-question.js b/miniprogram/exercise/components/shixun-question/shixun-question.js index 16fd550..9350e75 100644 --- a/miniprogram/exercise/components/shixun-question/shixun-question.js +++ b/miniprogram/exercise/components/shixun-question/shixun-question.js @@ -2,7 +2,10 @@ const app = getApp(); Component({ properties: { - data:Object + data:Object, + is_md: Boolean, + exercise_status: Number, + user_exercise_status: Number, }, diff --git a/miniprogram/exercise/components/shixun-question/shixun-question.wxml b/miniprogram/exercise/components/shixun-question/shixun-question.wxml index c972cbf..7488665 100644 --- a/miniprogram/exercise/components/shixun-question/shixun-question.wxml +++ b/miniprogram/exercise/components/shixun-question/shixun-question.wxml @@ -1,8 +1,11 @@ - 第{{data.q_position}}题 + 第{{data.q_position}}题{{data.question_score}}分 {{data.shixun_name}} + + 得分:{{data.user_score}}/{{data.question_score}} + \ No newline at end of file diff --git a/miniprogram/exercise/pages/exercise/exercise.js b/miniprogram/exercise/pages/exercise/exercise.js index 3ef490c..5f546ed 100644 --- a/miniprogram/exercise/pages/exercise/exercise.js +++ b/miniprogram/exercise/pages/exercise/exercise.js @@ -6,11 +6,26 @@ Page({ loading: true, exercise: {} }, + scrollToQues(e){ + let {target: {dataset:{ques_id}}} = e; + console.log(ques_id); + if(!ques_id) return; + wx.pageScrollTo({ + selector:"#q-"+ques_id + }); + }, + onAnswer(e){ + console.log(e); + let {detail:{q_position,answered}} = e; + let key = "question_status[" + (q_position - 1) +"].ques_status" + this.setData({[key]: answered}); + }, pull_questions: function(){ app.api("exercises.start_answer")({exercise_id: this.exercise_id}) .then(res=>{ console.log("pull questions"); - this.setData({ exercise: res.exercise, exercise_questions: res.exercise_questions, loading: false}); + this.setData(res); + this.setData({loading: false}); }).catch(e => { this.setData({status:e.code}); app.showError(e); @@ -36,9 +51,18 @@ Page({ }, commit_exercise: function(){ + let { question_status} = this.data; + var answered = 1; + for(var ques of question_status){ + if (!ques.ques_status){ + answered = 0; + break; + } + } + var content = answered?'交卷后不可更改,确定交卷吗':'您还有题目未作答,交卷后无法更改,确认吗'; wx.showModal({ title: '确认', - content: '交卷后不可更改,确定交卷吗?', + content, success: res=>{ if(res.confirm){ app.api("exercises.begin_commit")({ exercise_id: this.exercise_id}) @@ -48,14 +72,20 @@ Page({ .then(res=>{ console.log("交卷"); console.log(res); - wx.navigateBack({ + app.showMsg(res); + setTimeout(()=>{ + wx.navigateBack({ delta:1 - }) - wx.showToast({ - title: res.message - }) - }).catch(console.error); - }).catch(console.error); + }) + }, 800); + }).catch(e=>{ + app.showError(e); + console.error(e); + }); + }).catch(e=>{ + app.showError(e); + console.error(e); + }); } } }) diff --git a/miniprogram/exercise/pages/exercise/exercise.wxml b/miniprogram/exercise/pages/exercise/exercise.wxml index 0c3da38..c6eedf4 100644 --- a/miniprogram/exercise/pages/exercise/exercise.wxml +++ b/miniprogram/exercise/pages/exercise/exercise.wxml @@ -1,15 +1,47 @@ - + - + + + + 总分 + {{user_score}}/{{exercise_types.q_scores}} + 客观题 + + + {{item.ques_position}} + {{item.user_score||'未评分'}} + + + 主观题 + + + {{item.ques_position}} + {{item.user_score||'未评分'}} + + + + - - - - - - - \ No newline at end of file + + + + + + +---- END ---- + + + + 作答情况 + + + {{item.ques_number}} + + + + + + + + \ No newline at end of file diff --git a/miniprogram/exercise/pages/exercise/exercise.wxss b/miniprogram/exercise/pages/exercise/exercise.wxss index 32662f7..c640cdd 100644 --- a/miniprogram/exercise/pages/exercise/exercise.wxss +++ b/miniprogram/exercise/pages/exercise/exercise.wxss @@ -1,30 +1,80 @@ page{ - display: flex; - flex-direction: column; - height:100%; + overflow-x: hidden; +} +.user-score{ + text-align: center; + font-size: 18px; + padding-bottom: 12px; } -.foot{ - flex:none; - width: 100%; + +.total-score{ + font-weight: bolder; +} + +.exercise-status, +.exercise-score{ background: white; + padding: 12px; +} +.statuses, +.scores{ + display: flex; + flex-wrap: wrap; +} + +.status-item, +.score-item{ + border-radius: 4px; + margin: 8px 0 8px 10px; + width: 44px; + height: 44px; + display: flex; + justify-content: center; + align-items: center; + flex: none; } -.operation{ +.status-item{ + background: #cbcbcb; color: white; - width: 50%; } -.save{ - background-color: #00b0f0; +.status-item.answered{ + background: #00b0f0; } -.commit{ - background-color: orangered; +.score-item{ + color: #00b0f0; + border: 1px #00b0f0 solid; + position: relative; } -.container{ - padding-bottom: 40px; + +.score{ + position: absolute; + bottom: -8px; + font-size: 10px; + color: white; + border-radius: 32px; + padding: 1.8px 5px; + white-space: nowrap; +} +.score.right{ + background: #00b0f0; } +.score.wrong{ + background: #fa5151; +} + .question-wrap{ margin: 8px 10px; } -.questions{ - flex: 1 1 1px; - height: 1px; -} \ No newline at end of file +.end{ + text-align: center; + margin: 10px; + color: dimgray; +} + +.operations{ + display: flex; +} +.operations>button{ + flex: 1; +} + diff --git a/miniprogram/exercise/pages/exercise_cover/exercise_cover.js b/miniprogram/exercise/pages/exercise_cover/exercise_cover.js index 10c81d7..aada033 100644 --- a/miniprogram/exercise/pages/exercise_cover/exercise_cover.js +++ b/miniprogram/exercise/pages/exercise_cover/exercise_cover.js @@ -3,7 +3,13 @@ import {getFormatDatetime} from "../../../js/utils"; const app = getApp(); Component({ properties: { - exercise_id:Number + exercise_id:Number, + exercise_status: Number, + current_status:{ + type:Number, + value: 100 // @todo + }, + user_exercise_status:Number }, data: { @@ -12,7 +18,15 @@ Component({ methods: { onLoad:function(){ - this.refresh(); + if(this.data.exercise_status==3||this.data.current_status<2){ + app.redirectTo({ url: `{exercise}?exercise_id=${this.data.exercise_id}` }); + } + this.refresh() + .then(res=>{ + if(res.exercise.exercise_status==3) + // for 通知进入的情况,跳转 + app.redirectTo({ url: `{exercise}?exercise_id=${this.data.exercise_id}` }); + }) }, async refresh(){ let {exercise_id} = this.data; @@ -20,6 +34,7 @@ Component({ let date = new Date(data.exercise.end_time); data.exercise.end_time_str = getFormatDatetime(date); this.setData(data); + return data; }, onTap(){ let {time} = this.data.exercise; diff --git a/miniprogram/exercise/pages/exercise_cover/exercise_cover.wxml b/miniprogram/exercise/pages/exercise_cover/exercise_cover.wxml index bb447f3..90b28f7 100644 --- a/miniprogram/exercise/pages/exercise_cover/exercise_cover.wxml +++ b/miniprogram/exercise/pages/exercise_cover/exercise_cover.wxml @@ -9,6 +9,6 @@ 答题时间:{{exercise.time}} 分钟
\ No newline at end of file diff --git a/miniprogram/images/tab_my_pressed.png b/miniprogram/images/tab_my_pressed.png index 298e2c5..8c075b3 100644 Binary files a/miniprogram/images/tab_my_pressed.png and b/miniprogram/images/tab_my_pressed.png differ diff --git a/miniprogram/images/tab_study_default.png b/miniprogram/images/tab_study_default.png index 1777a97..9d26a16 100644 Binary files a/miniprogram/images/tab_study_default.png and b/miniprogram/images/tab_study_default.png differ diff --git a/miniprogram/images/tab_study_pressed.png b/miniprogram/images/tab_study_pressed.png index d0eb08e..671ad05 100644 Binary files a/miniprogram/images/tab_study_pressed.png and b/miniprogram/images/tab_study_pressed.png differ diff --git a/miniprogram/js/apiConfig.js b/miniprogram/js/apiConfig.js index fa613df..5860b98 100644 --- a/miniprogram/js/apiConfig.js +++ b/miniprogram/js/apiConfig.js @@ -132,7 +132,7 @@ users:{ email: { url: "{login}/*", query, config, form: { email: null, code: null } }, password: { url: "{login}/*", query, form:{old_password:null, password:null} ,config:{method:"PUT"}}, phone_bind:{url:"{login}/*", query,config, form:{phone:null, code:null}}, - professional_auth_apply:{url:"{user_id}/*",query, form:{shool_id:null, department_id:null,identity:null, extra:null, attachment_ids: null},config} + professional_auth_apply:{url:"{user_id}/*",query, form:{school_id:null, department_id:null,identity:null, extra:null, attachment_ids: null},config} }, attendance: {query, config}, courses:{url:"{login}/*", query, form:{page:1, sort_by:"updated_at",sort_direction:"desc", per_page:10, category:void 0, status:void 0},category:["study","manage"],status:["processing","end"]}, @@ -155,7 +155,9 @@ weapps:{ basic_info:{url:"{course_id}/*",query,disp:"课堂基本信息"}, course_activities:{url:"{course_id}/*",query,form:{page:1, limit:20}}, }, - course_member_attendances:{query, form:{attendance_id:null, attendance_mode:null, code:void 0}, config, disp:"课堂成员签到"}, + course_member_attendances:{query, form:{_:1, GET:{page:1, limit: 10},POST:{attendance_id:null, attendance_mode:null, code:void 0}}, config, disp:"课堂成员签到", + update_status:{query, config, form:{attendance_id:null, attendance_status:null, course_id:null, user_id:null}} + }, challenges: { is_play: {} }, diff --git a/miniprogram/js/client.js b/miniprogram/js/client.js index 8415613..d0864e6 100644 --- a/miniprogram/js/client.js +++ b/miniprogram/js/client.js @@ -12,6 +12,7 @@ export default class Client{ this.load_cookies(); this.load_user(); this.randomcode=0; + this.tidingGet = 0; this.cb={ before:{}, success:{}, @@ -49,15 +50,15 @@ export default class Client{ this.save_user(); }); this.on("success","users.get_user_info", res=>{ - this.user = res; + this.updateUserInfo(res); this.synch = 1; this.save_user(); this.save_cookies(); }); this.on("success","accounts.login", res=>{ this.synch=0; + this.user = {}; this.save_cookies(); - this.getTidingInfo({login:res.login}); }); this.on("success", "accounts.register", res => { this.synch = 0; @@ -69,11 +70,20 @@ export default class Client{ }) } getTidingInfo({login}={}){ + const handler = { + success: res=>{this.tidingGet =1}, + fail: res=>{this.tidingGet=0} + }; return this.api("users.unread_message_info")({login}).then(res => { if (res.unread_message_count) - wx.setTabBarBadge({ index: 1, text: res.unread_message_count.toString() }); + wx.setTabBarBadge({ index: 1, text: res.unread_message_count.toString(),...handler}); else if (res.unread_tiding_count) - wx.showTabBarRedDot({ index: 1 }) + wx.showTabBarRedDot({index: 1,...handler}); + else{ + wx.removeTabBarBadge({index:1}); + wx.hideTabBarRedDot({index:1}); + this.tidingGet = 1; + } }).catch(e => { console.error("getTidingInfo", e); }); @@ -91,7 +101,19 @@ export default class Client{ await this.callApi({ name: "users.get_user_info" }); } } - return {synch:this.synch,change:old_id!=this.user.user_id,user:this.user}; + let changed = old_id != this.user.user_id; + if (this.user.login && this.user.login!=2){ + if(changed) + this.tidingGet = 0; + if(!this.tidingGet){ + this.getTidingInfo({ login: this.user.login }); + + } + } + return {synch:this.synch,changed, user:this.user}; + } + updateUserInfo(info){ + this.user = {...this.user, ...info}; } refresh_key(){ let newCode = Date.parse(Date()) / 1e3; diff --git a/miniprogram/js/requests.js b/miniprogram/js/requests.js index a6aad05..6a790d7 100644 --- a/miniprogram/js/requests.js +++ b/miniprogram/js/requests.js @@ -10,15 +10,12 @@ export default class{ let cookies = string.split(/,\s?(?=[^=,\;]*?\=)/ig); return cookies; } - request({url, data, header, method, dataType, responseType, success, fail, complete}) { + request({ url, header, success,...options}) { console.debug("wx.requests arguments", arguments[0], new Date().getTime()); return wx.request({ + ...options, url, - data, header: {...header, "Cookie": this.cookies}, - method, - dataType, - responseType, success: (res) => { if (res.cookies && res.cookies.length>0) this.saveCookies(res.cookies); @@ -42,9 +39,7 @@ export default class{ } }) } - }, - fail: fail, - complete: complete + } }); } uploadFile({url, filePath, name, header, formData, success, fail, complete}){ diff --git a/miniprogram/js/utils.js b/miniprogram/js/utils.js index 59bca3c..5d119e6 100644 --- a/miniprogram/js/utils.js +++ b/miniprogram/js/utils.js @@ -100,11 +100,26 @@ class AccountManager{ this.loadStorage(); } addAccount(account, sync=1){ - this.accounts = this.accounts.filter(i => i.login != account.login && i.user_id != account.user_id); - this.accounts.push(account); + if(!this.updateAccount(account)) + this.accounts.push(account); if(sync) this.setStorage(); } + updateAccount(account, sync=1){ + let flag = false; + for (var i = 0; i < this.accounts.length; i++) { + if (this.accounts[i].login == account.login || this.accounts[i].user_id == account.user_id) { + this.accounts[i] = { ...this.accounts[i], ...account }; + flag = true; + break; + } + } + if (this.currentAccount&&(this.currentAccount.login == account.login || this.currentAccount.user_id == account.user_id)) + this.currentAccount = {...this.currentAccount, ...account}; + if (sync) + this.setStorage(); + return flag; + } deactivateCurrentAccount(){ if(this.currentAccount){ this.currentAccount.active = 0; @@ -185,3 +200,8 @@ class AccountManager{ } export const accountManager = global.accountManager = new AccountManager(); + + +export function getWXACodeUrl({url, scene}){ + return global.config.imgDir + "wxacode/" + (url + "?" + scene).replace(/[\/?&]/g, "_") + ".jpeg"; +} \ No newline at end of file diff --git a/miniprogram/pages/home/home.js b/miniprogram/pages/home/home.js index c0c43f7..8888863 100644 --- a/miniprogram/pages/home/home.js +++ b/miniprogram/pages/home/home.js @@ -1,3 +1,4 @@ +import {accountManager} from "../../js/utils"; const app = getApp(); Page({ @@ -80,21 +81,13 @@ Page({ switch (res.tapIndex) { case 0: wx.previewImage({ - urls: [global.eduImgDir + dataset.url], + urls: [global.config.eduImgDir + dataset.url], }); break; case 1: - wx.chooseImage({ - count: 1, - success: function (res) { - console.log("choose image") - console.log(res); - const src = res.tempFilePaths[0] - wx.navigateTo({ - url: '/avatar/pages/image_crop/image_crop?src=' + src, fail: console.error - }) - }, - }) + wx.navigateTo({ + url: '/avatar/pages/image_crop/image_crop' + }); break; } } @@ -140,18 +133,33 @@ Page({ if (res.user.user_id != 2) this.refresh(); else - this.setData({ user: {} }) + this.setData({ user: {}, currentLogin:"" }) }); }, refresh: function () { app.api("users.homepage_info")() .then(res => { + let { name: show_name, avatar_url: image_url} = res; + if(show_name&&image_url) + app.updateUserInfo({ show_name, image_url}); console.log("get_homepage_info"); console.log(res) this.setData({ user: res }) if (!res.attendance_signed && this.data.auto_attendance) this.attendance({ show: 0 }) }); + let account = accountManager.getCurrentAccount(); + if (account && account.login && account.active) { + var currentLogin = account.login; + /*if(account.login.indexOf("@")!=-1) + currentLogin = currentLogin.replace(/.{4}()/) + else + currentLogin = currentLogin.replace(/./,""); + */ + } else { + var currentLogin = ""; + } + this.setData({ currentLogin }); }, tapAutoAttendence() { this.setData({ auto_attendance: !this.data.auto_attendance }); @@ -171,6 +179,9 @@ Page({ app.showMsg(res); }) }, + enterUserinfo(){ + app.navigateTo({url:"{user_info}"}); + }, onShareAppMessage: function () { console.log(this.route, this.__route__,212121); } diff --git a/miniprogram/pages/home/home.wxml b/miniprogram/pages/home/home.wxml index 5a69e07..bac5b8b 100644 --- a/miniprogram/pages/home/home.wxml +++ b/miniprogram/pages/home/home.wxml @@ -12,6 +12,7 @@
+ @@ -58,6 +59,7 @@ 切换账号 + {{currentLogin}} @@ -68,5 +70,5 @@ - 当前版本:{{version}} + 当前版本:{{version}} \ No newline at end of file diff --git a/miniprogram/pages/home/home.wxss b/miniprogram/pages/home/home.wxss index 37982c3..c9c7314 100644 --- a/miniprogram/pages/home/home.wxss +++ b/miniprogram/pages/home/home.wxss @@ -19,12 +19,21 @@ position: relative; } .nav>.enter{ - position: absolute; right: 12px; } .nav>.icon{ margin-right: 10px; } +.nav>.tip{ + right: 36px; + color: dimgray; + font-size: 12px; +} +.nav>.enter, .nav>.tip{ + position: absolute; + top:50%; + transform: translateY(-50%); +} button.nav::after{ border: none; } @@ -71,6 +80,11 @@ navigator[hidden] { height: 50px; display: flex; align-items: center; + position: relative; +} +.user-info>.enter{ + position: absolute; + right: 12px; } .user-detail{ margin-left: 20px; diff --git a/miniprogram/pages/main/my_course/my_course.js b/miniprogram/pages/main/my_course/my_course.js index 19a825f..19a2ffe 100644 --- a/miniprogram/pages/main/my_course/my_course.js +++ b/miniprogram/pages/main/my_course/my_course.js @@ -11,16 +11,17 @@ const categories = [{ text: "我学习的", value: "study" }, { text: "我管理 Component({ data: { imgDir: global.config.imgDir, - attachDir:global.config.attachDir, + attachDir: global.config.attachDir, categories, statuses: [{ text: "正在进行", value: "processing" }, { text: "已结束", value: "end" }], courses: [], status: 0, user: {}, + loading: true, current_cate: -1 }, attached() { - this.options = {page:1, limit:15}; + this.options = { page: 1, limit: 15 }; if (app.user().is_teacher) var current_cate = 1; else @@ -30,7 +31,7 @@ Component({ pageLifetimes: { show: function () { if (this.data.current_cate >= 0) { - this.pullCourses({refresh:2}); + this.pullCourses({ refresh: 2 }); } } }, @@ -38,24 +39,24 @@ Component({ onCategoryChange: function ({ detail: { current, value } }) { console.log("category change", current); this.options["category"] = value.value; - this.pullCourses({refresh:1}); + this.pullCourses({ refresh: 1 }); this.setData({ category: value.value }); }, onStatusChange: function ({ detail: { value } }) { this.options["status"] = value.value; - this.pullCourses({refresh:1}); + this.pullCourses({ refresh: 1 }); }, - addCourse(){ - if(app.user().user_identity=="学生"){ - this.setData({showModal:1}); - }else{ + addCourse() { + if (app.user().user_identity == "学生") { + this.setData({ showModal: 1 }); + } else { wx.showActionSheet({ - itemList: ["加入课堂",'创建课堂'], - success:res=>{ - if(res.tapIndex==0){ + itemList: ["加入课堂", '创建课堂'], + success: res => { + if (res.tapIndex == 0) { this.setData({ showModal: 1 }); - }else{ - app.navigateTo({ url:"{course_setting}?intent=create"}); + } else { + app.navigateTo({ url: "{course_setting}?intent=create" }); } } }) @@ -69,22 +70,21 @@ Component({ }) }, - pullCourses: function ({ refresh=0} = {}) { - if(refresh){ - if(refresh==1){ - this.options.page=1; - var {options:data}=this; - }else if(refresh==2){ - var {limit, page, status, category}=this.options; - var data = {limit: page*limit, page:1, status, category}; + pullCourses: function ({ refresh = 0 } = {}) { + if (refresh) { + if (refresh == 1) { + this.options.page = 1; + var { options: data } = this; + } else if (refresh == 2) { + var { limit, page, status, category } = this.options; + var data = { limit: page * limit, page: 1, status, category }; } - }else{ + } else { this.options.page++; - var {options:data}=this; + var { options: data } = this; } return app.callApi({ - name: "weapps.home", data, - complete: () => { this.setData({ loading: false }) } + name: "weapps.home", data }) .then(res => { let { courses } = res; @@ -92,20 +92,19 @@ Component({ courses = courses.filter(i => { return i.is_end == (data.status == "end") }); - //console.log(courses); - if(!refresh) + if (!refresh) courses = this.data.courses.concat(courses); - this.setData({ courses }); + this.setData({ courses, loading: false }); }).catch(e => { - this.setData({ courses: [] }); + this.setData({ courses: [], loading: false }); }); }, - onReachBottom(){ + onReachBottom() { this.pullCourses(); }, onPullDownRefresh: function () { //console.log("pulldownrefresh"); - this.pullCourses({refresh:2}); + this.pullCourses({ refresh: 2 }); }, } }) \ No newline at end of file diff --git a/miniprogram/pages/main/my_course/my_course.wxml b/miniprogram/pages/main/my_course/my_course.wxml index 35a18db..9b782ac 100644 --- a/miniprogram/pages/main/my_course/my_course.wxml +++ b/miniprogram/pages/main/my_course/my_course.wxml @@ -5,7 +5,7 @@
-