analysis.js
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-01-31 15:41:18
* @LastEditors: yangming qianduan01@didihu.com.cn
* @LastEditTime: 2023-02-21 16:04:57
* @FilePath: \h5Demo\src\mixins\analysis.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
export default {
props: {
dataObject: {
type: Object,
},
popupState: {
type: Boolean,
default: true,
},
finishNum: {
type: Number,
},
},
inject: ["countdown"],
data() {
return {
memberList: [], //成员列表
isEnd: false, //是否结束
timer: null,
answerData: {
body: {
size: null,
currentSize: null,
timeLimit: null,
rightNum: null,
question: null,
choice: [],
},
},
};
},
watch: {
// 监听服务器返回的数据变化
dataObject(newData) {
// if (this.dataObject.command == 3 && this.dataObject.body.type == 4) {
// this.$store.commit("setGameType", "");
// }
// 答题动作
GPJSSDK.Game.knowAction({
// 原始数据
data: newData,
// 状态
status: (info) => {},
// 游戏开始倒计时
start: (duration) => {
clearInterval(this.timer);
this.duration = duration || newData.body.timeLimit;
this.timer = setInterval(() => {
this.duration--;
if (this.duration <= 0) return clearInterval(this.timer);
}, 1000);
},
// 游戏结束,并初始化数据
end: () => {
clearInterval(this.timer);
this.isEnd = true;
// this.$store.commit("setGameType", "");
},
});
},
},
methods: {
clearTimeLimit() {
clearInterval(this.timer);
},
},
};