高伟民 1 year ago
parent
commit
000e285785

+ 35 - 18
src/views/dw-survey/dw-sugar/DwSugarItem.vue

@@ -12,7 +12,7 @@
               <el-form>
                 <el-row>
                   <el-col :span="16">
-                    <h5>奖品条目<span style="color: red;">(总概率数不要超过100%)</span><span></span></h5>
+                    <h5>奖品条目<span style="color: red;">(总概率数不要超过100%)</span><span style="color: #0000cc">当前概率:{{ pr() }}</span></h5>
                     <div style="padding-left: 10px;">
                       <el-form-item v-for="(item, index) in survey.sugarItems" :key="index">
                         <el-input v-model="item.name" placeholder="奖品名称" style="width: 160px;"></el-input>
@@ -55,7 +55,13 @@ export default {
         sugarItems: []
       },
       group: this.$route.params.id,
-      pr: 0
+      pr: function () {
+        let pr = 0
+        this.survey.sugarItems.forEach(element => {
+          pr += Number(element.pr)
+        })
+        return pr.toFixed(2)
+      }
     }
   },
   watch: {
@@ -72,31 +78,35 @@ export default {
           this.survey.sugarItems.push(element)
         })
       })
-      /* console.log(this.survey.sugarItems.length)
-      if (this.survey.sugarItems.length === 0) {
-      } */
     },
     addSugarItem () {
-      this.survey.sugarItems.push({
-        name: '',
-        alias: '',
-        pr: '',
-        img: '',
-        remove: 1
-      })
+      if (this.survey.sugarItems.length < 10) {
+        this.survey.sugarItems.push({
+          name: '',
+          alias: '',
+          pr: '',
+          img: '',
+          remove: 1
+        })
+      } else {
+        this.$message({type: 'error', message: '奖品条目数量过多,请删减后重试!'})
+      }
     },
     removeSugarItem (index) {
-      if (this.survey.sugarItems[index].remove === 0) {
-        this.$message({type: 'error', message: '概率范围设置异常!'})
-        return
-      }
       this.survey.sugarItems.splice(index, 1)
     },
     computePr (now_pr, $event) {
     },
     onSubmit () {
+      if (this.pr() > 100) {
+        this.$message({type: 'error', message: '总概率总概率不能超过100!'})
+        return false
+      }
+      if (this.survey.sugarItems.filter(o => { return o.pr === '' }).length > 0) {
+        this.$message({type: 'error', message: '奖品概率不能为空,请检查后重试!'})
+        return false
+      }
       dwSurveySugarItemsSave(this.survey.sugarItems, this.group).then((response) => {
-        console.log(response)
         const data = response.data
         if (data.resultCode === 200) {
           this.$message({type: 'success', message: '保存成功'})
@@ -106,7 +116,14 @@ export default {
       })
     },
     findRouletteIndex () {
-      alert('http://localhost:8080/static/roulette/index.html?sugarGroup=' + this.group)
+      // // 获取当前页面地址,如http://localhost:8080/admin/index
+      // const wPath = window.document.location.href
+      // // 获取当前页面主机地址之后的目录,如:/admin/index
+      // const pathName =  this.$route.path
+      // const pos = wPath.indexOf(pathName)
+      // // 获取主机地址,如:http://localhost:8080
+      // const localhostPath = wPath.substring(0, pos)
+      alert('http://localhost:8080/static/roulette/index.html')
     }
   }
 }

+ 1 - 4
static/diaowen/answer-m.html

@@ -42,9 +42,6 @@
       <div  class="noLogoImg" style="padding-top: 5px;">
         <div  class="dwSvyName" >用户信息</div>
       </div>
-      <div id="dwSurveyNote" style="text-align: left;">
-        <div id="dwSurveyNoteEdit"  style="font-weight: normal;line-height: 20px;">加载中</div>
-      </div>
     </div>
   </div>
   <div>
@@ -65,7 +62,7 @@
         <td>
           <input type="text" id="userPhone" style="width:200px;padding:5px;border-radius: 5px;
           border-color: #efeaea;">
-          <div class="errorItem" hidden><label for="" class="error"></label></div>  
+          <div class="errorItem" hidden><label for="" class="error"></label></div>
         </td>
       </tr>
     </tbody></table>

+ 56 - 0
static/diaowen/answer-p.html

@@ -31,6 +31,60 @@
   </script>
 </head>
 <body>
