js_ryl 1.0.8 → 1.0.11

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
@@ -9,6 +9,7 @@
9
9
  >4.函数的节流和防抖 -- fun
10
10
  >5.运算符 -- num
11
11
  >6.复制文本信息 -- copy
12
+ >7.对象深拷贝 -- deepCopy
12
13
 
13
14
  ## Build Setup
14
15
 
@@ -129,10 +130,27 @@ npm run dev
129
130
  # alert(res.msg); 默认提示 -- 当前浏览器不支持,请更换浏览器后重试
130
131
  # }
131
132
  # });
133
+ #7. 对象或数组的深拷贝 -- deepCopy
134
+
135
+ # let obj = {
136
+ # name: '张三',
137
+ # age:12,
138
+ # info: {
139
+ # sex: '男',
140
+ # like: ['电影','游戏']
141
+ # }
142
+ # }
143
+ # let obj2 = deepCopy({},obj)
144
+ # obj2.age = 18
145
+ # obj2.info.sex = '女'
146
+ # obj2.info.like = ['耍']
147
+ # console.log(obj2,obj,'深拷贝后的值变化')
132
148
 
133
149
  #1.0.04: 函数防抖和节流,添加 可传入参数
134
150
  #1.0.05: 添加获取验证码效果
135
- #1.0.08: 添加获取验证码效果 逻辑调整
151
+ #1.0.09: 添加获取验证码效果 逻辑调整
152
+ #1.0.10: cookie 过期时间转化 toGMTString()
153
+ #1.0.11: 添加对象或数组的深拷贝方法
136
154
 
137
155
  npm run build
