Picture.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <!-- -->
  2. <template>
  3. <div :class="['Big-Book-PictureBox']" v-if="curQue">
  4. <!-- <ul class="Big-Book-PictureBox-item" v-for="(item,index) in curQue.queList" :key="index"> -->
  5. <li v-for="(items,indexs) in curQue.option" :key="indexs">
  6. <template v-if="ChildType!='image_gdcy'&& items.hanziSite=='top'">
  7. <div class="hanzi-box hanzi-box-top" v-if="items.pinyin||items.hanzi">
  8. <span v-if="items.pinyin&&(!items.pinyinSite||items.pinyinSite=='top')" class="pinyin">{{items.pinyin}}</span>
  9. <p v-if="items.hanzi">{{items.hanzi}}</p>
  10. <span v-if="items.pinyin&&(items.pinyinSite=='bottom')" class="pinyin">{{items.pinyin}}</span>
  11. </div>
  12. </template>
  13. <div v-for="(itemss,indexss) in items.img_list" :key="indexss">
  14. <el-image
  15. :src="itemss.url"
  16. fit="scale-down"
  17. class="img_url"
  18. >
  19. <div slot="placeholder" class="image-slot">
  20. <img src="../../../assets/common/icon-imgloading.png" />
  21. </div>
  22. </el-image>
  23. </div>
  24. <template v-if="ChildType!='image_gdcy'&&(!items.hanziSite||items.hanziSite=='bottom')">
  25. <div class="hanzi-box" v-if="items.pinyin||items.hanzi">
  26. <span v-if="items.pinyin&&(!items.pinyinSite||items.pinyinSite=='top')" class="pinyin">{{items.pinyin}}</span>
  27. <p v-if="items.hanzi">{{items.hanzi}}</p>
  28. <span v-if="items.pinyin&&(items.pinyinSite=='bottom')" class="pinyin">{{items.pinyin}}</span>
  29. </div>
  30. </template>
  31. <template v-if="ChildType=='image_input'||ChildType=='image_input_three'||ChildType=='image_wordInput'">
  32. <input class="singleInput" v-model="userAnswer.input" placeholder="输入" @blur="handleInput('input')">
  33. </template>
  34. <!-- <input class="singleInput" placeholder="输入" @blur="handleInput(index,indexs)" v-if="fn_list_obj[index]&&fn_list_obj[index].indexOf('input')>-1"> -->
  35. <!-- 补齐输入 -->
  36. <template v-if="ChildType=='image_gdcy'">
  37. <div class="fill-box">
  38. <b v-if="items.hanzi">{{items.hanzi}}</b>
  39. <input v-model="userAnswer.input" placeholder="输入" @blur="handleInput('input')">
  40. </div>
  41. </template>
  42. <!-- 双输入 -->
  43. <template v-if="ChildType=='image_dobleinput'">
  44. <div class="DoubleInput-box">
  45. <input placeholder="输入" @blur="handleInput('dInput',0)" v-model="userAnswer.dInput[0]">
  46. <input placeholder="输入" @blur="handleInput('dInput',1)" v-model="userAnswer.dInput[1]">
  47. </div>
  48. </template>
  49. <!-- 判断 -->
  50. <template v-if="ChildType=='image_judge'">
  51. <div class="judge-box">
  52. <a :class="['right-btn',userAnswer.judge=='right'?'active':'']" @click="handleSelectJudge('right')"></a>
  53. <a :class="['error-btn',userAnswer.judge=='error'?'active':'']" @click="handleSelectJudge('error')"></a>
  54. </div>
  55. </template>
  56. <!-- 单选 -->
  57. <template v-if="ChildType=='image_single'">
  58. <el-radio v-model="userAnswer.singleRadio" label="1"><span></span></el-radio>
  59. </template>
  60. <!-- 复选 -->
  61. <template v-if="ChildType=='image_checkBox'">
  62. <el-checkbox v-model="userAnswer.singlechecked"><span></span></el-checkbox>
  63. </template>
  64. <!-- 三件套 -->
  65. <div class="luyinVoice-box" v-if="items.mp3_list.length>0||fn_list_obj&&fn_list_obj.indexOf('image_record')>-1||items.RecordControl">
  66. <template v-if="items.mp3_list.length>0">
  67. <span :class="['voice',mp3Play]" @click="playmicrophone(items.mp3_list[0].url,'mp3')"></span>
  68. </template>
  69. <Soundrecord @handleWav="handleWav" :type="items.RecordControl?items.RecordControl:'normal'" class="luyin-box" :class="[items.RecordControl]" v-if="fn_list_obj.indexOf('image_record')>-1||items.RecordControl"/>
  70. <!-- <span :class="['luyin',microphoneStatus?'active':'']" @click="microphone"></span>
  71. <span :class="['play',hasMicro]" @click="playmicrophone(wavblob)"></span> -->
  72. </div>
  73. </li>
  74. <!-- </ul> -->
  75. </div>
  76. </template>
  77. <script>
  78. import Soundrecord from "../preview/Soundrecord.vue"; // 录音模板
  79. import Recorder from "js-audio-recorder"; //录音插件
  80. export default {
  81. components: { Soundrecord, },
  82. props: ["curQue","ChildType"],
  83. data() {
  84. return {
  85. fn_list_obj: '',
  86. answer: [],
  87. userAnswer: {
  88. input:'', // 输入
  89. dInput: ['',''], //双输入
  90. judge:'',// 判断
  91. singleRadio:'',
  92. singlechecked: false,
  93. }, // 记录用户答题内容
  94. recorder: new Recorder({
  95. sampleBits: 16, // 采样位数,支持 8 或 16,默认是16
  96. sampleRate: 16000, // 采样率,支持 11025、16000、22050、24000、44100、48000,根据浏览器默认值,我的chrome是48000
  97. numChannels: 1, // 声道,支持 1 或 2, 默认是1
  98. }),
  99. microphoneStatus: false,
  100. hasMicro: "", // 录音后的样式class
  101. wavblob: null,
  102. audio: new window.Audio(),
  103. oldUrl: null, // 存储上个播放音频地址
  104. mp3Play: '',// 音频播放
  105. };
  106. },
  107. computed: {},
  108. watch: {},
  109. //方法集合
  110. methods: {
  111. handleFnList() {
  112. let obj = '';
  113. this.curQue.fn_list.forEach(node=>{
  114. if (node.isFn) {
  115. obj += node.type + ','
  116. }
  117. // if(obj.indexOf('input')>-1){
  118. // node.option.forEach((i)=>{
  119. // userItem.push('')
  120. // })
  121. // }
  122. // this.userAnswer.push(userItem)
  123. })
  124. this.fn_list_obj = obj
  125. },
  126. // 修改正确选项中得某一个为正确答案
  127. changAnswer(index, type) {
  128. if (type == "single") {
  129. console.log(this.answer);
  130. } else if (type == "checkBox") {
  131. let correct = [];
  132. this.curQue.option.forEach((item, i) => {
  133. if (item.isChecked) {
  134. correct.push(i);
  135. }
  136. });
  137. this.answer[0].checkBox = correct;
  138. console.log(this.answer);
  139. } else if (type == "judge") {
  140. console.log(this.answer);
  141. }
  142. },
  143. // 去掉前后空格
  144. handleInput(index,indexs){
  145. if(indexs||indexs==0){
  146. let res = this.userAnswer[index][indexs].trim()
  147. this.$set(this.userAnswer[index],indexs,res)
  148. }else{
  149. this.userAnswer[index] = this.userAnswer[index].trim()
  150. }
  151. },
  152. playmicrophone (url,type) {
  153. if(url){
  154. let _this = this;
  155. if (!this.audio.paused) {
  156. this.audio.pause();
  157. if(type=='mp3'){
  158. _this.mp3Play = ''
  159. }
  160. }else if( this.audio.paused && _this.oldUrl == url ){
  161. _this.audio.play();
  162. if(type=='mp3'){
  163. _this.mp3Play = 'active'
  164. }
  165. } else {
  166. _this.audio.pause();
  167. _this.audio.load();
  168. if(type=='mp3'){
  169. _this.mp3Play = 'active'
  170. _this.audio.src = url
  171. }
  172. _this.oldUrl = url
  173. _this.audio.play();
  174. }
  175. }
  176. },
  177. // 判断题选择
  178. handleSelectJudge(obj){
  179. this.userAnswer.judge = obj
  180. },
  181. handleWav(data) {
  182. this.userAnswer = []
  183. this.userAnswer.push(data)
  184. // this.getAnswer(this.userAnswer, this.queIndex);
  185. this.cur.BookWavAnswerWav = [data]
  186. },
  187. },
  188. //生命周期 - 创建完成(可以访问当前this实例)
  189. created() {},
  190. //生命周期 - 挂载完成(可以访问DOM元素)
  191. mounted() {
  192. if (this.curQue) {
  193. this.handleFnList();
  194. let obj = {
  195. single: [],
  196. checkBox: [],
  197. judge: [],
  198. input: [],
  199. spell: [],
  200. };
  201. this.answer.push(obj);
  202. }
  203. let _this = this;
  204. _this.audio.addEventListener("ended", function () {
  205. _this.mp3Play = ''
  206. _this.hasMicro = 'normal'
  207. });
  208. },
  209. beforeCreate() {}, //生命周期 - 创建之前
  210. beforeMount() {}, //生命周期 - 挂载之前
  211. beforeUpdate() {}, //生命周期 - 更新之前
  212. updated() {}, //生命周期 - 更新之后
  213. beforeDestroy() {}, //生命周期 - 销毁之前
  214. destroyed() {}, //生命周期 - 销毁完成
  215. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  216. };
  217. </script>
  218. <style lang='scss' scoped>
  219. //@import url(); 引入公共css类
  220. .Big-Book-PictureBox{
  221. width: 100%;
  222. margin-bottom: 16px;
  223. // &.PictureBoxFlex{
  224. // display: flex;
  225. // justify-content: space-between;
  226. // .Big-Book-PictureBox-item{
  227. // width: 384px;
  228. // }
  229. // }
  230. // .Big-Book-PictureBox-item{
  231. // list-style: none;
  232. // background: #F3F3F3;
  233. // border-radius: 8px;
  234. // padding: 16px;
  235. // margin: 0;
  236. // display: flex;
  237. // flex-flow: wrap;
  238. li{
  239. list-style: none;
  240. padding: 8px;
  241. border-radius: 8px;
  242. border: 1px solid rgba(0, 0, 0, 0.1);
  243. background: #fff;
  244. .hanzi-box{
  245. margin-top: 8px;
  246. &.hanzi-box-top{
  247. margin-top: 0px;
  248. margin-bottom: 8px;
  249. }
  250. >span.pinyin{
  251. display: block;
  252. text-align: center;
  253. font-family: 'GB-PINYINOK-B';
  254. font-size: 14px;
  255. line-height: 1.3;
  256. color: #000000;
  257. }
  258. >p{
  259. color: #000000;
  260. font-size: 16px;
  261. line-height: 150%;
  262. text-align: center;
  263. margin: 0;
  264. width: 100%;
  265. font-family: 'FZJCGFKTK';
  266. }
  267. }
  268. input{
  269. flex: 1;
  270. width: 100%;
  271. border: 1px solid rgba(0, 0, 0, 0.15);
  272. box-sizing: border-box;
  273. border-radius: 4px;
  274. outline: none;
  275. height: 32px;
  276. padding: 4px 8px;
  277. color: #000000;
  278. text-align: center;
  279. font-size: 16px;
  280. line-height: 150%;
  281. &.singleInput{
  282. margin-top: 8px;
  283. }
  284. }
  285. .luyinVoice-box{
  286. width: 100%;
  287. margin-top: 8px;
  288. display: flex;
  289. -ms-flex-pack: justify;
  290. align-items: center;
  291. span{
  292. width: 24px;
  293. height: 24px;
  294. background-position: center;
  295. background-repeat: no-repeat;
  296. background-size: 24px;
  297. margin-right: 8px;
  298. cursor: pointer;
  299. &:first-child{
  300. margin-left: 0px;
  301. }
  302. &.voice{
  303. background-image: url('../../../assets/newImage/common/icon-voice-red.png');
  304. }
  305. &.active {
  306. background-image: url('../../../assets/newImage/common/icon-voice-play-red.png');
  307. }
  308. // &.luyin{
  309. // background-image: url('../../../assets/newImage/common/luyin.png');
  310. // &.active {
  311. // background-image: url('../../../assets/newImage/common/luyin-active.png');
  312. // }
  313. // }
  314. // &.play{
  315. // background-image: url('../../../assets/newImage/common/luyin-play.png');
  316. // &.normal {
  317. // background-image: url('../../../assets/newImage/common/luyin-play-active.png');
  318. // }
  319. // &.stop {
  320. // background-image: url('../../../assets/newImage/common/luyin-play-stop.png');
  321. // }
  322. // }
  323. }
  324. .luyin-box{
  325. flex: 1;
  326. justify-content: start;
  327. padding: 0 12px;
  328. border: 1px solid rgba(0, 0, 0, 0.1);
  329. border-radius: 8px;
  330. &.mini{
  331. width: 64px;
  332. }
  333. &.normal{
  334. width:129px;
  335. }
  336. &.pro{
  337. width:200px;
  338. }
  339. &.promax{
  340. width:280px;
  341. }
  342. }
  343. }
  344. .fill-box{
  345. display: flex;
  346. align-items: center;
  347. margin-top: 8px;
  348. b{
  349. margin-right: 8px;
  350. color: #000000;
  351. font-weight: normal;
  352. font-size: 16px;
  353. }
  354. }
  355. .DoubleInput-box{
  356. display: flex;
  357. align-items: center;
  358. margin-top: 8px;
  359. >input:first-child{
  360. margin-right: 8px;
  361. }
  362. }
  363. .el-radio,.el-checkbox{
  364. width: 100%;
  365. margin: 8px 0 0;
  366. text-align: center;
  367. height: 32px;
  368. line-height: 32px;
  369. }
  370. .judge-box{
  371. margin-top: 8px;
  372. display: flex;
  373. justify-content: center;
  374. a{
  375. width: 70px;
  376. height: 32px;
  377. background: #F7F7F7 url('../../../assets/newImage/common/right-btn.png') center no-repeat;
  378. background-size: 24px;
  379. border-radius: 4px;
  380. border: 1px solid #F7F7F7;
  381. &:hover,&.active{
  382. background-color: #E5FFF0;
  383. border-color: #00C850;
  384. }
  385. }
  386. a.error-btn{
  387. background: #F7F7F7 url('../../../assets/newImage/common/error-btn.png') center no-repeat;
  388. background-size: 24px;
  389. margin-left: 4px;
  390. &:hover,&.active{
  391. background-color: #FFE5E5;
  392. border-color: #DE4444;
  393. }
  394. }
  395. }
  396. }
  397. .img_url{
  398. width: 100%;
  399. height: 128px;
  400. }
  401. // }
  402. }
  403. .NNPE-tableList-tr-last{
  404. .Big-Book-PictureBox{
  405. margin-bottom: 0;
  406. }
  407. }
  408. </style>
  409. <style lang="scss">
  410. ul,li{
  411. list-style: none;
  412. padding: 0;
  413. margin: 0;
  414. }
  415. .Big-Book-PictureBox{
  416. .el-checkbox__label,.el-radio__label{
  417. padding: 0;
  418. }
  419. }
  420. </style>