+<div id="wrap2" style="position: absolute; height: 100%; width: 100%; z-index: 100; background-color: white;">
+  <div >
+    <div style="text-align: center;margin: 0px 16px; color: #365f8f;
+        font-weight: bold;
+        letter-spacing: 2px;
+        text-align: center;
+        font-size: 22px;
+        padding: 10px 0px;">
+      <div  class="noLogoImg" style="padding-top: 5px;">
+        <div  class="dwSvyName" >用户信息</div>
+      </div>
+    </div>
+  </div>
+  <div>
+    <table class="mFillblankTable" style="padding: 20px;
+    border-spacing: 20px;
+    border-collapse: separate;">
+      <tbody><tr class="mFillblankTableTr">
+        <td align="right" class="mFillblankTableEditTd quOption_0"><label class="editAble quCoOptionEdit" style="color: #848181;">姓名</label></td>
+        <td>
+          <input type="text" id="userName" style="width:200px;padding:5px;border-radius: 5px;
+          border-color: #efeaea;">
+          <div class="errorItem" hidden><label for="" class="error"></label></div>
+        </td>
+      </tr>
+      <tr class="mFillblankTableTr">
+        <td align="right" class="mFillblankTableEditTd quOption_1"><label class="editAble quCoOptionEdit" style="color: #848181;">手机号码</label>
+        </td>
+        <td>
+          <input type="text" id="userPhone" style="width:200px;padding:5px;border-radius: 5px;
+          border-color: #efeaea;">
+          <div class="errorItem" hidden><label for="" class="error"></label></div>
+        </td>
+      </tr>
+      </tbody></table>
+  </div>
+  <div class="surveyQuItemContent" style="margin-bottom: 0px;min-height:20px; padding:20px 60px; ">
+    <input type="button" id="submitUserInfo" value="继续" data-theme="b" style="background: -webkit-gradient(linear, 0 0, 0 bottom, from(dodgerblue), to(dodgerblue));idth: 100%;
+    line-height: 25px;
+    border-radius: 3px;
+    padding: 8px 0px;
+    margin-left: 0px;width: 100%;
+    line-height: 25px;
+    border-radius: 2px;
+    padding: 8px 0px;
+    margin-left: 0px;
+    font-size: 16px;
+    text-decoration: none;
+    color: white;
+    background: #1e94fc;
+    border: none;
+    background: #4F8BFF;" />
+  </div>
+</div>
 <div id="wrap">
   <div id="preview_head_top" style='text-align: center;background: #aaa;padding: 10px;color: #f3f3f3;display: none;'>当前为预览模式</div>
   <input type="hidden" id="id" name="id" value="">
@@ -47,6 +101,8 @@
     <input type="hidden" id="surveyId" name="surveyId" value="${survey.id }">
     <input type="hidden" id="ruleCode" name="ruleCode" value="">
     <input type="hidden" id="surveyLogId" name="surveyLogId" value="${survey.surveyLogId }">
+    <input type="hidden" id="sUserName" name="answerName" value="">
+    <input type="hidden" id="sUserPhone" name="answerPhone" value="">
     <div id="dw_body" style="padding-top:10px;">
       <div id="dw_body_content">
         <div id="dwSurveyHeader">

+ 1 - 1
static/diaowen/js/dw/an/ans-m-data.js

@@ -77,7 +77,7 @@ function parseSurvey(data){
     }
   }
 
-  if (data.surveyDetail.needUserInfo === 1) {
+  if (data.surveyDetail.needUserInfo === 1 && !$("#preview_head_top")[0]) {
     $('#wrap2').show();
   }
 

+ 5 - 2
static/diaowen/js/dw/an/ans-p-data.js

@@ -80,9 +80,12 @@ function parseSurvey(data,tag){
       // window.location.href="/static/diaowen/diaowen-message.html?sid="+data.sid+"&respType=1";
     }
   }
-  if (data.surveyDetail.needUserInfo === 1) {
-    
+  if (data.surveyDetail.needUserInfo === 1 && !$("#preview_head_top")[0]) {
+    $('#wrap2').show();
+  } else {
+    $('#wrap2').hide();
   }
+
   $("#id").val(data.id);
   $("#surveyId").val(data.id);
   $("#dwSurveyName").html(data.surveyName);

+ 26 - 0
static/diaowen/js/dw/an/ans-p.js

@@ -332,6 +332,32 @@ function sww() {
     return result;
   }
 
+  $('#submitUserInfo').click(function () {
+    let userName = $('#userName').val()
+    let userPhone = $('#userPhone').val()
+
+    if (!userName) {
+      $('#userName').next().find('label').text('姓名为必填项!')
+      $('#userName').next().show(100)
+    } else {
+      $('#userName').next().hide(100)
+    }
+
+    if (!userPhone) {
+      $('#userPhone').next().find('label').text('手机号码为必填项!')
+      $('#userPhone').next().show(100)
+    } else {
+      $('#userPhone').next().hide(100)
+    }
+
+    if (userName && userPhone) {
+      $('#sUserName').val(userName)
+      $('#sUserPhone').val(userPhone)
+
+      $('#wrap2').slideUp(1000)
+    }
+  })
+
 
   function checkoutData(checkType, value) {
     var validateStatus = true;

+ 2 - 2
static/diaowen/js/dw/an/msg.js

@@ -46,10 +46,10 @@ function resultStatus2Msg(resptype,sid,ruleCode) {
     tempMsg.resultNote = '不在本次调研范围内,无法作答!';
     tempMsg.resultColor = "#e70f0f";
   }else if(resptype==='23'){
-    tempMsg.resultNote = '该问卷需要填写答卷人信息!';
+    tempMsg.resultNote = '超过单个IP答卷次数限制';
     tempMsg.resultColor = "#e70f0f";
   }else if(resptype==='101'){
-    tempMsg.resultNote = '超过单个IP答卷次数限制!';
+    tempMsg.resultNote = '该问卷需要填写答卷人信息!';
     tempMsg.resultColor = "#e70f0f";
   }else if(resptype==='110'){
     tempMsg.resultNote = '超过单个手机号答卷次数限制!';