123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- export default {
- namespaced: true,
- state: {
- paperInfo: null,
- fromSchoolId: null, // 归属学校id // 该参数通过二维码链接获取
- studentId: null,
- studentQuestionAnserList: [],
- examParams: null // 缓存考试页面试题及答案参数
- // userFormData: null // 缓存用户信息表单参数
- },
-
- getters: {
-
- getStudentQuestionAnserList: state => {
- if (state.studentQuestionAnserList.length > 0) {
- return state.studentQuestionAnserList
- }
- let studentQuestionAnserList = uni.getStorageSync('studentQuestionAnserList')
- if (studentQuestionAnserList) {
- return JSON.parse(studentQuestionAnserList)
- }
- return null
- },
-
- getExamParams: state => {
- if (state.examParams) {
- return state.examParams
- }
- let examParams = uni.getStorageSync('examParams')
- if (examParams) {
- return JSON.parse(examParams)
- }
- return null
- },
-
- getPaperInfo: state => {
- if (state.paperInfo) {
- return state.paperInfo
- }
- let paperInfo = uni.getStorageSync('paperInfo')
- if (paperInfo) {
- return JSON.parse(paperInfo)
- }
- return null
- },
-
- getStudentId: state => {
- if (state.studentId) {
- return state.studentId
- }
- let studentId = uni.getStorageSync('studentId')
- if (studentId) {
- return parseInt(JSON.parse(studentId))
- }
- return null
- },
-
- getFromSchoolId: state => {
- if (state.fromSchoolId) {
- return state.fromSchoolId
- }
- let fromSchoolId = uni.getStorageSync('fromSchoolId')
- if (fromSchoolId) {
- return parseInt(JSON.parse(fromSchoolId))
- }
- return null
- }
-
- },
-
- mutations: {
-
- updateStudentQuestionAnserList (state, data) {
- state.studentQuestionAnserList = data
- uni.setStorage({
- key: 'studentQuestionAnserList',
- data: JSON.stringify(studentQuestionAnserList)
- })
- },
-
- updatePaperInfo (state, data) {
- state.paperInfo = data
- uni.setStorage({
- key: 'paperInfo',
- data: JSON.stringify(data)
- })
- },
-
- updateStudentId (state, data) {
- state.studentId = data
- uni.setStorage({
- key: 'studentId',
- data: JSON.stringify(data)
- })
- },
-
- updateExamParams (state, data) {
- state.examParams = data
- uni.setStorage({
- key: 'examParams',
- data: JSON.stringify(data)
- })
- },
-
- updateFromSchoolId (state, data) {
- state.fromSchoolId = data
- uni.setStorage({
- key: 'fromSchoolId',
- data: JSON.stringify(data)
- })
- }
- }
- }
|