diff --git a/src/App.vue b/src/App.vue index 66d0241..d5e2358 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,17 +1,17 @@ - - - - - + + + + + diff --git a/src/components/itemcontainer.vue b/src/components/itemcontainer.vue index 1b7ad08..f7a8374 100644 --- a/src/components/itemcontainer.vue +++ b/src/components/itemcontainer.vue @@ -1,200 +1,200 @@ - - - - - + + + + + diff --git a/src/config/ajax.js b/src/config/ajax.js index f9f4202..004e0a4 100644 --- a/src/config/ajax.js +++ b/src/config/ajax.js @@ -1,44 +1,44 @@ -export default (type='GET', url='', data={}, async=true) => { - return new Promise((resolve, reject) => { //定义一个promise - type = type.toUpperCase(); - - let requestObj; - if (window.XMLHttpRequest) { - requestObj = new XMLHttpRequest(); - } else { - requestObj = new ActiveXObject; - } - - if (type == 'GET') { - let dataStr = ''; //数据拼接字符串 - Object.keys(data).forEach(key => { - dataStr += key + '=' + data[key] + '&'; - }) - dataStr = dataStr.substr(0, dataStr.lastIndexOf('&')); - url = url + '?' + dataStr; - requestObj.open(type, url, async); - requestObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); - requestObj.send(); - }else if (type == 'POST') { - requestObj.open(type, url, async); - requestObj.setRequestHeader("Content-type", "application/json"); - requestObj.send(JSON.stringify(data)); - }else { - reject('error type'); - } - - requestObj.onreadystatechange = () => { - if (requestObj.readyState == 4) { - if (requestObj.status == 200) { - let obj = requestObj.response - if (typeof obj !== 'object') { - obj = JSON.parse(obj); - } - resolve(obj); - }else { - reject(requestObj); - } - } - } - }) +export default (type='GET', url='', data={}, async=true) => { + return new Promise((resolve, reject) => { //定义一个promise + type = type.toUpperCase(); + + let requestObj; + if (window.XMLHttpRequest) { + requestObj = new XMLHttpRequest(); + } else { + requestObj = new ActiveXObject; + } + + if (type == 'GET') { + let dataStr = ''; //数据拼接字符串 + Object.keys(data).forEach(key => { + dataStr += key + '=' + data[key] + '&'; + }) + dataStr = dataStr.substr(0, dataStr.lastIndexOf('&')); + url = url + '?' + dataStr; + requestObj.open(type, url, async); + requestObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + requestObj.send(); + }else if (type == 'POST') { + requestObj.open(type, url, async); + requestObj.setRequestHeader("Content-type", "application/json"); + requestObj.send(JSON.stringify(data)); + }else { + reject('error type'); + } + + requestObj.onreadystatechange = () => { + if (requestObj.readyState == 4) { + if (requestObj.status == 200) { + let obj = requestObj.response + if (typeof obj !== 'object') { + obj = JSON.parse(obj); + } + resolve(obj); + }else { + reject(requestObj); + } + } + } + }) } \ No newline at end of file diff --git a/src/images/4-1.jpg b/src/images/4-1.jpg index 3599c7b..b1ecf79 100755 Binary files a/src/images/4-1.jpg and b/src/images/4-1.jpg differ diff --git a/src/images/4-4.png b/src/images/4-4.png index 6fddd70..824ca1f 100755 Binary files a/src/images/4-4.png and b/src/images/4-4.png differ diff --git a/src/main.js b/src/main.js index dfdf7ea..d45e71a 100644 --- a/src/main.js +++ b/src/main.js @@ -1,17 +1,17 @@ -import Vue from 'vue' -import VueRouter from 'vue-router' -import routes from './router/router' -import store from './store/' -import ajax from './config/ajax' -import './style/common' -import './config/rem' - -Vue.use(VueRouter) -const router = new VueRouter({ - routes -}) - -new Vue({ - router, - store, +import Vue from 'vue' +import VueRouter from 'vue-router' +import routes from './router/router' +import store from './store/' +import ajax from './config/ajax' +import './style/common' +import './config/rem' + +Vue.use(VueRouter) +const router = new VueRouter({ + routes +}) + +new Vue({ + router, + store, }).$mount('#app') \ No newline at end of file diff --git a/src/page/home/index.vue b/src/page/home/index.vue index a5ae943..0c6c2f5 100644 --- a/src/page/home/index.vue +++ b/src/page/home/index.vue @@ -1,25 +1,25 @@ - - - - - + + + + + diff --git a/src/page/item/index.vue b/src/page/item/index.vue index 612dff6..0412b3a 100644 --- a/src/page/item/index.vue +++ b/src/page/item/index.vue @@ -1,26 +1,26 @@ - - - - - + + + + + diff --git a/src/page/score/index.vue b/src/page/score/index.vue index 0fba57e..668b522 100644 --- a/src/page/score/index.vue +++ b/src/page/score/index.vue @@ -1,140 +1,140 @@ - - - - - + + + + + diff --git a/src/router/router.js b/src/router/router.js index cc0e5a0..651de8c 100644 --- a/src/router/router.js +++ b/src/router/router.js @@ -1,16 +1,16 @@ -import App from '../App' - -export default [{ - path: '/', - component: App, - children: [{ - path: '', - component: r => require.ensure([], () => r(require('../page/home')), 'home') - }, { - path: '/item', - component: r => require.ensure([], () => r(require('../page/item')), 'item') - }, { - path: '/score', - component: r => require.ensure([], () => r(require('../page/score')), 'score') - }] +import App from '../App' + +export default [{ + path: '/', + component: App, + children: [{ + path: '', + component: r => require.ensure([], () => r(require('../page/home')), 'home') + }, { + path: '/item', + component: r => require.ensure([], () => r(require('../page/item')), 'item') + }, { + path: '/score', + component: r => require.ensure([], () => r(require('../page/score')), 'score') + }] }] \ No newline at end of file diff --git a/src/store/action.js b/src/store/action.js index d119255..870b3a3 100644 --- a/src/store/action.js +++ b/src/store/action.js @@ -1,15 +1,15 @@ -import ajax from '../config/ajax' - -export default { - addNum({ commit, state }, id) { - //点击下一题,记录答案id,判断是否是最后一题,如果不是则跳转下一题 - commit('REMBER_ANSWER', id); - if (state.itemNum < state.itemDetail.length) { - commit('ADD_ITEMNUM', 1); - } - }, - //初始化信息 - initializeData({ commit }) { - commit('INITIALIZE_DATA'); - } +import ajax from '../config/ajax' + +export default { + addNum({ commit, state }, id) { + //点击下一题,记录答案id,判断是否是最后一题,如果不是则跳转下一题 + commit('REMBER_ANSWER', id); + if (state.itemNum < state.itemDetail.length) { + commit('ADD_ITEMNUM', 1); + } + }, + //初始化信息 + initializeData({ commit }) { + commit('INITIALIZE_DATA'); + } } \ No newline at end of file diff --git a/src/store/index.js b/src/store/index.js index 5a6d748..bb2f5c6 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,178 +1,215 @@ -import Vue from 'vue' -import Vuex from 'vuex' -import mutations from './mutations' -import actions from './action' -import ajax from '../config/ajax' - - -Vue.use(Vuex) - -const state = { - level: '第一周', //活动周数 - itemNum: 1, // 第几题 - allTime: 0, //总共用时 - timer: '', //定时器 - itemDetail: [{ - "topic_id": 20, - "active_topic_id": 4, - "type": "ONE", - "topic_name": "题目一", - "active_id": 1, - "active_title": "欢乐星期五标题", - "active_topic_phase": "第一周", - "active_start_time": "1479139200", - "active_end_time": "1482163200", - "topic_answer": [{ - "topic_answer_id": 1, - "topic_id": 20, - "answer_name": "答案aaaa", - "is_standard_answer": 0 - }, { - "topic_answer_id": 2, - "topic_id": 20, - "answer_name": "正确答案", - "is_standard_answer": 0 - }, { - "topic_answer_id": 3, - "topic_id": 20, - "answer_name": "答案cccc", - "is_standard_answer": 0 - }, { - "topic_answer_id": 4, - "topic_id": 20, - "answer_name": "答案dddd", - "is_standard_answer": 1 - }] - }, { - "topic_id": 21, - "active_topic_id": 4, - "type": "MORE", - "topic_name": "题目二", - "active_id": 1, - "active_title": "欢乐星期五标题", - "active_topic_phase": "第一周", - "active_start_time": "1479139200", - "active_end_time": "1482163200", - "topic_answer": [{ - "topic_answer_id": 5, - "topic_id": 21, - "answer_name": "答案A", - "is_standard_answer": 1 - }, { - "topic_answer_id": 6, - "topic_id": 21, - "answer_name": "答案B", - "is_standard_answer": 0 - }, { - "topic_answer_id": 7, - "topic_id": 21, - "answer_name": "正确答案", - "is_standard_answer": 0 - }, { - "topic_answer_id": 8, - "topic_id": 21, - "answer_name": "答案D", - "is_standard_answer": 0 - }] - }, { - "topic_id": 21, - "active_topic_id": 4, - "type": "MORE", - "topic_name": "题目三", - "active_id": 1, - "active_title": "欢乐星期五标题", - "active_topic_phase": "第一周", - "active_start_time": "1479139200", - "active_end_time": "1482163200", - "topic_answer": [{ - "topic_answer_id": 9, - "topic_id": 21, - "answer_name": "测试A", - "is_standard_answer": 1 - }, { - "topic_answer_id": 10, - "topic_id": 21, - "answer_name": "BBBBBB", - "is_standard_answer": 0 - }, { - "topic_answer_id": 11, - "topic_id": 21, - "answer_name": "CCCCCC", - "is_standard_answer": 0 - }, { - "topic_answer_id": 12, - "topic_id": 21, - "answer_name": "正确答案", - "is_standard_answer": 0 - }] - }, { - "topic_id": 21, - "active_topic_id": 4, - "type": "MORE", - "topic_name": "题目四", - "active_id": 1, - "active_title": "欢乐星期五标题", - "active_topic_phase": "第一周", - "active_start_time": "1479139200", - "active_end_time": "1482163200", - "topic_answer": [{ - "topic_answer_id": 13, - "topic_id": 21, - "answer_name": "正确答案", - "is_standard_answer": 1 - }, { - "topic_answer_id": 14, - "topic_id": 21, - "answer_name": "A是错的", - "is_standard_answer": 0 - }, { - "topic_answer_id": 15, - "topic_id": 21, - "answer_name": "D是对的", - "is_standard_answer": 0 - }, { - "topic_answer_id": 16, - "topic_id": 21, - "answer_name": "C说的不对", - "is_standard_answer": 0 - }] - }, { - "topic_id": 21, - "active_topic_id": 4, - "type": "MORE", - "topic_name": "题目五", - "active_id": 1, - "active_title": "欢乐星期五标题", - "active_topic_phase": "第一周", - "active_start_time": "1479139200", - "active_end_time": "1482163200", - "topic_answer": [{ - "topic_answer_id": 17, - "topic_id": 21, - "answer_name": "错误答案", - "is_standard_answer": 1 - }, { - "topic_answer_id": 18, - "topic_id": 21, - "answer_name": "正确答案", - "is_standard_answer": 0 - }, { - "topic_answer_id": 19, - "topic_id": 21, - "answer_name": "错误答案", - "is_standard_answer": 0 - }, { - "topic_answer_id": 20, - "topic_id": 21, - "answer_name": "错误答案", - "is_standard_answer": 0 - }] - }], - answerid: [], //答案id -} - -export default new Vuex.Store({ - state, - actions, - mutations +import Vue from 'vue' +import Vuex from 'vuex' +import mutations from './mutations' +import actions from './action' +import ajax from '../config/ajax' + + +Vue.use(Vuex) + +const state = { + level: 'Hello', //活动周数 + itemNum: 1, // 第几题 + allTime: 0, //总共用时 + timer: '', //定时器 + itemDetail: [{ + "topic_id": 20, + "active_topic_id": 4, + "type": "ONE", + "topic_name": "题目一", + "active_id": 1, + "active_title": "欢乐星期五标题", + "active_topic_phase": "第一周", + "active_start_time": "1479139200", + "active_end_time": "1482163200", + "topic_answer": [{ + "topic_answer_id": 1, + "topic_id": 20, + "answer_name": "答案aaaa", + "is_standard_answer": 0 + }, { + "topic_answer_id": 2, + "topic_id": 20, + "answer_name": "正确答案", + "is_standard_answer": 0 + }, { + "topic_answer_id": 3, + "topic_id": 20, + "answer_name": "答案cccc", + "is_standard_answer": 0 + }, { + "topic_answer_id": 4, + "topic_id": 20, + "answer_name": "答案dddd", + "is_standard_answer": 1 + }] + }, { + "topic_id": 21, + "active_topic_id": 4, + "type": "MORE", + "topic_name": "题目二", + "active_id": 1, + "active_title": "欢乐星期五标题", + "active_topic_phase": "第一周", + "active_start_time": "1479139200", + "active_end_time": "1482163200", + "topic_answer": [{ + "topic_answer_id": 5, + "topic_id": 21, + "answer_name": "答案A", + "is_standard_answer": 1 + }, { + "topic_answer_id": 6, + "topic_id": 21, + "answer_name": "答案B", + "is_standard_answer": 0 + }, { + "topic_answer_id": 7, + "topic_id": 21, + "answer_name": "正确答案", + "is_standard_answer": 0 + }, { + "topic_answer_id": 8, + "topic_id": 21, + "answer_name": "答案D", + "is_standard_answer": 0 + }] + }, { + "topic_id": 21, + "active_topic_id": 4, + "type": "MORE", + "topic_name": "题目三", + "active_id": 1, + "active_title": "欢乐星期五标题", + "active_topic_phase": "第一周", + "active_start_time": "1479139200", + "active_end_time": "1482163200", + "topic_answer": [{ + "topic_answer_id": 9, + "topic_id": 21, + "answer_name": "测试A", + "is_standard_answer": 1 + }, { + "topic_answer_id": 10, + "topic_id": 21, + "answer_name": "BBBBBB", + "is_standard_answer": 0 + }, { + "topic_answer_id": 11, + "topic_id": 21, + "answer_name": "CCCCCC", + "is_standard_answer": 0 + }, { + "topic_answer_id": 12, + "topic_id": 21, + "answer_name": "正确答案", + "is_standard_answer": 0 + }] + }, { + "topic_id": 21, + "active_topic_id": 4, + "type": "MORE", + "topic_name": "题目四", + "active_id": 1, + "active_title": "欢乐星期五标题", + "active_topic_phase": "第一周", + "active_start_time": "1479139200", + "active_end_time": "1482163200", + "topic_answer": [{ + "topic_answer_id": 13, + "topic_id": 21, + "answer_name": "正确答案", + "is_standard_answer": 1 + }, { + "topic_answer_id": 14, + "topic_id": 21, + "answer_name": "A是错的", + "is_standard_answer": 0 + }, { + "topic_answer_id": 15, + "topic_id": 21, + "answer_name": "D是对的", + "is_standard_answer": 0 + }, { + "topic_answer_id": 16, + "topic_id": 21, + "answer_name": "C说的不对", + "is_standard_answer": 0 + }] + }, { + "topic_id": 21, + "active_topic_id": 4, + "type": "MORE", + "topic_name": "题目五", + "active_id": 1, + "active_title": "欢乐星期五标题", + "active_topic_phase": "第一周", + "active_start_time": "1479139200", + "active_end_time": "1482163200", + "topic_answer": [{ + "topic_answer_id": 17, + "topic_id": 21, + "answer_name": "错误答案", + "is_standard_answer": 1 + }, { + "topic_answer_id": 18, + "topic_id": 21, + "answer_name": "正确答案", + "is_standard_answer": 0 + }, { + "topic_answer_id": 19, + "topic_id": 21, + "answer_name": "错误答案", + "is_standard_answer": 0 + }, { + "topic_answer_id": 20, + "topic_id": 21, + "answer_name": "错误答案", + "is_standard_answer": 0 + }] + }, + + { + "topic_id": 21, + "active_topic_id": 4, + "type": "MORE", + "topic_name": "题目六", + "active_id": 1, + "active_title": "欢乐星期五标题", + "active_topic_phase": "第一周", + "active_start_time": "1479139200", + "active_end_time": "1482163200", + "topic_answer": [{ + "topic_answer_id": 21, + "topic_id": 21, + "answer_name": "答案A", + "is_standard_answer": 1 + }, { + "topic_answer_id": 22, + "topic_id": 21, + "answer_name": "答案B", + "is_standard_answer": 0 + }, { + "topic_answer_id": 23, + "topic_id": 21, + "answer_name": "我才是答案", + "is_standard_answer": 0 + }, { + "topic_answer_id": 24, + "topic_id": 21, + "answer_name": "答案D", + "is_standard_answer": 0 + }] + }, + + + +], + answerid: [], //答案id +} + +export default new Vuex.Store({ + state, + actions, + mutations }) \ No newline at end of file diff --git a/src/store/mutations.js b/src/store/mutations.js index 0483fcc..cc6d55f 100644 --- a/src/store/mutations.js +++ b/src/store/mutations.js @@ -1,30 +1,30 @@ -const ADD_ITEMNUM = 'ADD_ITEMNUM' -const REMBER_ANSWER = 'REMBER_ANSWER' -const REMBER_TIME = 'REMBER_TIME' -const INITIALIZE_DATA = 'INITIALIZE_DATA' -export default { - //点击进入下一题 - [ADD_ITEMNUM](state, num) { - state.itemNum += num; - }, - //记录答案 - [REMBER_ANSWER](state, id) { - state.answerid.push(id); - }, - /* - 记录做题时间 - */ - [REMBER_TIME](state) { - state.timer = setInterval(() => { - state.allTime++; - }, 1000) - }, - /* - 初始化信息, - */ - [INITIALIZE_DATA](state) { - state.itemNum = 1; - state.allTime = 0; - state.answerid = []; - }, +const ADD_ITEMNUM = 'ADD_ITEMNUM' +const REMBER_ANSWER = 'REMBER_ANSWER' +const REMBER_TIME = 'REMBER_TIME' +const INITIALIZE_DATA = 'INITIALIZE_DATA' +export default { + //点击进入下一题 + [ADD_ITEMNUM](state, num) { + state.itemNum += num; + }, + //记录答案 + [REMBER_ANSWER](state, id) { + state.answerid.push(id); + }, + /* + 记录做题时间 + */ + [REMBER_TIME](state) { + state.timer = setInterval(() => { + state.allTime++; + }, 1000) + }, + /* + 初始化信息, + */ + [INITIALIZE_DATA](state) { + state.itemNum = 1; + state.allTime = 0; + state.answerid = []; + }, } \ No newline at end of file diff --git a/src/style/common.less b/src/style/common.less index 8b438a4..3e42590 100644 --- a/src/style/common.less +++ b/src/style/common.less @@ -1,63 +1,63 @@ -body, div, span, header, footer, nav, section, aside, article, ul, dl, dt, dd, li, a, p, h1, h2, h3, h4,h5, i, b, textarea, button, input, select { - padding: 0; - margin: 0; - list-style: none; - font-style: normal; - text-decoration: none; - border: none; - color: #313131; - box-sizing: border-box; - font-weight: lighter; - font-family: 'Microsoft YaHei'; - -webkit-tap-highlight-color:transparent; - &:focus { - outline: none; - } -} - - -html{ - height: 100%; - width: 100%; -} -body{ - height: 100%; - width: 100%; - background: url(../images/1-1.jpg) no-repeat; - background-size: 100% 100%; -} - -.clear:after{ - content: ''; - display: block; - clear: both; -} - -.clear{ - zoom:1; -} - -.back_img{ - background-repeat: no-repeat; - background-size: 100% 100%; -} - -.margin{ - margin: 0 auto; -} - -.left{ - float: left; -} - -.right{ - float:right; -} - -.hide{ - display: none; -} - -.show{ - display: block; -} +body, div, span, header, footer, nav, section, aside, article, ul, dl, dt, dd, li, a, p, h1, h2, h3, h4,h5, i, b, textarea, button, input, select { + padding: 0; + margin: 0; + list-style: none; + font-style: normal; + text-decoration: none; + border: none; + color: #313131; + box-sizing: border-box; + font-weight: lighter; + font-family: 'Microsoft YaHei'; + -webkit-tap-highlight-color:transparent; + &:focus { + outline: none; + } +} + + +html{ + height: 100%; + width: 100%; +} +body{ + height: 100%; + width: 100%; + background: url(../images/1-1.jpg) no-repeat; + background-size: 100% 100%; +} + +.clear:after{ + content: ''; + display: block; + clear: both; +} + +.clear{ + zoom:1; +} + +.back_img{ + background-repeat: no-repeat; + background-size: 100% 100%; +} + +.margin{ + margin: 0 auto; +} + +.left{ + float: left; +} + +.right{ + float:right; +} + +.hide{ + display: none; +} + +.show{ + display: block; +}