js_ryl 1.0.24 → 1.0.26

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
@@ -19,6 +19,8 @@
19
19
  9.table中的数据补全方法 -- filterTable
20
20
  10.获取当前年份中,指定月份的天数 -- getMonthDays
21
21
  11.unicode转化emoji表情 -- emoji
22
+ 12.根据输入内容,高亮匹配对应的字符串 -- highLight
23
+ 13.商品飞入购物车效果 -- flyToCart
22
24
 
23
25
  # 使用方法:
24
26
 
@@ -32,14 +34,12 @@
32
34
  Money() #金额
33
35
 
34
36
  # 使用方法
35
-
36
- const regPhone = reg.Phone(this.phone);
37
- if (regPhone == true) {
38
- console.log("正确", this.phone);
39
- } else {
40
- console.log("错误",regPhone); -- 默认错误内容
41
- console.log("错误",reg.Phone(this.phone, "空手机", "手机唧唧了")); -- 自定义错误内容, 基本不用
42
- }
37
+ # 第一个参数是值,第二个参数(提示输入,可不填),三个参数(错误后的提示,可不填),第二三个参数有默认值
38
+ reg.Phone(this.name,'请输入...','完犊子').then(()=>{
39
+ console.log('成功')
40
+ }).catch(e=>{
41
+ console.log(e)
42
+ })
43
43
 
44
44
 
45
45
  #2.时间戳与时间的转化 -- time
@@ -166,8 +166,23 @@
166
166
  #11.unicode转化emoji表情,如果不符合emoji的要求,则转化为字符,如果还不符合,则输出原unicode
167
167
 
168
168
  # 方法:
169
- # emoji()
169
+ emoji(str)
170
+
171
+ #12.根据输入内容,高亮匹配对应的字符串
172
+
173
+ # 方法:
174
+ # 3个参数
175
+ # 第一个 需要匹配的值(静态或者动态的变量),第二个 需要被匹配的内容(字符串,一般是固定的),第三个 为匹配后的类名
176
+ <div v-html="setHighLight(name,highLightContent,'initHightLightClassName')"></div>
177
+ #引入 highLight.js
178
+ setHighLight:highLight,
170
179
 
180
+ #13.商品飞入购物车效果
181
+
182
+ # 方法:
183
+ flyToCart(event,image,targets)
184
+ # event 目标元素,image 缩略图,targets 购物车的位置
185
+ # 如:flyToCart(event,'https://v2-saas-1259468876.cos.ap-shanghai.myqcloud.com//system//admin//7c7ec8b02b009d2385db1faae95b9ab0.png',document.querySelector('#shoppps'))
171
186
 
172
187
 
173
188
  # serve with hot reload at localhost:8080
@@ -189,7 +204,8 @@
189
204
  #1.0.19: 验证手机号码 优化
190
205
  #1.0.21: number精度问题优化
191
206
  #1.0.22: 数据补全方法优化
