浏览代码

极速生活圈考试初版

zhangyujun 3 年之前
父节点
当前提交
fc108721db

+ 1 - 1
src/api/modules/open.js

@@ -17,7 +17,7 @@ const open = {
     },
     lightingCombinationId(id) {
         return request({
-            url: "https://jpcj-admin1.zzxcx.net/twzd-admin/open-api/lighting/combination/list/" + id,
+            url: "https://jpcj-admin1.zzxcx.net/twzd-admin/open-api/lighting/combination/" + id,
             method: "GET",
         })
     },

+ 11 - 2
src/pages/lightMock/components/composeTopicsMask.vue

@@ -24,7 +24,7 @@
         <div
           @click="
             () => {
-              emit('before');
+              $emit('before');
               stopTopicsAudio();
             }
           "
@@ -36,7 +36,7 @@
         <div
           @click="
             () => {
-              emit('after');
+              $emit('after');
               stopTopicsAudio();
             }
           "
@@ -51,7 +51,16 @@
 
 <script>
 import composeTopicsMaskList from "./composeTopicsMaskList.vue";
+import utils from '@/utils/index'
 export default {
+  methods: {
+    stopTopicsAudio() {
+      const audio  = utils.wxUtils.getGlobAudio()
+      audio.pause()
+
+
+    },
+  },
   // setup(props, { emit }) {
   // 	let mid = ref(null);
   // 	onMounted(() => {

+ 46 - 0
src/pages/lightMock/components/composeTopicsMaskList.vue

@@ -20,6 +20,7 @@
 </template>
 
 <script>
+import utils from "@/utils/index";
 export default {
   // setup(props, { emit }) {
   // 	let listIndex = ref(-1);
@@ -70,8 +71,50 @@ export default {
     return {
       listIndex: -1,
       audioPlayTimer: 0,
+      audio: {},
     };
   },
+  methods: {
+    playNextAudio(duration, interval) {
+      console.log(duration, interval);
+
+      let that = this;
+
+      if (Array.isArray(this.list) && that.listIndex + 1 !== this.list.length) {
+        that.audio.play();
+        that.audio.offEnded();
+        that.audio.onEnded(() => {
+          setTimeout(() => {
+            if (
+              Array.isArray(this.list) &&
+              that.listIndex + 1 !== this.list.length
+            ) {
+              that.listIndex = that.listIndex + 1;
+              that.audio.src = that.list[that.listIndex].voice;
+              that.audio.play();
+            }
+          }, interval * 1000);
+        });
+      } else {
+        return;
+      }
+    },
+    selectItem(item, index) {
+      if (this.listIndex == index) {
+        this.audio.pause();
+        this.listIndex = -1;
+        clearTimeout(this.audioPlayTimer);
+      } else {
+        clearTimeout(this.audioPlayTimer);
+        this.listIndex = index;
+        this.audio.src = item.voice;
+        this.audio.play();
+        let interval = this.$store.state.user.lightConfig.interval;
+        let duration = this.audio.duration;
+        this.playNextAudio(duration, interval);
+      }
+    },
+  },
   props: {
     list: {
       type: Array,
@@ -91,6 +134,9 @@ export default {
       },
     },
   },
+  mounted() {
+    this.audio = utils.wxUtils.getGlobAudio();
+  },
 };
 </script>
 

+ 187 - 171
src/pages/lightMock/components/examTopicList.vue

@@ -4,7 +4,7 @@
       <span
         @click="
           () => {
-            emit('close');
+            $emit('close');
           }
         "
         class="close-text"
@@ -47,184 +47,200 @@
 </template>
 
 <script>
-import composeTopicsMaskList from './composeTopicsMaskList.vue'
+import composeTopicsMaskList from "./composeTopicsMaskList.vue";
+import utils from "@/utils/index";
+import api from "@/api/index";
 export default {
-	// setup(props, { emit }) {
-	// 	let mid = ref(null);
-	// 	const store = useStore();
-	// 	let randComlist = ref([]);
-	// 	let randComlistIndex = ref(0);
-	// 	let randSingleListList = ref(0);
-	// 	let randSingleList = ref([]);
-	// 	let type = store.state.lightConfig.type as number;
-	// 	let directives = store.state.lightConfig.directives;
-	// 	let newComList: lightingCombinationListResRow[];
-	// 	// onMounted(() => {
-	// 	// 	console.log(mid.value,"xx");
-	// 	// });
-	// 	let stopTopicsAudio = () => {
-	// 		if (mid) {
-	// 			console.log(mid);
-	// 			mid.value.pauseAudioLoop();
+  // setup(props, { emit }) {
+  // 	let mid = ref(null);
+  // 	const store = useStore();
+  // 	let randComlist = ref([]);
+  // 	let randComlistIndex = ref(0);
+  // 	let randSingleListList = ref(0);
+  // 	let randSingleList = ref([]);
+  // 	let type = store.state.lightConfig.type as number;
+  // 	let directives = store.state.lightConfig.directives;
+  // 	let newComList: lightingCombinationListResRow[];
+  // 	// onMounted(() => {
+  // 	// 	console.log(mid.value,"xx");
+  // 	// });
+  // 	let stopTopicsAudio = () => {
+  // 		if (mid) {
+  // 			console.log(mid);
+  // 			mid.value.pauseAudioLoop();
 
-	// 			mid.value.listIndex = -1;
-	// 		}
-	// 	};
-	// 	const nextGroup = () => {
-	// 		if (type == 0) {
-	// 			let copySingleList = [...props.singleList]
-	// 			randComlistIndex.value = randComlistIndex.value + 1;
-	// 			let arrEnd = copySingleList.pop();
-	// 			let arrBegin = copySingleList.shift();
-	// 			let arr = copySingleList.sort((a, b) => Math.random() - 0.5);
-	// 			let arrMid = arr.slice(0, directives);
-	// 			randSingleList.value = [arrBegin, ...arrMid, arrEnd];
-	// 		} else {
-	// 			if (randComlistIndex.value + 1 >= props.comList.length) {
-	// 				randComlistIndex.value = 0;
-	// 			} else {
-	// 				randComlistIndex.value = randComlistIndex.value + 1;
-	// 			}
-	// 			lightingCombinationId(newComList[randComlistIndex.value].id).then((res) => {
-	// 				randComlist.value = res.data;
-	// 			});
-	// 		}
-	// 	};
-	// 	watch(
-	// 		() => props.comList,
-	// 		(val, oldValue) => {
-	// 			if (type == 1) {
-	// 				console.log("辩护了");
-	// 				let arr = val?.sort((a, b) => Math.random() - 0.5);
-	// 				newComList = arr;
-	// 				if (arr && arr.length > 0) {
-	// 					lightingCombinationId(arr[randComlistIndex.value].id).then((res) => {
-	// 						randComlist.value = res.data;
-	// 					});
-	// 				}
-	// 			}
+  // 			mid.value.listIndex = -1;
+  // 		}
+  // 	};
+  // 	const nextGroup = () => {
+  // 		if (type == 0) {
+  // 			let copySingleList = [...props.singleList]
+  // 			randComlistIndex.value = randComlistIndex.value + 1;
+  // 			let arrEnd = copySingleList.pop();
+  // 			let arrBegin = copySingleList.shift();
+  // 			let arr = copySingleList.sort((a, b) => Math.random() - 0.5);
+  // 			let arrMid = arr.slice(0, directives);
+  // 			randSingleList.value = [arrBegin, ...arrMid, arrEnd];
+  // 		} else {
+  // 			if (randComlistIndex.value + 1 >= props.comList.length) {
+  // 				randComlistIndex.value = 0;
+  // 			} else {
+  // 				randComlistIndex.value = randComlistIndex.value + 1;
+  // 			}
+  // 			lightingCombinationId(newComList[randComlistIndex.value].id).then((res) => {
+  // 				randComlist.value = res.data;
+  // 			});
+  // 		}
+  // 	};
+  // 	watch(
+  // 		() => props.comList,
+  // 		(val, oldValue) => {
+  // 			if (type == 1) {
+  // 				console.log("辩护了");
+  // 				let arr = val?.sort((a, b) => Math.random() - 0.5);
+  // 				newComList = arr;
+  // 				if (arr && arr.length > 0) {
+  // 					lightingCombinationId(arr[randComlistIndex.value].id).then((res) => {
+  // 						randComlist.value = res.data;
+  // 					});
+  // 				}
+  // 			}
 
-	// 			/* ... */
-	// 		},
-	// 		{
-	// 			immediate: true,
-	// 		}
-	// 	);
+  // 			/* ... */
+  // 		},
+  // 		{
+  // 			immediate: true,
+  // 		}
+  // 	);
 
-	// 	watch(
-	// 		() => props.singleList,
-	// 		(val, oldValue) => {
-	// 			if (type == 0) {
-	// 				let copyVal = [...val]
-	// 				let arrEnd = copyVal.pop();
-	// 				let arrBegin =copyVal.shift();
-	// 				let arr = [...copyVal].sort((a, b) => Math.random() - 0.5);
-	// 				let arrMid = arr.slice(0, directives);
-	// 				arr = [arrBegin, ...arrMid, arrEnd];
-	// 				randSingleList.value = arr
-	// 			}
+  // 	watch(
+  // 		() => props.singleList,
+  // 		(val, oldValue) => {
+  // 			if (type == 0) {
+  // 				let copyVal = [...val]
+  // 				let arrEnd = copyVal.pop();
+  // 				let arrBegin =copyVal.shift();
+  // 				let arr = [...copyVal].sort((a, b) => Math.random() - 0.5);
+  // 				let arrMid = arr.slice(0, directives);
+  // 				arr = [arrBegin, ...arrMid, arrEnd];
+  // 				randSingleList.value = arr
+  // 			}
 
-	// 			/* ... */
-	// 		},
-	// 		{
-	// 			immediate: true,
-	// 		}
-	// 	);
+  // 			/* ... */
+  // 		},
+  // 		{
+  // 			immediate: true,
+  // 		}
+  // 	);
 
-	// 	return {
-	// 		nextGroup,
-	// 		randSingleListList,
-	// 		randSingleList,
-	// 		emit,
-	// 		randComlistIndex,
-	// 		props,
-	// 		randComlist,
-	// 		store,
-	// 		type,
-	// 		mid,
-	// 		directives,
-	// 		stopTopicsAudio,
-	// 	};
-	// },
-	data() {
-		return {
-			randComlist:[],
-			randComlistIndex:0,
-			randSingleListList:0,
-			randSingleList:[]
+  // 	return {
+  // 		nextGroup,
+  // 		randSingleListList,
+  // 		randSingleList,
+  // 		emit,
+  // 		randComlistIndex,
+  // 		props,
+  // 		randComlist,
+  // 		store,
+  // 		type,
+  // 		mid,
+  // 		directives,
+  // 		stopTopicsAudio,
+  // 	};
+  // },
+  data() {
+    return {
+      randComlist: [],
+      randSingleList: [],
+      randComlistIndex: 0,
+      randSingleListList: 0,
+      newComList: [],
+      audio: {},
+      type: Number(this.$store.state.user.lightConfig.type),
+      directives: Number(this.$store.state.user.lightConfig.directives),
+    };
+  },
+  methods: {
+    stopTopicsAudio: () => {
+      audio.pause();
+    },
+    createRandSingleList() {
+      let directives = this.$store.state.user.lightConfig.directives;
+      let singleList = [...this.singleList];
+      let end = singleList.pop();
+      let start = singleList.shift();
+      let mid = singleList.sort((a, b) => Math.random() - 0.5);
+      return [start, ...mid.slice(0, directives), end];
+    },
+    nextGroup() {
+      if (this.$store.state.user.lightConfig.type == 0) {
+        this.randSingleList = this.createRandSingleList();
+      } else {
+        if (this.randComlistIndex + 1 >= this.comList.length) {
+          this.randComlistIndex = 0;
+        } else {
+          this.randComlistIndex = this.randComlistIndex + 1;
+        }
 
+        api.open
+          .lightingCombinationId(this.newComList[this.randComlistIndex].id)
+          .then((res) => {
+            this.randComlist = res.data;
+          });
+      }
+    },
+  },
+  props: {
+    show: {
+      type: Boolean,
+      default: false,
+    },
+    title: {
+      type: String,
+      default: "",
+    },
+    comList: {
+      type: Array,
+      default: () => {
+        return [];
+      },
+    },
+    singleList: {
+      type: Array,
+      default: () => {
+        return [];
+      },
+    },
+  },
+  computed: {
+    comTitle() {
+      if (
+        this.comList &&
+        this.comList.length > 0 &&
+        this.randComlistIndex < this.comList.length
+      ) {
+        return this.comList[this.randComlistIndex].titile;
+      } else {
+        return "";
+      }
+    },
 
-		}
-	},
-	methods: {
-		stopTopicsAudio:() => {
-			if (mid) {
-				console.log(mid);
-				mid.value.pauseAudioLoop();
-
-				mid.value.listIndex = -1;
-			}
-		},
-		nextGroup :() => {
-			if (type == 0) {
-				let copySingleList = [...props.singleList]
-				randComlistIndex.value = randComlistIndex.value + 1;
-				let arrEnd = copySingleList.pop();
-				let arrBegin = copySingleList.shift();
-				let arr = copySingleList.sort((a, b) => Math.random() - 0.5);
-				let arrMid = arr.slice(0, directives);
-				randSingleList.value = [arrBegin, ...arrMid, arrEnd];
-			} else {
-				if (randComlistIndex.value + 1 >= props.comList.length) {
-					randComlistIndex.value = 0;
-				} else {
-					randComlistIndex.value = randComlistIndex.value + 1;
-				}
-				lightingCombinationId(newComList[randComlistIndex.value].id).then((res) => {
-					randComlist.value = res.data;
-				});
-			}
-		}
-	},
-	props: {
-		show: {
-			type: Boolean,
-			default: false,
-		},
-		title: {
-			type: String,
-			default: "",
-		},
-		comList: {
-			type: Array,
-			default: () => {
-				return [];
-			},
-		},
-		singleList: {
-			type: Array,
-			default: () => {
-				return [];
-			},
-		},
-	},
-	computed: {
-		comTitle() {
-			if (this.comList && this.comList.length > 0 && this.randComlistIndex < this.comList.length) {
-				return this.comList[this.randComlistIndex].titile;
-			} else {
-				return "";
-			}
-		},
-		// randComList():lightingCombinationListResRow[]{
-		// 	let arr = this.comList.sort((a, b) => Math.random() - 0.5);
-		// 	return arr
-		// }
-	},
-	components: {
-		composeTopicsMaskList,
-	},
-	mounted() {},
+    // randComList():lightingCombinationListResRow[]{
+    // 	let arr = this.comList.sort((a, b) => Math.random() - 0.5);
+    // 	return arr
+    // }
+  },
+  components: {
+    composeTopicsMaskList,
+  },
+  mounted() {
+    this.audio = utils.wxUtils.getGlobAudio();
+    this.randSingleList = this.createRandSingleList();
+    this.newComList = this.comList.sort((a, b) => Math.random() - 0.5);
+    api.open.lightingCombinationId(this.newComList[0].id).then((res) => {
+      this.randComlist = res.data;
+    });
+  },
 };
 </script>
 

+ 43 - 6
src/pages/lightMock/index.vue

@@ -10,10 +10,10 @@
       v-if="lightConfigVisible"
     ></lightConfig>
     <composeTopicsMask
-      v-if="composeTopicsVisible"
+      v-if="composeTopicsMaskVisible"
       @close="
         () => {
-          composeTopicsVisible = false;
+          composeTopicsMaskVisible = false;
         }
       "
       @before="selectBeforeCom"
@@ -80,7 +80,7 @@ export default {
     return {
       examTopicListVisible: false,
       lightConfigVisible: false,
-      composeTopicsVisible: false,
+      composeTopicsMaskVisible: false,
       list1Index: -1,
       timer: 0,
       active: 0,
@@ -115,9 +115,46 @@ export default {
     };
   },
   methods: {
-    selectCom() {
-		this.composeTopicsVisible=true
-	},
+    selectCom(item, index) {
+      this.composeTopicsMaskVisible = true;
+      this.list1Index = index;
+      this.composeTopicsMaskVisible = true;
+      this.singleTopicTitle = item.titile;
+      api.open.lightingCombinationId(item.id).then((res) => {
+        this.listItem = res.data;
+      });
+    },
+    selectBeforeCom() {
+      if (this.list1Index == 0) {
+        uni.showToast({
+          title: "已经到底了",
+          icon:"none"
+        });
+      } else {
+        this.list1Index = this.list1Index - 1;
+        let item = this.list1[this.list1Index];
+        this.singleTopicTitle = item.titile;
+        api.open.lightingCombinationId(item.id).then((res) => {
+          this.listItem = res.data;
+        });
+      }
+    },
+    selectAfterCom() {
+      if (this.list1Index == this.list1.length - 1) {
+        uni.showToast({
+          title: "已经到底了",
+           icon:"none"
+        });
+      } else {
+        this.list1Index = this.list1Index + 1;
+
+        let item = this.list1[this.list1Index];
+        this.singleTopicTitle = item.titile;
+        api.open.lightingCombinationId(item.id).then((res) => {
+          this.listItem = res.data;
+        });
+      }
+    },
   },
   mounted() {
     api.open.lightingCombinationList().then((res) => {

+ 4 - 0
src/utils/modules/wx.js

@@ -14,6 +14,10 @@ const wxUtils = {
 			}
 		}
 
+	},
+	//暂停语音
+	pauseGlobalAudio(){
+
 	},
 	//微信支付调起支付
 	wxPay(data) {