138
156
  ```
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),a=n(4),i=n(0),u=n(5),c=n(6);e.default={reg:r.a,time:o.a,cookie:a.a,fun:i.a,num:u.a,copy:c.a}},function(t,e,n){"use strict";var r=!1,o=null,a="",i=null,u={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},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,7,8,9][0-9]{9}$/;return t?!!r.test(t)||n:e},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(a=t.target.innerText,i=t,!r){r=!0,t.target.innerText=n-1+"s"+u;var c=n-1;o=setInterval(function(){c--,c<=0?(t.target.innerText=a,e.PhoneCodeClear()):t.target.innerText=c+"s"+u},1e3)}},PhoneCodeClear:function(){r=!1,i.target.innerText=a,clearInterval(o)},phoneCodeStatus:function(){return r}};e.a=u},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(),a=n.getMonth()+1,i=n.getDate(),u=n.getHours(),c=n.getMinutes(),s=n.getSeconds();return"yyyy-MM-dd"==e?o+"-"+r(a)+"-"+r(i):"yyyy-MM-dd HH:mm"==e?o+"-"+r(a)+"-"+r(i)+" "+r(u)+":"+r(c):o+"-"+r(a)+"-"+r(i)+" "+r(u)+":"+r(c)+":"+r(s)},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)}};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.expires&&(n.expires=10==String(n.expires).length?new Date(1e3*n.expires):new Date(n.expires),o=";expires="+n.expires),document.cookie=t+"="+e+r+o},get:function(t){for(var e=document.cookie,n=e.split("; "),r=0;r<n.length;r++)if(n[r].split("=")[0]===t)return n[r].split("=")[1];return""},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(".",""))},a=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},i={add:function(t,e){t=Number(t),e=Number(e);var n,o,i;try{n=r(t)+1}catch(t){n=0}try{o=r(e)+1}catch(t){o=0}i=Math.pow(10,Math.max(n,o));var u=(this.mul(t,i)+this.mul(e,i))/i;return a("add",t,e,u)},sub:function(t,e){t=Number(t),e=Number(e);var n,o,i;try{n=r(t)+1}catch(t){n=0}try{o=r(e)+1}catch(t){o=0}i=Math.pow(10,Math.max(n,o));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,i,u=0,c=0;try{u=r(t)}catch(t){}try{c=r(e)}catch(t){}n=o(t),i=o(e);var s=this.mul(n/i,Math.pow(10,c-u));return a("div",t,e,s)},mul:function(t,e){t=Number(t),e=Number(e);var n=0,i=t.toString(),u=e.toString();try{n+=r(i)}catch(t){}try{n+=r(u)}catch(t){}var c=o(i)*o(u)/Math.pow(10,n);return a("mul",t,e,c)}};e.a=i},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}])});
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);e.default={reg:r.a,time:o.a,cookie:i.a,fun:a.a,num:u.a,copy:c.a,deepCopy:l.a}},function(t,e,n){"use strict";var r=!1,o=null,i="",a=null,u={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},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,7,8,9][0-9]{9}$/;return t?!!r.test(t)||n:e},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 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)}};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.expires){o=";expires="+(10==String(n.expires).length?new Date(1e3*n.expires):new Date(n.expires)).toGMTString()}document.cookie=t+"="+e+r+o},get:function(t){for(var e=document.cookie,n=e.split("; "),r=0;r<n.length;r++)if(n[r].split("=")[0]===t)return n[r].split("=")[1];return""},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={add:function(t,e){t=Number(t),e=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=Number(t),e=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}}])});
package/index.html CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  <head>
5
5
  <meta charset="utf-8">
6
- <title>judadingsheng_ryl</title>
6
+ <title>myJS_ryl</title>
7
7
  </head>
8
8
 
9
9
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js_ryl",
3
- "version": "1.0.8",
3
+ "version": "1.0.11",
4
4
  "private": false,
5
5
  "description": "自定义通用js",
6
6
  "author": "renyuliang <785788909@qq.com>",
@@ -21,11 +21,11 @@
21
21
  "babel-preset-env": "^1.6.0",
22
22
  "babel-preset-stage-3": "^6.24.1",
23
23
  "cross-env": "^5.0.5",
24
- "css-loader": "^0.28.7",
24
+ "css-loader": "^0.28.11",
25
25
  "file-loader": "^1.1.11",
26
- "node-sass": "^4.14.1",
26
+ "sass": "^1.52.3",
27
27
  "sass-loader": "^7.3.1",
28
- "style-loader": "^1.3.0",
28
+ "style-loader": "^0.23.1",
29
29
  "url-loader": "^0.6.2",
30
30
  "vue-cli-plugin-element": "~1.0.1",
31
31
  "vue-loader": "^13.0.5",
package/src/App.vue CHANGED
@@ -1,157 +1,3 @@
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
- </div>
25
- </template>
26
- <script>
27
- import reg from "./reg";
28
- import time from "./time";
29
- import cookie from "./cookie";
30
- import fun from "./function";
31
- import num from "./number";
32
- import copy from "./copy";
33
- export default {
34
- data() {
35
- return {
36
- name: "",
37
- };
38
- },
39
- // directives: {
40
- // LazyLoad,
41
- // },
42
- mounted() {
43
- // console.log(time.toStamp("2021-06-02 18:17:02"), "当前时间戳");
44
- // console.log(time.toDate(1622623502), "当前时间");
45
- // cookie.set("test1", "abcde", {
46
- // path: "/device",
47
- // expires: 1622882702,
48
- // });
49
- // cookie.set("test2", "abcdefghi", { expires: 1622623502 });
50
- // setTimeout(() => {
51
- // console.log(cookie.get("test2"));
52
- // }, 1000);
53
- // setTimeout(() => {
54
- // cookie.remove("test2");
55
- // }, 3000);
56
- // document.onscroll = fun.throole(function () {
57
- // console.log("触发了几次了" + Date.now());
58
- // }, 200);
59
- // let arr = [729.396, 72.6353, 6.3343, 1.1695];
60
- let arr = [729.6986, 72.6, 6.119, 23.03];
61
- let arr2 = arr.reduce((pre, next) => {
62
- return pre + next;
63
- });
64
- let arr3 = arr.reduce((v, n) => {
65
- return num.add(v, n);
66
- });
67
- let arr4 = arr.reduce((v, n) => {
68
- // 数字相加时,可能会出现多余2位数的
69
- var x = String(v).indexOf(".")+1;//得到小数点的位置
70
- var y = String(v).length - x;//小数点的位数
71
- if(y > 0 && y >=3 ) {
72
- v = Math.floor(v * 100) / 100
73
- }
74
- var x1 = String(n).indexOf(".")+1;//得到小数点的位置
75
- var y1 = String(n).length - x1;//小数点的位数
76
- if(y1 > 0 && y1 >=3 ) {
77
- n = Math.floor(n * 100) / 100
78
- }
79
- return num.add(v, n);
80
-
81
- // return num.add((v).toFixed(2), (n).toFixed(2));
82
- });
83
-
84
- // var num11 = 1.1298;
85
- // var x = String(num11).indexOf(".")+1;//得到小数点的位置
86
- // var y = String(num11).length - x;//小数点的位数
87
- // if(y > 0 && y >=3 ) {
88
- // console.log(num11+":有" + y+ "位小数",x);
89
- // let num22 = Math.floor(num11 * 100) / 100
90
- // console.log(num22)
91
- // console.log(typeof num22);
92
- // }
93
-
94
- console.log(arr2,'22');
95
- console.log(arr3,'33');
96
- console.log(arr4,'44');
97
- console.log(num.add(3.29555556,2.63));
98
- console.log(num.sub(0.11, 0.306));
99
- console.log(num.mul(0.1, 0.3231));
100
- console.log(num.div(0.93, 0.3));
101
- },
102
- methods: {
103
- phoneCode(e){
104
- if (reg.phoneCodeStatus()) {
105
- console.log('已经发送了')
106
- return false
107
- }
108
- reg.PhoneCode(e,10)
109
- },
110
- phoneCodeExit(){
111
- reg.PhoneCodeClear()
112
- },
113
- longpress() {
114
- console.log(112233);
115
- },
116
- copyCli() {
117
- copy("good哈哈哈失败", (res) => {
118
- if (res.code == 200) {
119
- // 成功
120
- alert(res.msg);
121
- } else {
122
- // 失败
123
- alert(res.msg);
124
- }
125
- });
126
- },
127
- inputsLk: fun.debounce(function (v,v2) {
128
- console.log(this.name,v,v2);
129
- }),
130
- initScroll: fun.throole(function () {
131
- console.log("触发了几次了" + Date.now());
132
- }),
133
- getCookie() {
134
- console.log(cookie.get("test2"));
135
- },
136
- inputBlur() {
137
- const regPhone = reg.Phone(this.name);
138
- if (regPhone == true) {
139
- console.log("正确", this.name);
140
- } else {
141
- console.log("错误", regPhone, "///");
142
- console.log(
143
- "错误",
144
- reg.Phone(this.name, "空手机", "手机唧唧了"),
145
- "///"
146
- );
147
- }
148
- },
149
- },
150
- };
151
- </script>
152
- <style lang="scss" scoped>
153
- .img {
154
- width: 100px;
155
- height: 100px;
156
- }
157
- </style>
1
+ <template>
2
+ <div id="app"></div>
3
+ </template>
package/src/App2.vue ADDED
@@ -0,0 +1,177 @@
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
+ </div>
25
+ </template>
26
+ <script>
27
+ import reg from "./reg";
28
+ import time from "./time";
29
+ import cookie from "./cookie";
30
+ import fun from "./function";
31
+ import num from "./number";
32
+ import copy from "./copy";
33
+ import deepCopy from "./deepCopy";
34
+ export default {
35
+ data() {
36
+ return {
37
+ name: "",
38
+ };
39
+ },
40
+ // directives: {
41
+ // LazyLoad,
42
+ // },
43
+ mounted() {
44
+ // console.log(time.toStamp("2021-06-02 18:17:02"), "当前时间戳");
45
+ // console.log(time.toDate(1622623502), "当前时间");
46
+ // cookie.set("test1", "abcde", {
47
+ // path: "/device",
48
+ // expires: 1622882702,
49
+ // });
50
+ // cookie.set("test2", "abcdefghi", { expires: 1622623502 });
51
+ // setTimeout(() => {
52
+ // console.log(cookie.get("test2"));
53
+ // }, 1000);
54
+ // setTimeout(() => {
55
+ // cookie.remove("test2");
56
+ // }, 3000);
57
+ // document.onscroll = fun.throole(function () {
58
+ // console.log("触发了几次了" + Date.now());
59
+ // }, 200);
60
+ // let arr = [729.396, 72.6353, 6.3343, 1.1695];
61
+ let arr = [729.6986, 72.6, 6.119, 23.03];
62
+ let arr2 = arr.reduce((pre, next) => {
63
+ return pre + next;
64
+ });
65
+ let arr3 = arr.reduce((v, n) => {
66
+ return num.add(v, n);
67
+ });
68
+ let arr4 = arr.reduce((v, n) => {
69
+ // 数字相加时,可能会出现多余2位数的
70
+ var x = String(v).indexOf(".")+1;//得到小数点的位置
71
+ var y = String(v).length - x;//小数点的位数
72
+ if(y > 0 && y >=3 ) {
73
+ v = Math.floor(v * 100) / 100
74
+ }
75
+ var x1 = String(n).indexOf(".")+1;//得到小数点的位置
76
+ var y1 = String(n).length - x1;//小数点的位数
77
+ if(y1 > 0 && y1 >=3 ) {
78
+ n = Math.floor(n * 100) / 100
79
+ }
80
+ return num.add(v, n);
81
+
82
+ // return num.add((v).toFixed(2), (n).toFixed(2));
83
+ });
84
+
85
+ // var num11 = 1.1298;
86
+ // var x = String(num11).indexOf(".")+1;//得到小数点的位置
87
+ // var y = String(num11).length - x;//小数点的位数
88
+ // if(y > 0 && y >=3 ) {
89
+ // console.log(num11+":有" + y+ "位小数",x);
90
+ // let num22 = Math.floor(num11 * 100) / 100
91
+ // console.log(num22)
92
+ // console.log(typeof num22);
93
+ // }
94
+
95
+ console.log(arr2,'22');
96
+ console.log(arr3,'33');
97
+ console.log(arr4,'44');
98
+ console.log(num.add(3.29555556,2.63));
99
+ console.log(num.sub(0.11, 0.306));
100
+ console.log(num.mul(0.1, 0.3231));
101
+ console.log(num.div(0.93, 0.3));
102
+
103
+ let obj = {
104
+ name: '张三',
105
+ age:12,
106
+ info: {
107
+ sex: '男',
108
+ like: ['电影','游戏']
109
+ }
110
+ }
111
+ let obj2 = deepCopy({},obj)
112
+ obj2.age = 18
113
+ obj2.info.sex = '女'
114
+ obj2.info.like = ['耍']
115
+ console.log(obj2,obj,'深拷贝后的值变化')
116
+
117
+ let arr00 = [1,2,3,4,5]
118
+ let arr002 = deepCopy([],arr00)
119
+ arr002[0]=111
120
+ console.log(arr002,arr00)
121
+ },
122
+ methods: {
123
+ phoneCode(e){
124
+ if (reg.phoneCodeStatus()) {
125
+ console.log('已经发送了')
126
+ return false
127
+ }
128
+ reg.PhoneCode(e,10)
129
+ },
130
+ phoneCodeExit(){
131
+ reg.PhoneCodeClear()
132
+ },
133
+ longpress() {
134
+ console.log(112233);
135
+ },
136
+ copyCli() {
137
+ copy("good哈哈哈失败", (res) => {
138
+ if (res.code == 200) {
139
+ // 成功
140
+ alert(res.msg);
141
+ } else {
142
+ // 失败
143
+ alert(res.msg);
144
+ }
145
+ });
146
+ },
147
+ inputsLk: fun.debounce(function (v,v2) {
148
+ console.log(this.name,v,v2);
149
+ }),
150
+ initScroll: fun.throole(function () {
151
+ console.log("触发了几次了" + Date.now());
152
+ }),
153
+ getCookie() {
154
+ console.log(cookie.get("test2"));
155
+ },
156
+ inputBlur() {
157
+ const regPhone = reg.Phone(this.name);
158
+ if (regPhone == true) {
159
+ console.log("正确", this.name);
160
+ } else {
161
+ console.log("错误", regPhone, "///");
162
+ console.log(
163
+ "错误",
164
+ reg.Phone(this.name, "空手机", "手机唧唧了"),
165
+ "///"
166
+ );
167
+ }
168
+ },
169
+ },
170
+ };
171
+ </script>
172
+ <style lang="scss" scoped>
173
+ .img {
174
+ width: 100px;
175
+ height: 100px;
176
+ }
177
+ </style>
@@ -9,8 +9,10 @@ const cookie = {
9
9
  // 处理默认有效期
10
10
  let expires = "";
11
11
  if (ops.expires) {
12
- ops.expires = String(ops.expires).length == 10 ? new Date(ops.expires * 1000) : new Date(ops.expires)
13
- expires = ";expires=" + ops.expires;
12
+ // ops.expires = String(ops.expires).length == 10 ? new Date(ops.expires * 1000) : new Date(ops.expires)
13
+ // expires = ";expires=" + ops.expires;
14
+ let exp = String(ops.expires).length == 10 ? new Date(ops.expires * 1000) : new Date(ops.expires)
15
+ expires = ";expires=" + exp.toGMTString();
14
16
  }
15
17
  // 设置cookie
16
18
  document.cookie = `${key}=${val}${path}${expires}`;
@@ -0,0 +1,13 @@
1
+ // 深拷贝
2
+ export default function deepCopy(obj, tar) {
3
+ var dest = obj || {}
4
+ for (const key in tar) {
5
+ if (typeof tar[key] === 'object') {
6
+ dest[key] = (tar[key].constructor === Array) ? []:{}
7
+ deepCopy(dest[key],tar[key])
8
+ } else {
9
+ dest[key] = tar[key]
10
+ }
11
+ }
12
+ return dest
13
+ }
package/src/index.js CHANGED
@@ -11,6 +11,8 @@ import fun from "./function";
11
11
  import num from "./number";
12
12
  // 复制文本信息
13
13
  import copy from "./copy";
14
+ // 深拷贝
15
+ import deepCopy from "./deepCopy";
14
16
 
15
17
  export default {
16
18
  reg,
@@ -18,5 +20,6 @@ export default {
18
20
  cookie,
19
21
  fun,
20
22
  num,
21
- copy
23
+ copy,
24
+ deepCopy
22
25
  };
package/src/reg/index.js CHANGED
@@ -131,7 +131,9 @@ let reg = {
131
131
  // 清除手机验证码
132
132
  PhoneCodeClear(){
133
133
  phoneCodeStatus = false
134
- phoneCodeSelf.target.innerText = phoneCodeName
134
+ if (phoneCodeSelf) {
135
+ phoneCodeSelf.target.innerText = phoneCodeName
136
+ }
135
137
  clearInterval(phoneCodeTimer)
136
138
  },
137
139
  // 验证码状态是否已经发送