js_ryl 1.0.19 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -181,6 +181,7 @@
181
181
  #1.0.17: 添加 数据补全方法 如:table中有数据为空时,自动补全 ‘--’ 符号
182
182
  #1.0.18: 添加 获取当前年份中,指定月份的天数
183
183
  #1.0.19: 验证手机号码 优化
184
+ #1.0.21: number精度问题优化
184
185
  ```
185
186
 
186
187
  For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader).
package/dist/build.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("js_ryl",[],e):"object"==typeof exports?exports.js_ryl=e():t.js_ryl=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=1)}([function(t,e,n){"use strict";var r={throole:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=0;return function(){var r=this,o=Date.now();o-n>e&&(t.call(r,arguments),n=o)}},debounce:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=null;return function(){var r=arguments,o=this;clearTimeout(n),n=setTimeout(function(){t.apply(o,r)},e)}}};e.a=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(2),o=n(3),i=n(4),a=n(0),u=n(5),c=n(6),l=n(7),s=n(8),f=n(9),d=n(10);e.default={reg:r.a,time:o.a,cookie:i.a,fun:a.a,num:u.a,copy:c.a,deepCopy:l.a,verCode:s.a,filterTable:f.a,getMonthDays:d.a}},function(t,e,n){"use strict";var r={Phone:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入手机号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"手机号码格式有误",r=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;return t?!!r.test(t)||n:e},Email:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入邮箱",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"邮箱格式有误",r=/^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;return t?!!r.test(t)||n:e},IdCard:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入身份证号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"身份证号码格式有误",r=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;return t?!!r.test(t)||n:e},Common:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入包含数字、字母以及下划线的内容",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"只能包含数字、字母以及下划线",r=/^[a-zA-Z0-9_]+$/;return t?!!r.test(t)||n:e},QQ:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入QQ号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"QQ号码格式错误",r=/^[1-9][0-9]{4,10}$/gim;return t?!!r.test(t)||n:e},Money:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入金额(最多保留2位小数点)",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"金额格式错误",r=/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;return t?!!r.test(t)||n:e}};e.a=r},function(t,e,n){"use strict";function r(t){return t<10?"0"+t:t}var o={toDate:function(t,e){var n="";n=10==String(t).length?new Date(1e3*t):new Date(t);var o=n.getFullYear(),i=n.getMonth()+1,a=n.getDate(),u=n.getHours(),c=n.getMinutes(),l=n.getSeconds();return"yyyy-MM-dd"==e?o+"-"+r(i)+"-"+r(a):"yyyy-MM-dd HH:mm"==e?o+"-"+r(i)+"-"+r(a)+" "+r(u)+":"+r(c):o+"-"+r(i)+"-"+r(a)+" "+r(u)+":"+r(c)+":"+r(l)},toStamp:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=new Date(t.replace(/-/g,"/")).getTime().toString();return 10==e&&(n=n.substr(0,10)),parseInt(n)},getNow:function(){var t=(new Date).getTime();return o.toDate(t)}};e.a=o},function(t,e,n){"use strict";var r={set:function(t,e,n){n=n||{};var r=n.path?";Path="+n.path:"",o=n.domain?";domain="+n.domain:"",i="";if(n.expires){i=";expires="+(10==String(n.expires).length?new Date(1e3*n.expires):new Date(n.expires)).toGMTString()}document.cookie=t+"="+encodeURIComponent(e)+o+r+i},get:function(t){var e="; "+document.cookie,n=e.split("; "+t+"=");return 2===n.length?decodeURIComponent(n.pop().split(";").shift()):null},remove:function(t,e){e=e||{},e.expires=-1,r.set(t,null,e)}};e.a=r},function(t,e,n){"use strict";var r=(n(0),function(t){var e=0;try{t=Number(t);var n=t.toString().toUpperCase();if(2===n.split("E").length){var r=!1;2===n.split(".").length&&(n=n.split(".")[1],0!==parseInt(n.split("E")[0])&&(r=!0));var o=n.split("E");r&&(e=o[0].length),e-=parseInt(o[1])}else 2===n.split(".").length&&0!==parseInt(n.split(".")[1])&&(e=n.split(".")[1].length)}catch(t){throw t}finally{return(isNaN(e)||e<0)&&(e=0),e}}),o=function(t){t=Number(t);var e=r(t),n=t.toString().toUpperCase();return 2===n.split("E").length?Math.round(t*Math.pow(10,e)):Number(n.replace(".",""))},i=function(t,e,n,r){var o=0;switch(t){case"add":o=e+n;break;case"sub":o=e-n;break;case"div":o=e/n;break;case"mul":o=e*n}return Math.abs(r-o)>1?o:r},a={NumFilter:function(t){var e=String(t).indexOf(".")+1,n=String(t).length-e;return n>0&&n>=3&&(t=Math.floor(100*t)/100),t},add:function(t,e){t=this.NumFilter(Number(t)),e=this.NumFilter(Number(e));var n,o,a;try{n=r(t)+1}catch(t){n=0}try{o=r(e)+1}catch(t){o=0}a=Math.pow(10,Math.max(n,o));var u=(this.mul(t,a)+this.mul(e,a))/a;return i("add",t,e,u)},sub:function(t,e){t=this.NumFilter(Number(t)),e=this.NumFilter(Number(e));var n,o,a;try{n=r(t)+1}catch(t){n=0}try{o=r(e)+1}catch(t){o=0}a=Math.pow(10,Math.max(n,o));var u=Number((this.mul(t,a)-this.mul(e,a))/a);return i("sub",t,e,u)},div:function(t,e){t=Number(t),e=Number(e);var n,a,u=0,c=0;try{u=r(t)}catch(t){}try{c=r(e)}catch(t){}n=o(t),a=o(e);var l=this.mul(n/a,Math.pow(10,c-u));return i("div",t,e,l)},mul:function(t,e){t=Number(t),e=Number(e);var n=0,a=t.toString(),u=e.toString();try{n+=r(a)}catch(t){}try{n+=r(u)}catch(t){}var c=o(a)*o(u)/Math.pow(10,n);return i("mul",t,e,c)}};e.a=a},function(t,e,n){"use strict";function r(t,e){var n=document.createElement("input");n.setAttribute("readonly","readonly"),n.setAttribute("value",t),document.body.appendChild(n),document.execCommand("copy")?(n.select(),document.execCommand("copy"),e({code:200,msg:"复制成功"})):e({code:100,msg:"当前浏览器不支持,请更换浏览器后重试"}),document.body.removeChild(n)}e.a=r},function(t,e,n){"use strict";function r(t,e){var n=t||{};for(var i in e)"object"===o(e[i])?(n[i]=e[i].constructor===Array?[]:{},r(n[i],e[i])):n[i]=e[i];return n}e.a=r;var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t}},function(t,e,n){"use strict";var r=!1,o=null,i="",a=null,u={PhoneCode:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"后重新获取";if(i=t.target.innerText,a=t,!r){r=!0,t.target.innerText=n-1+"s"+u;var c=n-1;o=setInterval(function(){c--,c<=0?(t.target.innerText=i,e.PhoneCodeClear()):t.target.innerText=c+"s"+u},1e3)}},PhoneCodeClear:function(){r=!1,a&&(a.target.innerText=i),clearInterval(o)},phoneCodeStatus:function(){return r}};e.a=u},function(t,e,n){"use strict";function r(t){return["",void 0,null].some(function(e){return e===t})}var o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--",n=[];for(var o in t){for(var i={},a=Object.entries(t[o]),u=0;u<a.length;u++){var c=a[u];r(c[1])&&(c[1]=e),i[c[0]]=c[1]}n.push(i)}return n};e.a=o},function(t,e,n){"use strict";var r=function(t,e){return new Date(t,e,0).getDate()};e.a=r}])});
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("js_ryl",[],e):"object"==typeof exports?exports.js_ryl=e():t.js_ryl=e()}("undefined"!=typeof self?self:this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/dist/",e(e.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),o=n(2),i=n(3),a=n(4),u=n(5),c=n(6),l=n(7),s=n(8),f=n(9),d=n(10);e.default={reg:r.a,time:o.a,cookie:i.a,fun:a.a,num:u.a,copy:c.a,deepCopy:l.a,verCode:s.a,filterTable:f.a,getMonthDays:d.a}},function(t,e,n){"use strict";var r={Phone:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入手机号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"手机号码格式有误",r=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;return t?!!r.test(t)||n:e},Email:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入邮箱",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"邮箱格式有误",r=/^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;return t?!!r.test(t)||n:e},IdCard:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入身份证号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"身份证号码格式有误",r=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;return t?!!r.test(t)||n:e},Common:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入包含数字、字母以及下划线的内容",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"只能包含数字、字母以及下划线",r=/^[a-zA-Z0-9_]+$/;return t?!!r.test(t)||n:e},QQ:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入QQ号码",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"QQ号码格式错误",r=/^[1-9][0-9]{4,10}$/gim;return t?!!r.test(t)||n:e},Money:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"请输入金额(最多保留2位小数点)",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"金额格式错误",r=/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;return t?!!r.test(t)||n:e}};e.a=r},function(t,e,n){"use strict";function r(t){return t<10?"0"+t:t}var o={toDate:function(t,e){var n="";n=10==String(t).length?new Date(1e3*t):new Date(t);var o=n.getFullYear(),i=n.getMonth()+1,a=n.getDate(),u=n.getHours(),c=n.getMinutes(),l=n.getSeconds();return"yyyy-MM-dd"==e?o+"-"+r(i)+"-"+r(a):"yyyy-MM-dd HH:mm"==e?o+"-"+r(i)+"-"+r(a)+" "+r(u)+":"+r(c):o+"-"+r(i)+"-"+r(a)+" "+r(u)+":"+r(c)+":"+r(l)},toStamp:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,n=new Date(t.replace(/-/g,"/")).getTime().toString();return 10==e&&(n=n.substr(0,10)),parseInt(n)},getNow:function(){var t=(new Date).getTime();return o.toDate(t)}};e.a=o},function(t,e,n){"use strict";var r={set:function(t,e,n){n=n||{};var r=n.path?";Path="+n.path:"",o="";if(n.domain&&"domain"==n.domain){o=";domain="+window.location.hostname.split(".").slice(-2).join(".")}var i="";if(n.expires){i=";expires="+(10==String(n.expires).length?new Date(1e3*n.expires):new Date(n.expires)).toGMTString()}document.cookie=t+"="+encodeURIComponent(e)+o+r+i},get:function(t){var e="; "+document.cookie,n=e.split("; "+t+"=");return 2===n.length?decodeURIComponent(n.pop().split(";").shift()):null},remove:function(t,e){e=e||{},e.expires=-1,r.set(t,null,e)}};e.a=r},function(t,e,n){"use strict";var r={throole:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=0;return function(){var r=this,o=Date.now();o-n>e&&(t.call(r,arguments),n=o)}},debounce:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=null;return function(){var r=arguments,o=this;clearTimeout(n),n=setTimeout(function(){t.apply(o,r)},e)}}};e.a=r},function(t,e,n){"use strict";function r(t){return Math.floor(100*t)===100*t}var o=function(t){var e=0;try{t=Number(t);var n=t.toString().toUpperCase();if(2===n.split("E").length){var r=!1;2===n.split(".").length&&(n=n.split(".")[1],0!==parseInt(n.split("E")[0])&&(r=!0));var o=n.split("E");r&&(e=o[0].length),e-=parseInt(o[1])}else 2===n.split(".").length&&0!==parseInt(n.split(".")[1])&&(e=n.split(".")[1].length)}catch(t){throw t}finally{return(isNaN(e)||e<0)&&(e=0),e}},i=function(t){t=Number(t);var e=o(t),n=t.toString().toUpperCase();return 2===n.split("E").length?Math.round(t*Math.pow(10,e)):Number(n.replace(".",""))},a=function(t,e,n,o){var i=0;switch(t){case"add":i=e+n;break;case"sub":i=e-n;break;case"div":i=e/n;break;case"mul":i=e*n}return Math.abs(o-i)>1?i:(r(o)||(o=Number(o.toFixed(2))),o)},u={NumFilter:function(t){var e=String(t).indexOf(".")+1,n=String(t).length-e;return n>0&&n>=3&&(t=Math.floor(100*t)/100),t},add:function(t,e){t=this.NumFilter(Number(t)),e=this.NumFilter(Number(e));var n,r,i;try{n=o(t)+1}catch(t){n=0}try{r=o(e)+1}catch(t){r=0}i=Math.pow(10,Math.max(n,r));var u=(this.mul(t,i)+this.mul(e,i))/i;return a("add",t,e,u)},sub:function(t,e){t=this.NumFilter(Number(t)),e=this.NumFilter(Number(e));var n,r,i;try{n=o(t)+1}catch(t){n=0}try{r=o(e)+1}catch(t){r=0}i=Math.pow(10,Math.max(n,r));var u=Number((this.mul(t,i)-this.mul(e,i))/i);return a("sub",t,e,u)},div:function(t,e){t=Number(t),e=Number(e);var n,r,u=0,c=0;try{u=o(t)}catch(t){}try{c=o(e)}catch(t){}n=i(t),r=i(e);var l=this.mul(n/r,Math.pow(10,c-u));return a("div",t,e,l)},mul:function(t,e){t=Number(t),e=Number(e);var n=0,r=t.toString(),u=e.toString();try{n+=o(r)}catch(t){}try{n+=o(u)}catch(t){}var c=i(r)*i(u)/Math.pow(10,n);return a("mul",t,e,c)}};e.a=u},function(t,e,n){"use strict";function r(t,e){var n=document.createElement("input");n.setAttribute("readonly","readonly"),n.setAttribute("value",t),document.body.appendChild(n),document.execCommand("copy")?(n.select(),document.execCommand("copy"),e({code:200,msg:"复制成功"})):e({code:100,msg:"当前浏览器不支持,请更换浏览器后重试"}),document.body.removeChild(n)}e.a=r},function(t,e,n){"use strict";function r(t,e){var n=t||{};for(var i in e)"object"===o(e[i])?(n[i]=e[i].constructor===Array?[]:{},r(n[i],e[i])):n[i]=e[i];return n}e.a=r;var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t}},function(t,e,n){"use strict";var r=!1,o=null,i="",a=null,u={PhoneCode:function(t){var e=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"后重新获取";if(i=t.target.innerText,a=t,!r){r=!0,t.target.innerText=n-1+"s"+u;var c=n-1;o=setInterval(function(){c--,c<=0?(t.target.innerText=i,e.PhoneCodeClear()):t.target.innerText=c+"s"+u},1e3)}},PhoneCodeClear:function(){r=!1,a&&(a.target.innerText=i),clearInterval(o)},phoneCodeStatus:function(){return r}};e.a=u},function(t,e,n){"use strict";function r(t){return["",void 0,null].some(function(e){return e===t})}var o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--",n=[];for(var o in t){for(var i={},a=Object.entries(t[o]),u=0;u<a.length;u++){var c=a[u];r(c[1])&&(c[1]=e),i[c[0]]=c[1]}n.push(i)}return n};e.a=o},function(t,e,n){"use strict";var r=function(t,e){return new Date(t,e,0).getDate()};e.a=r}])});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js_ryl",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "private": false,
5
5
  "description": "自定义通用js",
6
6
  "author": "renyuliang <785788909@qq.com>",
package/src/App.vue CHANGED
@@ -1,3 +1,185 @@
1
- <template>
2
- <div id="app"></div>
3
- </template>
1
+ <template>
2
+ <div id="app">
3
+ <input
4
+ type="text"
5
+ id="input"
6
+ v-model="name"
7
+ @blur="inputBlur"
8
+ @keydown="inputsLk({id:'11',name:'实力坑爹'},12123)"
9
+ />
10
+ <button @click="getCookie">点击</button>
11
+ <div
12
+ style="height: 300px; border: 1px solid red; overflow-y: auto"
13
+ @scroll="initScroll"
14
+ >
15
+ <div style="height: 800px">滚动区域</div>
16
+ </div>
17
+ <button @click="copyCli()">Copy</button>
18
+ <br />
19
+ <br>
20
+ <br>
21
+ <!-- <button @click="phoneCode($event)">验证码</button> -->
22
+ <a href="javascript:;" @click="phoneCode($event)">验证码</a>
23
+ <a href="javascript:;" @click="phoneCodeExit()">清空验证码</a>
24
+ <br>
25
+ <br>
26
+ <ul>
27
+ <li v-for="(item,index) in list" :key="index">
28
+ <span>{{item.name}}</span>
29
+ <span>{{item.age}}</span>
30
+ <span>{{item.sex}}</span>
31
+ </li>
32
+ </ul>
33
+ </div>
34
+ </template>
35
+ <script>
36
+ import reg from "./reg";
37
+ import time from "./time";
38
+ import cookie from "./cookie";
39
+ import fun from "./function";
40
+ import num from "./number";
41
+ import copy from "./copy";
42
+ import deepCopy from "./deepCopy";
43
+ import verCode from "./verCode";
44
+ import filterTable from "./filterTable";
45
+ import getMonthDays from "./getMonthDays";
46
+ export default {
47
+ data() {
48
+ return {
49
+ name: "",
50
+ list: [
51
+ {
52
+ name:'d',
53
+ age:99,
54
+ sex:'男'
55
+ },
56
+ {
57
+ name:null,
58
+ age:'',
59
+ sex: '女'
60
+ },
61
+ {
62
+ name:'hf',
63
+ age:1,
64
+ sex:''
65
+ },
66
+ ]
67
+ };
68
+ },
69
+ // directives: {
70
+ // LazyLoad,
71
+ // },
72
+ mounted() {
73
+ this.list = filterTable(this.list)
74
+ console.log(time.toStamp("2021-06-02 18:17:02"), "当前时间戳");
75
+ console.log(time.toDate(1622623502), "当前时间");
76
+ console.log(time.getNow(), "系统当前时间");
77
+ cookie.set("test1", "abcde", {
78
+ path: "/device",
79
+ expires: 1622882702,
80
+ });
81
+ cookie.set("test2", "abcdefghi", { expires: 1622623502 });
82
+ setTimeout(() => {
83
+ console.log(cookie.get("test2"));
84
+ }, 1000);
85
+ setTimeout(() => {
86
+ cookie.remove("test2");
87
+ }, 3000);
88
+ document.onscroll = fun.throole(function () {
89
+ console.log("触发了几次了" + Date.now());
90
+ }, 200);
91
+ // let arr = [729.396, 72.6353, 6.3343, 1.1695];
92
+ let arr = [729.6986, 72.6, 6.119, 23.03,0.502];
93
+ let arr2 = arr.reduce((pre, next) => {
94
+ return pre + next;
95
+ });
96
+ let arr3 = arr.reduce((v, n) => {
97
+ return num.add(v, n);
98
+ });
99
+
100
+
101
+ console.log(arr2,'22');
102
+ console.log(arr3,'33');
103
+ console.log(num.add(3.29555556,2.63),'+');
104
+ console.log(num.sub(0.51653, 0.306),'-');
105
+ console.log(num.mul(0.33, 0.3231),'*');
106
+ console.log(num.div(0.893, 0.3),typeof num.div(0.893, 0.3),'/');
107
+
108
+
109
+ let obj = {
110
+ name: '张三',
111
+ age:12,
112
+ info: {
113
+ sex: '男',
114
+ like: ['电影','游戏']
115
+ }
116
+ }
117
+ let obj2 = deepCopy({},obj)
118
+ obj2.age = 18
119
+ obj2.info.sex = '女'
120
+ obj2.info.like = ['耍']
121
+ console.log(obj2,obj,'深拷贝后的值变化')
122
+
123
+ let arr00 = [1,2,3,4,5]
124
+ let arr002 = deepCopy([],arr00)
125
+ arr002[0]=111
126
+ console.log(arr002,arr00),
127
+
128
+ console.log(getMonthDays(2022,11), '// 获取当前年份中,指定月份的天数')
129
+ },
130
+ methods: {
131
+ phoneCode(e){
132
+ if (verCode.phoneCodeStatus()) {
133
+ console.log('已经发送了')
134
+ return false
135
+ }
136
+ verCode.PhoneCode(e,10)
137
+ },
138
+ phoneCodeExit(){
139
+ verCode.PhoneCodeClear()
140
+ },
141
+ longpress() {
142
+ console.log(112233);
143
+ },
144
+ copyCli() {
145
+ copy("good哈哈哈失败", (res) => {
146
+ if (res.code == 200) {
147
+ // 成功
148
+ alert(res.msg);
149
+ } else {
150
+ // 失败
151
+ alert(res.msg);
152
+ }
153
+ });
154
+ },
155
+ inputsLk: fun.debounce(function (v,v2) {
156
+ console.log(this.name,v,v2);
157
+ }),
158
+ initScroll: fun.throole(function () {
159
+ console.log("触发了几次了" + Date.now());
160
+ }),
161
+ getCookie() {
162
+ console.log(cookie.get("test2"));
163
+ },
164
+ inputBlur() {
165
+ const regPhone = reg.Phone(this.name);
166
+ if (regPhone == true) {
167
+ console.log("正确", this.name);
168
+ } else {
169
+ console.log("错误", regPhone, "///");
170
+ console.log(
171
+ "错误",
172
+ reg.Phone(this.name, "空手机", "手机唧唧了"),
173
+ "///"
174
+ );
175
+ }
176
+ },
177
+ },
178
+ };
179
+ </script>
180
+ <style lang="scss" scoped>
181
+ .img {
182
+ width: 100px;
183
+ height: 100px;
184
+ }
185
+ </style>
@@ -1,53 +1,47 @@
1
1
  // 原生cookie的使用
2
2
  const cookie = {
3
- // 设置cookie
4
3
  set: (key, val, ops) => {
5
4
  // 接收配置信息
6
5
  ops = ops || {};
7
6
  // 处理默认路径
8
7
  let path = ops.path ? ";Path=" + ops.path : "";
9
- // 处理默认域名
10
- let domain = ops.domain ? ";domain=" + ops.domain :""
8
+ // 处理默认域名
9
+ let domain = ''
10
+ if (ops.domain && ops.domain == 'domain') {
11
+ // 设置cookie的路径为根域名
12
+ var hostname = window.location.hostname;
13
+ var parts = hostname.split('.');
14
+ var set_domain = parts.slice(-2).join('.');
15
+ domain = ";domain=" + set_domain
16
+ }
11
17
  // 处理默认有效期
12
18
  let expires = "";
13
19
  if (ops.expires) {
14
- // ops.expires = String(ops.expires).length == 10 ? new Date(ops.expires * 1000) : new Date(ops.expires)
15
- // expires = ";expires=" + ops.expires;
16
- let exp = String(ops.expires).length == 10 ? new Date(ops.expires * 1000) : new Date(ops.expires)
17
- expires = ";expires=" + exp.toGMTString();
20
+ let exp = String(ops.expires).length == 10 ? new Date(ops.expires * 1000) : new Date(ops.expires)
21
+ expires = ";expires=" + exp.toGMTString();
18
22
  }
19
23
  // 设置cookie
20
- document.cookie = `${key}=${encodeURIComponent(val)}${domain}${path}${expires}`;
24
+ // document.cookie = `${key}=${encodeURIComponent(val)}${path}${expires}`;
25
+ document.cookie = `${key}=${encodeURIComponent(val)}${domain}${path}${expires}`;
21
26
  },
22
27
  // 获取cookie
23
28
  get: (name) => {
24
- // // 获取所有的cookie
25
- // let str = document.cookie;
26
- // // 第一次分割,将每组名字和值分割出来
27
- // let arr = str.split("; ");
28
- // for (let i = 0; i < arr.length; i++) {
29
- // // 第二次分割将每个名字和值分割开
30
- // if (arr[i].split("=")[0] === key) {
31
- // // 将值返回
32
- // return arr[i].split("=")[1];
33
- // }
34
- // }
35
- // // 如果循环结束没有匹配项就返回空
36
- // return "";
37
29
  const value = `; ${document.cookie}`
38
- const parts = value.split(`; ${name}=`)
39
- if (parts.length === 2) {
40
- return decodeURIComponent(parts.pop().split(';').shift())
41
- } else {
42
- return null
43
- }
30
+ const parts = value.split(`; ${name}=`)
31
+ if (parts.length === 2) {
32
+ return decodeURIComponent(parts.pop().split(';').shift())
33
+ } else {
34
+ return null
35
+ }
44
36
  },
45
37
  // 移除cookie
46
38
  remove: (key, ops) => {
47
39
  ops = ops || {};
48
40
  // 日期设为昨天即为失效
49
41
  ops.expires = -1;
50
- cookie.set(key, null, ops);
42
+ // 如果设置时,设置了domain,则删除时 也需要
43
+ //ops.domain = 'domain'
44
+ cookie.set(key, null, ops);
51
45
  }
52
46
  };
53
47
  export default cookie;
@@ -1,4 +1,3 @@
1
- import fun from '../function/index'
2
1
  // 处理精度丢失的加减乘除
3
2
  var countDecimals = function (num) {
4
3
  var len = 0;
@@ -65,9 +64,17 @@ var getCorrectResult = function (type, num1, num2, result) {
65
64
  if (Math.abs(result - temp_result) > 1) {
66
65
  return temp_result;
67
66
  }
67
+ if(!isLessThanTwoDecimalPlaces(result)){
68
+ result = Number(result.toFixed(2))
69
+ }
68
70
  return result;
69
71
  };
70
72
 
73
+ // 判断小数点是否超过后2位 (如果超过了是 false 未超过 true)
74
+ function isLessThanTwoDecimalPlaces(num) {
75
+ return Math.floor(num * 100) === num * 100;
76
+ }
77
+
71
78
  let num = {
72
79
  NumFilter(v) {
73
80
  // 数字相加时,可能会出现多余2位数的
package/src/App2.vue DELETED
@@ -1,185 +0,0 @@
1
- <template>
2
- <div id="app">
3
- <input
4
- type="text"
5
- id="input"
6
- v-model="name"
7
- @blur="inputBlur"
8
- @keydown="inputsLk({id:'11',name:'实力坑爹'},12123)"
9
- />
10
- <button @click="getCookie">点击</button>
11
- <div
12
- style="height: 300px; border: 1px solid red; overflow-y: auto"
13
- @scroll="initScroll"
14
- >
15
- <div style="height: 800px">滚动区域</div>
16
- </div>
17
- <button @click="copyCli()">Copy</button>
18
- <br />
19
- <br>
20
- <br>
21
- <!-- <button @click="phoneCode($event)">验证码</button> -->
22
- <a href="javascript:;" @click="phoneCode($event)">验证码</a>
23
- <a href="javascript:;" @click="phoneCodeExit()">清空验证码</a>
24
- <br>
25
- <br>
26
- <ul>
27
- <li v-for="(item,index) in list" :key="index">
28
- <span>{{item.name}}</span>
29
- <span>{{item.age}}</span>
30
- <span>{{item.sex}}</span>
31
- </li>
32
- </ul>
33
- </div>
34
- </template>
35
- <script>
36
- import reg from "./reg";
37
- import time from "./time";
38
- import cookie from "./cookie";
39
- import fun from "./function";
40
- import num from "./number";
41
- import copy from "./copy";
42
- import deepCopy from "./deepCopy";
43
- import verCode from "./verCode";
44
- import filterTable from "./filterTable";
45
- import getMonthDays from "./getMonthDays";
46
- export default {
47
- data() {
48
- return {
49
- name: "",
50
- list: [
51
- {
52
- name:'d',
53
- age:99,
54
- sex:'男'
55
- },
56
- {
57
- name:null,
58
- age:'',
59
- sex: '女'
60
- },
61
- {
62
- name:'hf',
63
- age:1,
64
- sex:''
65
- },
66
- ]
67
- };
68
- },
69
- // directives: {
70
- // LazyLoad,
71
- // },
72
- mounted() {
73
- this.list = filterTable(this.list)
74
- console.log(time.toStamp("2021-06-02 18:17:02"), "当前时间戳");
75
- console.log(time.toDate(1622623502), "当前时间");
76
- console.log(time.getNow(), "系统当前时间");
77
- cookie.set("test1", "abcde", {
78
- path: "/device",
79
- expires: 1622882702,
80
- });
81
- cookie.set("test2", "abcdefghi", { expires: 1622623502 });
82
- setTimeout(() => {
83
- console.log(cookie.get("test2"));
84
- }, 1000);
85
- setTimeout(() => {
86
- cookie.remove("test2");
87
- }, 3000);
88
- document.onscroll = fun.throole(function () {
89
- console.log("触发了几次了" + Date.now());
90
- }, 200);
91
- // let arr = [729.396, 72.6353, 6.3343, 1.1695];
92
- let arr = [729.6986, 72.6, 6.119, 23.03,0.502];
93
- let arr2 = arr.reduce((pre, next) => {
94
- return pre + next;
95
- });
96
- let arr3 = arr.reduce((v, n) => {
97
- return num.add(v, n);
98
- });
99
-
100
-
101
- console.log(arr2,'22');
102
- console.log(arr3,'33');
103
- console.log(num.add(3.29555556,2.63),'+');
104
- console.log(num.sub(0.11, 0.306),'-');
105
- console.log(num.mul(0.1, 0.3231),'*');
106
- console.log(num.div(0.893, 0.3),'/');
107
-
108
-
109
- let obj = {
110
- name: '张三',
111
- age:12,
112
- info: {
113
- sex: '男',
114
- like: ['电影','游戏']
115
- }
116
- }
117
- let obj2 = deepCopy({},obj)
118
- obj2.age = 18
119
- obj2.info.sex = '女'
120
- obj2.info.like = ['耍']
121
- console.log(obj2,obj,'深拷贝后的值变化')
122
-
123
- let arr00 = [1,2,3,4,5]
124
- let arr002 = deepCopy([],arr00)
125
- arr002[0]=111
126
- console.log(arr002,arr00),
127
-
128
- console.log(getMonthDays(2022,11), '// 获取当前年份中,指定月份的天数')
129
- },
130
- methods: {
131
- phoneCode(e){
132
- if (verCode.phoneCodeStatus()) {
133
- console.log('已经发送了')
134
- return false
135
- }
136
- verCode.PhoneCode(e,10)
137
- },
138
- phoneCodeExit(){
139
- verCode.PhoneCodeClear()
140
- },
141
- longpress() {
142
- console.log(112233);
143
- },
144
- copyCli() {
145
- copy("good哈哈哈失败", (res) => {
146
- if (res.code == 200) {
147
- // 成功
148
- alert(res.msg);
149
- } else {
150
- // 失败
151
- alert(res.msg);
152
- }
153
- });
154
- },
155
- inputsLk: fun.debounce(function (v,v2) {
156
- console.log(this.name,v,v2);
157
- }),
158
- initScroll: fun.throole(function () {
159
- console.log("触发了几次了" + Date.now());
160
- }),
161
- getCookie() {
162
- console.log(cookie.get("test2"));
163
- },
164
- inputBlur() {
165
- const regPhone = reg.Phone(this.name);
166
- if (regPhone == true) {
167
- console.log("正确", this.name);
168
- } else {
169
- console.log("错误", regPhone, "///");
170
- console.log(
171
- "错误",
172
- reg.Phone(this.name, "空手机", "手机唧唧了"),
173
- "///"
174
- );
175
- }
176
- },
177
- },
178
- };
179
- </script>
180
- <style lang="scss" scoped>
181
- .img {
182
- width: 100px;
183
- height: 100px;
184
- }
185
- </style>