12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- let filterData = (arr1, arr2) => {
- let map = {};
- for (let i = 0; i < arr1.length; i++) {
- if (arr1[i]) {
- map[arr1[i].question_id] = arr1[i].answer
- }
- }
- return arr2.map((item) => {
- for (let i = 0; i < item.answer.length; i++) {
- const value = item.answer[i];
- const va = map[item.id]
- // console.log(va)
- if (va) {
- // const maparr = map[item.question_id]
- for (let j = 0; j < va.length; j++) {
- if (va[j].key == value.key) {
- value.checked = 1;
- }
- }
- }
- }
- return item
- })
- }
- let examDjsFn = (examSurplusTime) => {
- let timer = null;
- let time = examSurplusTime * 1000
- timer = setInterval(() => {
- let m, s
- if (time >= 0) {
- m = Math.floor(time / 1000 / 60 % 60);
- s = Math.floor(time / 1000 % 60);
- m = m < 10 ? ('0' + m) : m;
- s = s < 10 ? ('0' + s) : s;
- let duration = m + ':' + s;
- console.log(duration)
- // that.setData({
- // duration: duration
- // })
-
- time = time - 1000
- return duration
- } else {
- clearInterval(timer);
- return '00:00'
- }
- }, 1000);
- }
- export default {
- filterData,
- examDjsFn
- };
|