Kaynağa Gözat

Merge branch 'pre' of http://git.dgtis.com/sunlupeng/pointsMall

sunlupeng 1 yıl önce
ebeveyn
işleme
12573f67f4

+ 1 - 0
package.json

@@ -10,6 +10,7 @@
   "dependencies": {
     "axios": "0.17.1",
     "core-js": "^3.8.3",
+    "crypto-js": "4.1.1",
     "element-china-area-data": "^6.0.2",
     "element-ui": "^2.15.12",
     "js-cookie": "2.2.0",

+ 66 - 0
src/utils/AES.js

@@ -0,0 +1,66 @@
+import CryptoJS from 'crypto-js'
+const keyStr = '1234567890123456'
+export default {
+  // 加密
+  encrypt(word) {
+    // 判断是否存在keyStr,不存在就用默认的keyStr(注意:这个keyStr必需要前后端统一,不然双方加密解密后会不相同。调用generatekey方法生成)
+    // keyStr = keyStr ? keyStr : '1grLx91U40VawzhRAm7E'
+    const key = CryptoJS.enc.Utf8.parse(keyStr)
+    const srcs = CryptoJS.enc.Utf8.parse(word)
+    const encrypted = CryptoJS.AES.encrypt(srcs, key, {
+      mode: CryptoJS.mode.ECB,
+      padding: CryptoJS.pad.Pkcs7
+    })
+    return encrypted.toString()
+  },
+  // AES的ECB加密(还有CBC模式)
+  encryptECB(word) {
+    // 这里是密钥
+    var keyHex = CryptoJS.enc.Utf8.parse(keyStr)
+    // 这里是demo样本 一些是json,
+    // var plaintText = "{'a':'SSS'}"
+    // 一些是string
+    var plaintText = word
+
+    // 用ECB进行加密
+    var encryptedData = CryptoJS.AES.encrypt(
+      // JSON.stringify(plaintText),
+      plaintText,
+      keyHex,
+      {
+        // iv: CryptoJS.enc.Utf8.parse('0000000000000000'), // 16位
+        mode: CryptoJS.mode.ECB, // 加密模式
+        padding: CryptoJS.pad.Pkcs7
+      })
+    // 打印出加密后的
+    // console.log(encryptedData.toString(), '加密后')
+    return encryptedData.toString();
+  },
+
+  // 解密
+  decrypt(word) {
+    // 这里是密钥
+    var keyHex = CryptoJS.enc.Utf8.parse(keyStr)
+    // 这里需要将16进制的数据转为base64
+    // var encryptedBase64Str = CryptoJS.enc.Hex.parse(word)
+    // // console.log('解密前Base64:' + encryptedBase64Str)
+    // var str = CryptoJS.enc.Base64.stringify(encryptedBase64Str)
+    // console.log("str=",str)
+    // 接下来就是解密了,讲最后Base64形式的进行解密
+    var decryptedData = CryptoJS.AES.decrypt(
+      word,
+      keyHex,
+      {
+        // iv: CryptoJS.enc.Hex.parse('0000000000000000'), // 16位
+        mode: CryptoJS.mode.ECB, // 加密模式
+        padding: CryptoJS.pad.Pkcs7
+      }
+    )
+    return CryptoJS.enc.Utf8.stringify(decryptedData).toString()
+    // console.log("decryptedData=",decryptedData)
+    // 这里会产生制表符需要清除掉(如果解密后数据少于16位会以空格补齐)
+    // return decryptedData.toString(CryptoJS.enc.Utf8).replace(/\0/g, '')
+  },
+
+
+}

+ 10 - 4
src/views/HomeView/AnswerGame/AnswerGame.vue

@@ -19,7 +19,7 @@
                                     <span style="text-align: center;">{{ questions[itemNum].ask }}</span>
                                 </div>
                                 <div class="content animated" :class="animate_showChoice" v-if="animate_showChoice">
-                                    <div v-for="(item,index) in questions[itemNum].answers" :key="index"  class="answerItem" :class="index == clickIndex ? answerColor : ''" @click="answer(item,index)">
+                                    <div v-for="(item,index) in questions[itemNum].answers" :key="index"  class="answerItem" :class="[index == clickIndex ? answerColor : '' , item.right ? rightAnswer : '']" @click="answer(item,index)">
                                         <span>{{ item.answer }}</span>
                                         <img v-if="index == clickIndex&&answerColor=='error'" class="invisible" src="@/assets/image/answerGame/item/error.png" alt="错误">
                                         <img v-if="index == clickIndex&&answerColor=='right'" class="invisible" style="width: 25px;" src="@/assets/image/answerGame/item/right.png" alt="正确">
@@ -64,6 +64,7 @@
 </template>
 <script>
 import { homeData,questionList,submitAnswer } from "@/api/allApi";
+import AES from "@/utils/AES.js";
 import SiderInfo from '@/components/SiderInfo.vue';
 import { mapGetters } from 'vuex';
 export default{
@@ -72,6 +73,7 @@ export default{
   },
   data() {
     return {
+        rightAnswer:'',
         actId:this.$route.query.actId,
         roomId:'',
         rule:'',
@@ -114,9 +116,11 @@ export default{
     },
     getQuestionList(){
         questionList({}).then(response=>{
-                console.log(response.data.data);
-                this.questions = response.data.data.questions;
-                this.roomId = response.data.data.roomId;
+                //解密
+                let resData = JSON.parse(AES.decrypt(response.data.data));
+                console.log(resData);
+                this.questions = resData.questions;
+                this.roomId = resData.roomId;
                 this.timerCountdown();
                 this.isShowItem = true;
             })
@@ -163,12 +167,14 @@ export default{
                 this.answerColor = 'right';
             }else{
                 this.answerColor = 'error';
+                this.rightAnswer = 'right';
             }
             this.localClick = true;
             setTimeout(() => {
                 this.result.push(val.answer);
                 this.clickIndex = -1;
                 this.answerColor = '';
+                this.rightAnswer = '';
                 this.animate_showChoice = 'fadeOut';
                 if(this.itemNum==4){
                     clearInterval(this.timer);

+ 24 - 10
src/views/HomeView/postInteract/detail.vue

@@ -15,26 +15,26 @@
                     <div class="quesList">
                         <div class="listItem" v-for="(item, index) in dataList" :key="index">
                             <div v-if="item.type == 'SCQ'">
-                                <div class="itemTitle">{{ index + 1 }}. {{ item.description }}(单选)</div>
-                                <el-radio-group v-model="item.comment">
-                                    <el-radio :disabled="data.interactUserStatus == null?false:true" v-for="(childItem, childIndex) in item.options" :key="childIndex"
+                                <div class="itemTitle">{{ index + 1 }}. {{ item.description }}<el-tag size="small" type="danger"> 单选</el-tag></div>
+                                <el-radio-group v-model="item.comment" class="flex-column">
+                                    <el-radio class="myRadio" :disabled="data.interactUserStatus == 0?false:true" v-for="(childItem, childIndex) in item.options" :key="childIndex"
                                         :label="childItem.id">{{ childItem.name }}</el-radio>
                                 </el-radio-group>
                             </div>
 
                             <div v-if="item.type == 'MCQ'">
-                                <div class="itemTitle">{{ index + 1 }}. {{ item.description }}(多选)</div>
-                                <el-checkbox-group v-model="item.comment">
-                                    <el-checkbox :disabled="data.interactUserStatus == null?false:true" v-for="(childItem, childIndex) in item.options" :key="childIndex"
+                                <div class="itemTitle">{{ index + 1 }}. {{ item.description }}<el-tag size="small" type="danger"> 多选</el-tag></div>
+                                <el-checkbox-group v-model="item.comment" class="flex-column">
+                                    <el-checkbox class="myRadio" :disabled="data.interactUserStatus == 0?false:true" v-for="(childItem, childIndex) in item.options" :key="childIndex"
                                         :label="childItem.id">{{ childItem.name }}</el-checkbox>
                                 </el-checkbox-group>
                             </div>
                             <div v-if="item.type == 'SAQ'">
-                                <div class="itemTitle">{{ index + 1 }}. {{ item.description }}(问答)</div>
-                                <el-input :disabled="data.interactUserStatus == null?false:true" type="textarea" :rows="4" placeholder="请输入内容" v-model="item.comment"></el-input>
+                                <div class="itemTitle">{{ index + 1 }}. {{ item.description }}<el-tag size="small" type="danger"> 问答</el-tag></div>
+                                <el-input :disabled="data.interactUserStatus == 0?false:true" type="textarea" :rows="4" placeholder="请输入内容" v-model="item.comment"></el-input>
                             </div>
                         </div>
-                        <div v-if="data.interactUserStatus == null" class="footBut">
+                        <div v-if="data.interactUserStatus == 0" class="footBut">
                             <el-button style="width: 200px;" type="primary" @click="save()">提交</el-button>
                         </div>
 
@@ -118,16 +118,29 @@ export default {
                 let questions = response.data.data.data;
                 questions.forEach(item => {
                     if (item.type == "MCQ") {
-                        item.comment = [];
+                        if (item.comment) {
+                            item.comment = item.comment.split(',');
+                        }else{
+                            item.comment = [];
+                        }
                     }
                 });
                 this.dataList = questions;
+                console.log(this.dataList);
             }).catch(() => { })
         },
     },
 }
 </script>
 <style scoped>
+.myRadio{
+    margin: 10px !important;
+}
+.flex-column{
+    display: flex;
+    flex-flow: column nowrap;
+    align-items: flex-start;
+}
 .footBut {
     display: flex;
     flex-direction: column;
@@ -145,6 +158,7 @@ export default {
 
 .itemTitle {
     margin-bottom: 10px;
+    font-weight: 700;
 }
 
 .userInfo {

+ 4 - 2
src/views/HomeView/postInteract/list.vue

@@ -14,7 +14,9 @@
                                     {{ item.typeName }}
                                 </div> 
                                 <div class="dividing"></div> 
-                                <div class="date">{{ item.createTime }}</div>
+                                <div class="date">
+                                    <el-tag type="danger" effect="plain" size="small">{{ item.deadline }}</el-tag>
+                                </div>
                             </div>
                             <div class="main">
                                 <div class="info-box">
@@ -25,7 +27,7 @@
                                         {{ item.content }}
                                     </div>
                                 </div> 
-                                <img v-if="item.imgUrl" :src="item.imgUrl" :alt="item.title" class="lazy thumb">
+                                <img v-if="item.media" :src="item.media" :alt="item.title" class="lazy thumb">
                             </div>
                         </div>
                     </div>

+ 5 - 0
yarn.lock

@@ -2672,6 +2672,11 @@ cross-spawn@^7.0.2, cross-spawn@^7.0.3:
     shebang-command "^2.0.0"
     which "^2.0.1"
 
+crypto-js@4.1.1:
+  version "4.1.1"
+  resolved "https://registry.npmmirror.com/crypto-js/-/crypto-js-4.1.1.tgz#9e485bcf03521041bd85844786b83fb7619736cf"
+  integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==
+
 css-declaration-sorter@^6.3.1:
   version "6.3.1"
   resolved "https://registry.npmmirror.com/css-declaration-sorter/-/css-declaration-sorter-6.3.1.tgz#be5e1d71b7a992433fb1c542c7a1b835e45682ec"