192
- #1.0.24: 数据补全方法优化
207
+ #1.0.25: 新增了emoji,highLight方法
208
+ #1.0.26: 商品飞入购物车效果
193
209
  ```
194
210
 
195
211
  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=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),v=n(11);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,emoji:v.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){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function o(t){return i.some(function(e){return e===t})}var i=["",void 0,null],a=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--",n=arguments[2];n&&n.length&&(i=[].concat(r(i),r(n)));var a=[];for(var u in t){for(var c={},l=Object.entries(t[u]),s=0;s<l.length;s++){var f=l[s];o(f[1])&&(f[1]=e),c[f[0]]=f[1]}a.push(c)}return a};e.a=a},function(t,e,n){"use strict";var r=function(t,e){return new Date(t,e,0).getDate()};e.a=r},function(t,e,n){"use strict";function r(t){var e=/U\+([0-9A-Fa-f]{4,6})|\[u\+([0-9A-Fa-f]{4,6})\]|\\u\{([0-9A-Fa-f]{4,6})\}/g;return t?t.replace(e,function(t,e,n,r){var a=e||n||r,u=parseInt(a,16);if(isNaN(u)||u<0||u>1114111)return t;try{var c=String.fromCodePoint(u);return o(u)?c:i(c)?c:t}catch(e){return t}}):t}function o(t){return u.some(function(e){var n=a(e,2),r=n[0],o=n[1];return t>=r&&t<=o})}function i(t){return"�"!==t}e.a=r;var a=function(){function t(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=[[8986,8987],[9193,9196],[9200,9200],[9203,9203],[9642,9643],[9654,9654],[9664,9664],[9723,9726],[9728,9732],[9742,9742],[9745,9745],[9748,9749],[9752,9752],[9757,9757],[9760,9760],[9762,9763],[9766,9766],[9770,9770],[9774,9775],[9784,9786],[9792,9792],[9794,9794],[9800,9811],[9823,9824],[9827,9827],[9829,9830],[9832,9832],[9851,9851],[9855,9855],[9874,9879],[9881,9881],[9883,9884],[9888,9889],[9898,9899],[9904,9905],[9917,9918],[9924,9925],[9928,9928],[9934,9935],[9937,9937],[9939,9940],[9961,9962],[9968,9973],[9975,9978],[9981,9981],[9986,9986],[9989,9989],[9992,9997],[9999,9999],[10002,10002],[10004,10004],[10006,10006],[10013,10013],[10017,10017],[10024,10024],[10035,10036],[10052,10052],[10055,10055],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10083,10084],[10133,10135],[10145,10145],[10160,10160],[10175,10175],[10548,10549],[11013,11015],[11035,11036],[11088,11088],[11093,11093],[126980,126980],[127183,127183],[127344,127345],[127358,127359],[127374,127374],[127377,127386],[127462,127487],[127489,127490],[127514,127514],[127535,127535],[127538,127546],[127568,127569],[127744,128511],[128512,128591],[128640,128767],[128768,128895],[128896,129023],[129024,129279],[129280,129535],[129536,129647],[129648,129791],[129792,130047]]}])});
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),s=n(7),l=n(8),f=n(9),d=n(10),v=n(11),p=n(12),h=n(13);e.default={reg:r.a,time:o.a,cookie:i.a,fun:a.a,num:u.a,copy:c.a,deepCopy:s.a,verCode:l.a,filterTable:f.a,getMonthDays:d.a,emoji:v.a,highLight:p.a,flyToCart:h.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]:"手机号码格式有误";return new Promise(function(r,o){var i=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;t?i.test(t)?r():o(n):o(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]:"邮箱格式有误";return new Promise(function(r,o){var i=/^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;t?i.test(t)?r():o(n):o(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]:"身份证号码格式有误";return new Promise(function(r,o){var i=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;t?i.test(t)?r():o(n):o(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]:"只能包含数字、字母以及下划线";return new Promise(function(r,o){var i=/^[a-zA-Z0-9_]+$/;t?i.test(t)?r():o(n):o(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号码格式错误";return new Promise(function(r,o){var i=/^[1-9][0-9]{4,10}$/gim;t?i.test(t)?r():o(n):o(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]:"金额格式错误";return new Promise(function(r,o){var i=/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;t?i.test(t)?r():o(n):o(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(),s=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(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)},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 s=this.mul(n/r,Math.pow(10,c-u));return a("div",t,e,s)},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){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function o(t){return i.some(function(e){return e===t})}var i=["",void 0,null],a=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"--",n=arguments[2];n&&n.length&&(i=[].concat(r(i),r(n)));var a=[];for(var u in t){for(var c={},s=Object.entries(t[u]),l=0;l<s.length;l++){var f=s[l];o(f[1])&&(f[1]=e),c[f[0]]=f[1]}a.push(c)}return a};e.a=a},function(t,e,n){"use strict";var r=function(t,e){return new Date(t,e,0).getDate()};e.a=r},function(t,e,n){"use strict";function r(t){var e=/U\+([0-9A-Fa-f]{4,6})|\[u\+([0-9A-Fa-f]{4,6})\]|\\u\{([0-9A-Fa-f]{4,6})\}/g;return t?t.replace(e,function(t,e,n,r){var a=e||n||r,u=parseInt(a,16);if(isNaN(u)||u<0||u>1114111)return t;try{var c=String.fromCodePoint(u);return o(u)?c:i(c)?c:t}catch(e){return t}}):t}function o(t){return u.some(function(e){var n=a(e,2),r=n[0],o=n[1];return t>=r&&t<=o})}function i(t){return"�"!==t}e.a=r;var a=function(){function t(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=[[8986,8987],[9193,9196],[9200,9200],[9203,9203],[9642,9643],[9654,9654],[9664,9664],[9723,9726],[9728,9732],[9742,9742],[9745,9745],[9748,9749],[9752,9752],[9757,9757],[9760,9760],[9762,9763],[9766,9766],[9770,9770],[9774,9775],[9784,9786],[9792,9792],[9794,9794],[9800,9811],[9823,9824],[9827,9827],[9829,9830],[9832,9832],[9851,9851],[9855,9855],[9874,9879],[9881,9881],[9883,9884],[9888,9889],[9898,9899],[9904,9905],[9917,9918],[9924,9925],[9928,9928],[9934,9935],[9937,9937],[9939,9940],[9961,9962],[9968,9973],[9975,9978],[9981,9981],[9986,9986],[9989,9989],[9992,9997],[9999,9999],[10002,10002],[10004,10004],[10006,10006],[10013,10013],[10017,10017],[10024,10024],[10035,10036],[10052,10052],[10055,10055],[10060,10060],[10062,10062],[10067,10069],[10071,10071],[10083,10084],[10133,10135],[10145,10145],[10160,10160],[10175,10175],[10548,10549],[11013,11015],[11035,11036],[11088,11088],[11093,11093],[126980,126980],[127183,127183],[127344,127345],[127358,127359],[127374,127374],[127377,127386],[127462,127487],[127489,127490],[127514,127514],[127535,127535],[127538,127546],[127568,127569],[127744,128511],[128512,128591],[128640,128767],[128768,128895],[128896,129023],[129024,129279],[129280,129535],[129536,129647],[129648,129791],[129792,130047]]},function(t,e,n){"use strict";function r(t,e,n){if(console.log(t,e,n,"//"),!t)return e;var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=new RegExp("("+r+")","gi");return e.replace(o,'<span class="'+n+'">$1</span>')}e.a=r},function(t,e,n){"use strict";function r(t,e,n){var r=t.target,o=document.createElement("img");o.style.cssText="position: fixed;\n width: 20px;\n height: 20px;\n border-radius: 50%;\n pointer-events: none;\n transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.8s;\n z-index: 10000;\n opacity: 1;\n transform-origin: center center;",o.setAttribute("src",e),document.body.appendChild(o);var i=r.getBoundingClientRect(),a=i.left+i.width/2,u=i.top+i.height/2,c=n.getBoundingClientRect(),s=c.left+c.width/2,l=c.top+c.height/2,f=(a+s)/2,d=Math.min(u,l)-150;o.style.left=a+"px",o.style.top=u+"px";var v=0,p=performance.now(),h=function t(e){(v=(e-p)/800)>1&&(v=1);var n=(1-v)*(1-v)*a+2*(1-v)*v*f+v*v*s,r=(1-v)*(1-v)*u+2*(1-v)*v*d+v*v*l;o.style.left=n+"px",o.style.top=r+"px",o.style.transform="scale("+(1-.7*v)+")",o.style.opacity=""+(1-v),v<1&&requestAnimationFrame(t)};requestAnimationFrame(h)}e.a=r}])});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js_ryl",
3
- "version": "1.0.24",
3
+ "version": "1.0.26",
4
4
  "private": false,
5
5
  "description": "自定义通用js",
6
6
  "author": "renyuliang <785788909@qq.com>",
package/src/App.vue CHANGED
@@ -8,6 +8,8 @@
8
8
  @keydown="inputsLk({id:'11',name:'实力坑爹'},12123)"
9
9
  />
10
10
  <button @click="getCookie">点击</button>
11
+ <br>
12
+ <div v-html="setHighLight(name,highLightContent,'initHightLightClassName')"></div>
11
13
  <div
12
14
  style="height: 300px; border: 1px solid red; overflow-y: auto"
13
15
  @scroll="initScroll"
@@ -18,7 +20,6 @@
18
20
  <br />
19
21
  <br>
20
22
  <br>
21
- <!-- <button @click="phoneCode($event)">验证码</button> -->
22
23
  <a href="javascript:;" @click="phoneCode($event)">验证码</a>
23
24
  <a href="javascript:;" @click="phoneCodeExit()">清空验证码</a>
24
25
  <br>
@@ -30,6 +31,10 @@
30
31
  <span>{{item.sex}}</span>
31
32
  </li>
32
33
  </ul>
34
+ <a href="javascript:;" @click="shopToCart($event)">点击加入购物车</a>
35
+ <div style="text-align:right;margin-top:300px;">
36
+ <span id="shoppps">这是购物车的位置</span>
37
+ </div>
33
38
  </div>
34
39
  </template>
35
40
  <script>
@@ -44,10 +49,13 @@ import verCode from "./verCode";
44
49
  import filterTable from "./filterTable";
45
50
  import getMonthDays from "./getMonthDays";
46
51
  import emoji from "./emoji";
52
+ import highLight from "./highLight";
53
+ import flyToCart from "./flyToCart";
47
54
  export default {
48
55
  data() {
49
56
  return {
50
57
  name: "",
58
+ highLightContent: '234234234234',
51
59
  list: [
52
60
  {
53
61
  name:'d',
@@ -141,6 +149,10 @@ export default {
141
149
 
142
150
  },
143
151
  methods: {
152
+ shopToCart(event){
153
+ flyToCart(event,'https://v2-saas-1259468876.cos.ap-shanghai.myqcloud.com//system//admin//7c7ec8b02b009d2385db1faae95b9ab0.png',document.querySelector('#shoppps'))
154
+ },
155
+ setHighLight:highLight,
144
156
  phoneCode(e){
145
157
  if (verCode.phoneCodeStatus()) {
146
158
  console.log('已经发送了')
@@ -175,24 +187,35 @@ export default {
175
187
  console.log(cookie.get("test2"));
176
188
  },
177
189
  inputBlur() {
178
- const regPhone = reg.Phone(this.name);
179
- if (regPhone == true) {
180
- console.log("正确", this.name);
181
- } else {
182
- console.log("错误", regPhone, "///");
183
- console.log(
184
- "错误",
185
- reg.Phone(this.name, "空手机", "手机唧唧了"),
186
- "///"
187
- );
188
- }
190
+ reg.Email(this.name,'请是是是','完犊子').then(()=>{
191
+ console.log('成功')
192
+ }).catch(e=>{
193
+ console.log(e)
194
+ })
195
+ // const regPhone = reg.Phone(this.name);
196
+ // console.log(regPhone,'regPhone')
197
+ // if (regPhone == true) {
198
+ // console.log("正确", this.name);
199
+ // } else {
200
+ // console.log("错误", regPhone, "///");
201
+ // console.log(
202
+ // "错误",
203
+ // reg.Phone(this.name, "空手机", "手机唧唧了"),
204
+ // "///"
205
+ // );
206
+ // }
189
207
  },
190
208
  },
191
209
  };
192
210
  </script>
193
- <style lang="scss" scoped>
211
+ <style lang="scss">
194
212
  .img {
195
213
  width: 100px;
196
214
  height: 100px;
197
215
  }
216
+ .initHightLightClassName{
217
+ color: #06f;
218
+ font-weight: bold;
219
+ text-decoration: underline;
220
+ }
198
221
  </style>
@@ -0,0 +1,67 @@
1
+ // 飞入购物车效果
2
+ // event 目标元素,image 缩略图,targets 购物车的位置
3
+ export default function flyToCart(event,image,targets) {
4
+ const button = event.target
5
+ // 创建商品图片
6
+ const flyEl = document.createElement('img')
7
+ // 设置缩略图样式
8
+ flyEl.style.cssText = `position: fixed;
9
+ width: 20px;
10
+ height: 20px;
11
+ border-radius: 50%;
12
+ pointer-events: none;
13
+ transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.8s;
14
+ z-index: 10000;
15
+ opacity: 1;
16
+ transform-origin: center center;`
17
+ flyEl.setAttribute('src',image)
18
+ document.body.appendChild(flyEl)
19
+
20
+ // 起点坐标(按钮中心)
21
+ const startRect = button.getBoundingClientRect()
22
+ const startX = startRect.left + startRect.width / 2
23
+ const startY = startRect.top + startRect.height / 2
24
+
25
+ // 终点坐标(购物车中心)
26
+ const cartRect = targets.getBoundingClientRect()
27
+ const endX = cartRect.left + cartRect.width / 2
28
+ const endY = cartRect.top + cartRect.height / 2
29
+
30
+ // 抛物线控制点(控制抛物线弧度)
31
+ // 这里取起点和终点中间上方 150px 作为控制点
32
+ const controlX = (startX + endX) / 2
33
+ const controlY = Math.min(startY, endY) - 150
34
+
35
+ // 设置初始位置
36
+ flyEl.style.left = startX + 'px'
37
+ flyEl.style.top = startY + 'px'
38
+
39
+ let t = 0 // 进度 0~1
40
+ const duration = 800 // 动画时长 ms
41
+ const startTime = performance.now()
42
+
43
+ const animate = (time) => {
44
+ t = (time - startTime) / duration
45
+ if (t > 1) t = 1
46
+
47
+ // 贝塞尔曲线公式计算位置
48
+ // B(t) = (1-t)^2 * P0 + 2(1-t)t * P1 + t^2 * P2
49
+ const x = (1 - t) * (1 - t) * startX + 2 * (1 - t) * t * controlX + t * t * endX
50
+ const y = (1 - t) * (1 - t) * startY + 2 * (1 - t) * t * controlY + t * t * endY
51
+
52
+ flyEl.style.left = x + 'px'
53
+ flyEl.style.top = y + 'px'
54
+
55
+ // 缩放和透明度渐变
56
+ flyEl.style.transform = `scale(${1 - t * 0.7})`
57
+ flyEl.style.opacity = `${1 - t}`
58
+
59
+ if (t < 1) {
60
+ requestAnimationFrame(animate)
61
+ } else {
62
+ // 动画结束,移除元素
63
+ // flyEl.remove()
64
+ }
65
+ }
66
+ requestAnimationFrame(animate)
67
+ }
@@ -0,0 +1,11 @@
1
+ // 高亮显示搜索匹配的文字
2
+ export default function highlight(searchName,backText,className) {
3
+ console.log(searchName,backText,className,'//')
4
+ if (!searchName) return backText;
5
+ // 转义特殊字符,防止正则错误
6
+ const escapedKeyword = searchName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
7
+ // 创建正则,忽略大小写,全局匹配
8
+ const regex = new RegExp(`(${escapedKeyword})`, 'gi');
9
+ // 替换匹配部分,包裹高亮span
10
+ return backText.replace(regex, `<span class="${className}">$1</span>`);
11
+ }
package/src/index.js CHANGED
@@ -21,6 +21,10 @@ import filterTable from "./filterTable";
21
21
  import getMonthDays from "./getMonthDays";
22
22
  // emoji表情转化
23
23
  import emoji from "./emoji";
24
+ // 高亮显示搜索匹配的文字
25
+ import highLight from "./highLight";
26
+ // 飞入购物车效果
27
+ import flyToCart from "./flyToCart";
24
28
 
25
29
  export default {
26
30
  reg,
@@ -33,5 +37,7 @@ export default {
33
37
  verCode,
34
38
  filterTable,
35
39
  getMonthDays,
36
- emoji
40
+ emoji,
41
+ highLight,
42
+ flyToCart
37
43
  };
package/src/reg/index.js CHANGED
@@ -6,29 +6,33 @@ let reg = {
6
6
  noValueMsg = "请输入手机号码",
7
7
  errValueMsg = "手机号码格式有误"
8
8
  ) {
9
- let reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
10
- if (value) {
11
- if (reg.test(value)) {
12
- return true;
9
+ return new Promise((resolve,reject)=>{
10
+ let reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
11
+ if (value) {
12
+ if (reg.test(value)) {
13
+ resolve()
14
+ } else {
15
+ reject(errValueMsg)
16
+ }
13
17
  } else {
14
- return errValueMsg;
18
+ reject(noValueMsg)
15
19
  }
16
- } else {
17
- return noValueMsg;
18
- }
20
+ })
19
21
  },
20
22
  // 邮箱验证
21
23
  Email(value, noValueMsg = "请输入邮箱", errValueMsg = "邮箱格式有误") {
22
- let reg = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
23
- if (value) {
24
- if (reg.test(value)) {
25
- return true;
24
+ return new Promise((resolve,reject)=>{
25
+ let reg = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
26
+ if (value) {
27
+ if (reg.test(value)) {
28
+ resolve()
29
+ } else {
30
+ reject(errValueMsg)
31
+ }
26
32
  } else {
27
- return errValueMsg;
33
+ reject(noValueMsg)
28
34
  }
29
- } else {
30
- return noValueMsg;
31
- }
35
+ })
32
36
  },
33
37
  // 身份证号码验证
34
38
  IdCard(
@@ -36,16 +40,18 @@ let reg = {
36
40
  noValueMsg = "请输入身份证号码",
37
41
  errValueMsg = "身份证号码格式有误"
38
42
  ) {
39
- let reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
40
- if (value) {
41
- if (reg.test(value)) {
42
- return true;
43
+ return new Promise((resolve,reject)=>{
44
+ let reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
45
+ if (value) {
46
+ if (reg.test(value)) {
47
+ resolve()
48
+ } else {
49
+ reject(errValueMsg)
50
+ }
43
51
  } else {
44
- return errValueMsg;
52
+ reject(noValueMsg)
45
53
  }
46
- } else {
47
- return noValueMsg;
48
- }
54
+ })
49
55
  },
50
56
  // 只能包含数字、字母以及下划线
51
57
  Common(
@@ -53,16 +59,18 @@ let reg = {
53
59
  noValueMsg = "请输入包含数字、字母以及下划线的内容",
54
60
  errValueMsg = "只能包含数字、字母以及下划线"
55
61
  ) {
56
- let reg = /^[a-zA-Z0-9_]+$/;
57
- if (value) {
58
- if (reg.test(value)) {
59
- return true;
62
+ return new Promise((resolve,reject)=>{
63
+ let reg = /^[a-zA-Z0-9_]+$/;
64
+ if (value) {
65
+ if (reg.test(value)) {
66
+ resolve()
67
+ } else {
68
+ reject(errValueMsg)
69
+ }
60
70
  } else {
61
- return errValueMsg;
71
+ reject(noValueMsg)
62
72
  }
63
- } else {
64
- return noValueMsg;
65
- }
73
+ })
66
74
  },
67
75
  // QQ验证
68
76
  QQ(
@@ -70,16 +78,18 @@ let reg = {
70
78
  noValueMsg = "请输入QQ号码",
71
79
  errValueMsg = "QQ号码格式错误"
72
80
  ) {
73
- let reg = /^[1-9][0-9]{4,10}$/gim;
74
- if (value) {
75
- if (reg.test(value)) {
76
- return true;
81
+ return new Promise((resolve,reject)=>{
82
+ let reg = /^[1-9][0-9]{4,10}$/gim;
83
+ if (value) {
84
+ if (reg.test(value)) {
85
+ resolve()
86
+ } else {
87
+ reject(errValueMsg)
88
+ }
77
89
  } else {
78
- return errValueMsg;
90
+ reject(noValueMsg)
79
91
  }
80
- } else {
81
- return noValueMsg;
82
- }
92
+ })
83
93
  },
84
94
  // 金额
85
95
  Money(
@@ -87,16 +97,18 @@ let reg = {
87
97
  noValueMsg = "请输入金额(最多保留2位小数点)",
88
98
  errValueMsg = "金额格式错误"
89
99
  ) {
90
- let reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
91
- if (value) {
92
- if (reg.test(value)) {
93
- return true;
100
+ return new Promise((resolve,reject)=>{
101
+ let reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
102
+ if (value) {
103
+ if (reg.test(value)) {
104
+ resolve()
105
+ } else {
106
+ reject(errValueMsg)
107
+ }
94
108
  } else {
95
- return errValueMsg;
109
+ reject(noValueMsg)
96
110
  }
97
- } else {
98
- return noValueMsg;
99
- }
111
+ })
100
112
  }
101
113
  };
102
114