Ver código fonte

提示框样式修改

wyq 4 anos atrás
pai
commit
234281c2ea
2 arquivos alterados com 24 adições e 24 exclusões
  1. 17 4
      src/js/promise.js
  2. 7 20
      src/js/staticInfo.js

+ 17 - 4
src/js/promise.js

@@ -341,9 +341,22 @@ const titleConfigH = {
 const Toast = function (msg, duration) {
   duration = isNaN(duration) ? 3000 : duration;
   var m = document.createElement('div');
-  m.innerHTML = `<img class="warn" style="margin-right:14px" src=${warn}/>`+msg;
-  m.style.cssText = "display:flex;align-items:center;max-width:60%;min-width: 150px;padding:0 14px;height: 30px;color: #FFB609;line-height: 30px;text-align: center;border-radius: 4px;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);z-index: 999999;background: #FDF6EA;font-size: 16px;";
-  $('.warn').css('margin-top','10px')
+  m.innerHTML = msg;
+  m.style.cssText = "max-width:60%;min-width: 150px;padding:0 14px;height: 30px;color: #fff;line-height: 30px;text-align: center;border-radius: 4px;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);z-index: 999999;background: #333;font-size: 16px;";
+  document.body.appendChild(m);
+  setTimeout(function () {
+    var d = 0.5;
+    m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
+    m.style.opacity = '0';
+    setTimeout(function () { document.body.removeChild(m) }, d * 1000);
+  }, duration);
+}
+const Toasts = function (msg, duration) {
+  duration = isNaN(duration) ? 3000 : duration;
+  var m = document.createElement('div');
+  m.innerHTML = `<img class="warn" style="margin-right:14px" src=${warn}/>` + msg;
+  m.style.cssText = "display:flex;align-items:center;max-width:60%;min-width: 150px;padding:0 14px;height: 30px;color: #FFB609;line-height: 30px;text-align: center;border-radius: 4px;position: fixed;top: 75px;left: 50%;transform: translate(-50%, -50%);z-index: 999999;background: #FDF6EA;font-size: 16px;";
+  $('.warn').css('margin-top', '10px')
   document.body.appendChild(m);
   setTimeout(function () {
     var d = 0.5;
@@ -363,5 +376,5 @@ module.exports = {
   isIe8,
   titleConfig,
   titleConfigH,
-  Toast
+  Toast, Toasts 
 }

+ 7 - 20
src/js/staticInfo.js

@@ -15,7 +15,8 @@ const {
   config,
   getUrlArgObject,
   openNewWin,
-  Toast
+  Toast,
+  Toasts
 } = require('./promise.js');
 const $ = require("jquery");
 require("./jquery-migrate");
@@ -362,28 +363,14 @@ function getResult(pushInfo, textType) {
       if (pushInfo.length > 0) {
         for (var i = 0; i < pushInfo.length; i++) {
           if (pushInfo[i].content.max >= num && num >= pushInfo[i].content.min) {
-            console.log(pushInfo[i])
             if (tmp) {
-              if (num == 0) {
-                result = pushInfo[i].result + ';' + tmp
-              } else {
-                result = pushInfo[i].result + '(' + num + '分' + ')' + ';' + tmp
-                console.log(result)
-              }
+              result = pushInfo[i].result + '(' + num + '分' + ')' + ';' + tmp
             } else {
-              if (num == 0) {
-                result = pushInfo[i].result
-              } else {
-                result = pushInfo[i].result + '(' + num + '分' + ')'
-              }
+              result = pushInfo[i].result + '(' + num + '分' + ')'
             }
           } else {
             if (tmp) {
-              if (num == 0) {
-                console.log(123)
-                result = tmp
-              }
-              
+              result = tmp
             }
           }
         }
@@ -415,10 +402,10 @@ function getResult(pushInfo, textType) {
       }
 
     } else {
-      Toast('温馨提示:必填选项不能为空~', 500)
+      console.log(11)
+      Toasts('温馨提示:必填选项不能为空~', 5000000)
     }
   })
-
   $(".printing").hover(
     function () {
       $(".slideImg").attr("src", printing2);