| | |
| | | }, |
| | | "editor.tabSize": 2, |
| | | "[wxml]": { |
| | | "editor.defaultFormatter": "wechat.miniprogram.wxml-language-features" |
| | | "editor.defaultFormatter": "esbenp.prettier-vscode" |
| | | }, |
| | | "[css]": { |
| | | "editor.defaultFormatter": "HookyQR.beautify" |
| | |
| | | |
| | | |
| | | export const loginInfo = (app, callback) => { |
| | | wx.login({ |
| | | success: (res) => { |
| | | wx.getUserInfo({ |
| | | success: (infoRes) => { |
| | | app.MG.identity.checkWeChatAppAccount({ |
| | | code: res.code, |
| | | appCode: app.config.appRefCode, |
| | | encryptedData: infoRes.encryptedData, |
| | | iv: infoRes.iv |
| | | }).then(loginRes => { |
| | | if (!loginRes) { |
| | | const pages = getCurrentPages(); |
| | | const currentPage = pages[pages.length - 1]; |
| | | let url = `/${currentPage.route}`; |
| | | if (Object.keys(currentPage.options).length) { |
| | | let option = ""; |
| | | for (const key in currentPage.options) { |
| | | if (currentPage.options[key]) { |
| | | if (option) { |
| | | option += "&" |
| | | } |
| | | option += key + "=" + currentPage.options[key] |
| | | } |
| | | } |
| | | url += "?" + option |
| | | } |
| | | debugger |
| | | console.log(url); |
| | | wx.navigateTo({ |
| | | url: "/pages/bindInfo/index?page=" + encodeURIComponent(url), |
| | | }); |
| | | } else { |
| | | wx.login({ |
| | | success: (res) => { |
| | | app.MG.identity.loginByWeChatAppCode({ |
| | | code: res.code, |
| | | appRefCode: app.config.appRefCode, |
| | | platform: "WeChatAppCustom", |
| | | encryptedData: infoRes.encryptedData, |
| | | iv: infoRes.iv |
| | | }).then(res => { |
| | | if (res && res.status == "Ok") { |
| | | // 储存token |
| | | wx.setStorageSync(app.config.tokenKey, res.token); |
| | | // 记录登录统计 |
| | | setSessionGuid() |
| | | // 获取用户信息 |
| | | getUserInfo(app, callback, res.token) |
| | | } else { |
| | | console.log(res); |
| | | callback(false) |
| | | } |
| | | }) |
| | | }, |
| | | fail: (err) => { |
| | | console.log(err); |
| | | callback(false) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | fail: (err) => { |
| | | console.log(err); |
| | | callback(false) |
| | | } |
| | | }) |
| | | }, |
| | | fail: (err) => { |
| | | console.log(err); |
| | | callback(false) |
| | | } |
| | | }) |
| | | wx.login({ |
| | | success: (res) => { |
| | | wx.getUserInfo({ |
| | | success: (infoRes) => { |
| | | app.MG.identity.checkWeChatAppAccount({ |
| | | code: res.code, |
| | | appCode: app.config.appRefCode, |
| | | encryptedData: infoRes.encryptedData, |
| | | iv: infoRes.iv |
| | | }).then(loginRes => { |
| | | if (!loginRes) { |
| | | const pages = getCurrentPages(); |
| | | const currentPage = pages[pages.length - 1]; |
| | | let url = `/${currentPage.route}`; |
| | | if (Object.keys(currentPage.options).length) { |
| | | let option = ""; |
| | | for (const key in currentPage.options) { |
| | | if (currentPage.options[key]) { |
| | | if (option) { |
| | | option += "&" |
| | | } |
| | | option += key + "=" + currentPage.options[key] |
| | | } |
| | | } |
| | | url += "?" + option |
| | | } |
| | | debugger |
| | | console.log(url); |
| | | wx.navigateTo({ |
| | | url: "/pages/bindInfo/index?page=" + encodeURIComponent(url), |
| | | }); |
| | | } else { |
| | | wx.login({ |
| | | success: (res) => { |
| | | app.MG.identity.loginByWeChatAppCode({ |
| | | code: res.code, |
| | | appRefCode: app.config.appRefCode, |
| | | platform: "WeChatAppCustom", |
| | | encryptedData: infoRes.encryptedData, |
| | | iv: infoRes.iv |
| | | }).then(res => { |
| | | if (res && res.status == "Ok") { |
| | | // 储存token |
| | | wx.setStorageSync(app.config.tokenKey, res.token); |
| | | // 获取用户信息 |
| | | getUserInfo(app, callback, res.token) |
| | | // 记录登录统计 |
| | | // setSessionGuid() |
| | | } else { |
| | | console.log(res); |
| | | callback(false) |
| | | } |
| | | }) |
| | | }, |
| | | fail: (err) => { |
| | | console.log(err); |
| | | callback(false) |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | }, |
| | | fail: (err) => { |
| | | console.log(err); |
| | | callback(false) |
| | | } |
| | | }) |
| | | }, |
| | | fail: (err) => { |
| | | console.log(err); |
| | | callback(false) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | // 获取登录用户身份 |
| | | const getUserInfo = (app, callback, token) => { |
| | | app.MG.identity.getCurrentAppUser().then(res => { |
| | | // 用户信息优先级:教师认证 > 微信 > 学生(注册时默认) |
| | | if (res) { |
| | | let defaultUser = {}; |
| | | let WeChatInfo = res.infoList.find((item) => item.type === "WeChat"); |
| | | let phoneNumber = res.secretList.find(i => i.type == 'MobilePhone') |
| | | app.MG.identity.getCurrentAppUser().then(res => { |
| | | // 用户信息优先级:教师认证 > 微信 > 学生(注册时默认) |
| | | if (res) { |
| | | let defaultUser = {}; |
| | | let WeChatInfo = res.infoList.find((item) => item.type === "WeChat"); |
| | | let phoneNumber = res.secretList.find(i => i.type == 'MobilePhone') |
| | | |
| | | if (WeChatInfo) { |
| | | defaultUser = { |
| | | nickName: WeChatInfo.name, |
| | | avatarUrl: WeChatInfo.icon, |
| | | weChatId: WeChatInfo.id |
| | | } |
| | | } |
| | | if (phoneNumber) { |
| | | defaultUser.phoneNumber = phoneNumber.credential |
| | | } |
| | | wx.setStorageSync(app.config.userInfoKey, JSON.stringify(defaultUser)); |
| | | } |
| | | callback(token); |
| | | }); |
| | | if (WeChatInfo) { |
| | | defaultUser = { |
| | | nickName: WeChatInfo.name, |
| | | avatarUrl: WeChatInfo.icon, |
| | | weChatId: WeChatInfo.id |
| | | } |
| | | } |
| | | if (phoneNumber) { |
| | | defaultUser.phoneNumber = phoneNumber.credential |
| | | } |
| | | wx.setStorageSync(app.config.userInfoKey, JSON.stringify(defaultUser)); |
| | | } |
| | | callback(token); |
| | | }); |
| | | } |
| | |
| | | var SnIp = null; |
| | | try { |
| | | // eslint-disable-next-line |
| | | SnIp = window.returnCitySN; |
| | | // SnIp = window.returnCitySN; |
| | | } catch (error) { |
| | | SnIp = null; |
| | | console.log(error); |
| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | | let content = { |
| | | source: this.data.ratevalue, |
| | | phone: this.data.inputvalue, |
| | |
| | | }, |
| | | // 确定 |
| | | async confirmSuggest() { |
| | | const isPhoneNumber = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/.test(this.data.inputvalue); |
| | | const telephoneCheck = /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/ |
| | | const istelePhone = telephoneCheck.test(this.data.inputvalue) |
| | | const textvalue = this.data.textvalue.trim() |
| | | if (!this.data.ratevalue) { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: '请选择评分', |
| | | }) |
| | | } else if (!this.data.inputvalue) { |
| | | } else if (!this.data.inputvalue.length) { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: '请填写联系方式', |
| | | }) |
| | | } else if (!isPhoneNumber) { |
| | | } else if (!istelePhone) { |
| | | return wx.showToast({ |
| | | icon: "error", |
| | | title: '请输入正确联系方式', |
| | | }) |
| | | } else if (!this.data.textvalue) { |
| | | } else if (!textvalue.length) { |
| | | return wx.showToast({ |
| | | icon: 'error', |
| | | title: '请输入反馈反馈内容', |
| | |
| | | recordBuyMock() { |
| | | const num = this.data.mockData.mockList.length |
| | | const id = tool.uuid(8) |
| | | const createDate = new Date().getTime() |
| | | const createDate = this.DateFormat(new Date().getTime(), 'yyyy-MM-dd') |
| | | const mockList = this.data.mockData.mockList |
| | | mockList.push({ id, createDate, name: `第${num + 1}套试卷`, state: '0' }) |
| | | this.setData({ |
| | |
| | | this.setData({ |
| | | currentIndex: e.detail.index |
| | | }) |
| | | if (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') { |
| | | let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0 |
| | | let flag = this.isHaveAnswer(this.data.questionDataList[index].userAnswer) |
| | | if (flag) this.handleQuestion(e.detail.index) |
| | | let index = e.detail.index - 1 >= 0 ? e.detail.index - 1 : 0 |
| | | const item = this.data.questionDataList[index] |
| | | if ((this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) { |
| | | let flag = this.isHaveAnswer(item.userAnswer) |
| | | if (flag) this.handleQuestion(index) |
| | | } |
| | | }, |
| | | // 点击答题卡跳转题目 |
| | |
| | | const id = e.detail.value.currentTarget.dataset.id |
| | | const radioChecked = e.detail.value.detail.value |
| | | const questionList = this.data.questionDataList |
| | | questionList.forEach(item => { |
| | | if (item.id == id) { |
| | | // 我的错题和我的收藏模式下,单选题选择了直接批改 |
| | | for (let index = 0; index < questionList.length; index++) { |
| | | const item = questionList[index]; |
| | | if (item.id == id && !item.isComplete) { |
| | | item.userAnswer = radioChecked |
| | | item.isUserAnswer = this.isHaveAnswer(radioChecked) |
| | | if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) { |
| | | debugger |
| | | let index = this.data.currentIndex - 1 >= 0 ? this.data.currentIndex - 1 : 0 |
| | | this.handleQuestion(index) |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | // questionList.forEach(item => { |
| | | // if (item.id == id && !item.isComplete) { |
| | | // item.userAnswer = radioChecked |
| | | // item.isUserAnswer = this.isHaveAnswer(radioChecked) |
| | | // if ((item.questionType == 'singleChoice' || item.questionType == 'judge') && (this.data.answerType == 'collectQuestion' || this.data.answerType == 'errorQuestion') && !item.isComplete) { |
| | | // this.handleQuestion(this.data.currentIndex) |
| | | // } |
| | | // } |
| | | // }) |
| | | const cardListUpdata = this.data.cardList |
| | | cardListUpdata.forEach(item => { |
| | | item.infoList.forEach(citem => { |
| | | if (citem.id == id) { |
| | | for (let index = 0; index < cardListUpdata.length; index++) { |
| | | const item = cardListUpdata[index]; |
| | | for (let cindex = 0; cindex < item.infoList.length; cindex++) { |
| | | const citem = item.infoList[cindex]; |
| | | if (citem.id == id && !citem.isComplete) { |
| | | citem.userAnswer = radioChecked |
| | | citem.isUserAnswer = this.isHaveAnswer(radioChecked) |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | } |
| | | // cardListUpdata.forEach(item => { |
| | | // item.infoList.forEach(citem => { |
| | | // if (citem.id == id && !citem.isComplete) { |
| | | // citem.userAnswer = radioChecked |
| | | // citem.isUserAnswer = this.isHaveAnswer(radioChecked) |
| | | // } |
| | | // }) |
| | | // }) |
| | | this.setData({ |
| | | questionDataList: questionList, |
| | | cardList: cardListUpdata |
| | |
| | | const qustionList = this.data.questionDataList |
| | | for (let index = 0; index < qustionList.length; index++) { |
| | | const item = qustionList[index]; |
| | | if (!item.isComplete) this.handleQuestion(index + 1) |
| | | if (!item.isComplete) this.handleQuestion(index) |
| | | } |
| | | } |
| | | if (this.data.answerType == 'option') { |
| | |
| | | } |
| | | if (mocklist.length && this.data.uuid) { |
| | | const oldMockData = mocklist.find((mockItem) => mockItem.id == this.data.uuid) |
| | | debugger |
| | | this.setData({ |
| | | 'mockData.state': oldMockData.state, |
| | | 'mockData.score': oldMockData.score, |
| | |
| | | // 批改题目 (练习,我的错题,我的收藏,,组卷) |
| | | handleQuestion(num) { |
| | | const questionList = this.data.questionDataList |
| | | const index = num - 1 >= 0 ? num - 1 : 0 |
| | | const index = num |
| | | if (questionList[index].isComplete) { |
| | | // 题目已完成,跳过 |
| | | return true |
| | |
| | | "t-radio-group": "tdesign-miniprogram/radio-group/radio-group", |
| | | "t-checkbox": "tdesign-miniprogram/checkbox/checkbox", |
| | | "t-checkbox-group": "tdesign-miniprogram/checkbox-group/checkbox-group", |
| | | "t-textarea": "tdesign-miniprogram/textarea/textarea" |
| | | "t-textarea": "tdesign-miniprogram/textarea/textarea", |
| | | "t-empty": "tdesign-miniprogram/empty/empty" |
| | | } |
| | | } |
| | |
| | | data-value="{{item.option}}" |
| | | data-id="{{item.id}}" |
| | | data-index="{{inputItem.num}}" |
| | | class="title-input" |
| | | class="title-input {{isNight ? 'input-night-color' : ''}}" |
| | | style="border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx;background-color:{{isNight ? '#000' : '#fff'}}; " |
| | | placeholder-style="{{placeholderstyle}}" |
| | | wx:if="{{inputItem.data == 'input'}}" |
| | |
| | | > |
| | | <view |
| | | style="font-size: {{sliderValue || 32}}rpx;" |
| | | class="radio-item {{(answerType == 'option' || answerType == 'mock' ) && !submitStatus && item.userAnswer == contentItem.value ? 'radio-active' : isNight ? 'night' :''}} {{ (item.answer == contentItem.value && item.answer == item.userAnswer && submitStatus) ? 'radio-correct' : (item.userAnswer == contentItem.value && item.userAnswer != item.answer && submitStatus) ?'radio-error' :'' }}" |
| | | class="radio-item {{(answerType == 'option' || answerType == 'mock' ) && !submitStatus && item.userAnswer == contentItem.value ? 'radio-active' : isNight ? 'night' :''}} {{item.userAnswer == contentItem.value && submitStatus ? item.isRight ? 'radio-correct' : 'radio-error' :''}}" |
| | | > |
| | | <!-- 仅文字 --> |
| | | <text wx:if="{{item.optionStyle == 'Txt'}}" |
| | |
| | | bind:change="onChangeRadio" |
| | | data-value="{{item.option}}" |
| | | data-id="{{item.id}}" |
| | | class="option-textarea" |
| | | class="option-textarea {{isNight ? 'textarea-night-color' :''}}" |
| | | wx:elif="{{item.questionType == 'shortAnswer'}}" |
| | | t-class="external-class" |
| | | placeholder="请输入文字" |
| | |
| | | </view> |
| | | </view> |
| | | </swiper-item> |
| | | <swiper-item wx:if="{{answerType !== 'collectQuestion'}}"> |
| | | <swiper-item |
| | | wx:if="{{answerType !== 'collectQuestion' && questionList.length}}" |
| | | > |
| | | <text>没有更多了。。。</text> |
| | | </swiper-item> |
| | | <swiper-item wx:if="{{!questionList.length}}"> |
| | | <view class="noData"> |
| | | <t-empty icon="folder-open" description="暂无数据" /> |
| | | </view> |
| | | </swiper-item> |
| | | </swiper> |
| | | </view> |
| | |
| | | .textarea-center { |
| | | display: flex; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .input-night-color { |
| | | --td-input-default-text-color: #fff; |
| | | } |
| | | |
| | | .textarea-night-color { |
| | | --td-textarea-text-color: rgba(255, 255, 255, 1); |
| | | } |
| | | |
| | | .noData { |
| | | width: 100%; |
| | | height: 100%; |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | } |
| | |
| | | const app = getApp(); |
| | | import { loginInfo } from '../../../../assets/js/login'; |
| | | Page({ |
| | | /** |
| | | * 页面的初始数据 |
| | |
| | | if (res && res.status == "Ok") { |
| | | // 储存token |
| | | wx.setStorageSync(app.config.tokenKey, res.token); |
| | | // 记录登录统计 |
| | | setSessionGuid() |
| | | // 获取用户信息 |
| | | this.getUserInfo() |
| | | // 记录登录统计 |
| | | // setSessionGuid() |
| | | } else { |
| | | wx.showToast({ |
| | | icon: "error", |
| | |
| | | } |
| | | wx.setStorageSync(app.config.userInfoKey, JSON.stringify(defaultUser)); |
| | | } |
| | | wx.switchTab({ |
| | | wx.navigateTo({ |
| | | url: this.data.redirectPage ? this.data.redirectPage : '/pages/home/home' |
| | | }) |
| | | }); |
| | |
| | | // 获取二级分类 |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const item = res.datas[index]; |
| | | item.icon ? item.icon = getPublicImage(item.icon, 58, 72) : item.icon = item.icon |
| | | item.icon ? item.icon = getPublicImage(item.icon, 500) : item.icon = item.icon |
| | | item.children = await this.getSecondList(item); |
| | | } |
| | | console.log(res.datas); |
| | |
| | | field: 'state' |
| | | } |
| | | ], |
| | | coverSize: { |
| | | width: 500 |
| | | }, |
| | | queryType: '\\', |
| | | searchList: [], |
| | | size: '30', |
| | |
| | | for (let index = 0; index < res.datas.length; index++) { |
| | | const element = res.datas[index]; |
| | | if (element.icon) |
| | | element.icon = getPublicImage(element.icon, 58, 72) |
| | | element.icon = getPublicImage(element.icon, 500) |
| | | |
| | | } |
| | | datas = res.datas; |
| | |
| | | |
| | | .assort-img { |
| | | display: flex; |
| | | align-items: center; |
| | | width: 152rpx; |
| | | height: 186rpx; |
| | | box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, 0.16); |
| | |
| | | |
| | | // 首页测试登录功能,后续注释 |
| | | // 检查登录状态 |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | // 如果不是第一次登录,会执行回调 |
| | | if (data) { |
| | | // 登录成功,自动记录token和用户信息,并返回true |
| | | } else { |
| | | // 出现错误,返回false |
| | | } |
| | | }) |
| | | } else { |
| | | // 如果是第一次登录,会跳转至绑定用户信息页面,填写完用户信息后进行登录并储存token和用户信息,结束后跳转回当前页面(携带页面参数) |
| | | } |
| | | // const token = wx.getStorageSync(app.config.tokenKey) |
| | | // if (!token) { |
| | | // loginInfo(app, (data) => { |
| | | // // 如果不是第一次登录,会执行回调 |
| | | // if (data) { |
| | | // // 登录成功,自动记录token和用户信息,并返回true |
| | | // } else { |
| | | // // 出现错误,返回false |
| | | // } |
| | | // }) |
| | | // } else { |
| | | // // 如果是第一次登录,会跳转至绑定用户信息页面,填写完用户信息后进行登录并储存token和用户信息,结束后跳转回当前页面(携带页面参数) |
| | | // } |
| | | |
| | | this.init(); |
| | | }, |