yunlin 1.0.20 → 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/dist/func.js +1 -0
- package/dist/index.js +1 -0
- package/dist/test.js +1 -0
- package/dist/utils.js +1 -0
- package/package.json +13 -4
- package/.babelrc +0 -5
- package/src/func.js +0 -272
- package/src/index.js +0 -7
- package/src/test.js +0 -355
- package/src/utils.js +0 -545
package/dist/func.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var a0_0x306dfc=a0_0x5bbe;(function(_0xb3793a,_0x5561e8){var _0x3b6df4=a0_0x5bbe,_0x450cfd=_0xb3793a();while(!![]){try{var _0x26b6cf=-parseInt(_0x3b6df4(0xe3))/0x1+parseInt(_0x3b6df4(0xd0))/0x2+parseInt(_0x3b6df4(0xd2))/0x3*(parseInt(_0x3b6df4(0xf8))/0x4)+-parseInt(_0x3b6df4(0xc4))/0x5*(-parseInt(_0x3b6df4(0xfa))/0x6)+parseInt(_0x3b6df4(0xd7))/0x7*(-parseInt(_0x3b6df4(0xe8))/0x8)+-parseInt(_0x3b6df4(0xe7))/0x9+-parseInt(_0x3b6df4(0xfc))/0xa*(-parseInt(_0x3b6df4(0xf4))/0xb);if(_0x26b6cf===_0x5561e8)break;else _0x450cfd['push'](_0x450cfd['shift']());}catch(_0x40f178){_0x450cfd['push'](_0x450cfd['shift']());}}}(a0_0x465d,0x95d0a));Object[a0_0x306dfc(0xfd)](exports,'__esModule',{'value':!![]}),exports[a0_0x306dfc(0xf9)]=void 0x0;function a0_0x465d(){var _0x52c959=['vipdiscounted','base','totaltax','length','保險費用','baseadultprice','promotion','優惠券','fLsjUnit','718112ueFEUL','list','1047zalrTl','insure','unit','\x20*\x20','filter','86632rqfDyu','tipday','兒童[占床]','other','reduction','money','name','point','baseprice','rylx','includes','adultprice','763944oyyEUS','tip','vip','people','4468923TDnXKB','648QPaYoO','viprecharge','num','itemname','trip','airtax','其他費用','strJgbm','map','adult','附加行程','totalprice','14047FtssyY','unitpricewb','人員費用','會員減免','180ZxwoeU','default','2319402fXpCXH','childprice','10510tMFuUR','defineProperty','concat','service','push','coupon','split','tipuser','fJcbzlsjUnit','長者減免','strLx','unitprice','elder','tax','childnum','price','15Hbahqw','adultnum','nRs'];a0_0x465d=function(){return _0x52c959;};return a0_0x465d();}function handleCosting(_0x46f2fe){var _0x6cc980=a0_0x306dfc,_0x5da151=arguments['length']>0x1&&arguments[0x1]!==undefined?arguments[0x1]:'¥',_0x51d90c=arguments[_0x6cc980(0xca)]>0x2&&arguments[0x2]!==undefined?arguments[0x2]:{'people':_0x6cc980(0xf6),'service':'附加服務','trip':_0x6cc980(0xf2),'other':_0x6cc980(0xee),'reduction':'減免費用','totalprice':'總計','airtax':'機場稅'},_0x720849=arguments[_0x6cc980(0xca)]>0x3&&arguments[0x3]!==undefined?arguments[0x3]:{'adult':'成人','child':'兒童','childusebed':_0x6cc980(0xd9),'infant':'嬰兒','half':'拼房','tip':'小費','elder':_0x6cc980(0x105),'vip':_0x6cc980(0xf7),'promotion':'促銷','insure':_0x6cc980(0xcb),'coupon':_0x6cc980(0xce),'point':'積分','tax':'稅金','viprecharge':'會員充值','r':'人','t':'天'},_0x33d9ef=[],_0x12f9b3=_0x6cc980(0xd5),_0x5c8088=_0x46f2fe[_0x6cc980(0xd6)](function(_0x1becda){var _0x5a22a3=_0x6cc980;return _0x1becda[_0x5a22a3(0x106)]==_0x5a22a3(0xc8);});if(_0x5c8088[_0x6cc980(0xca)]){var _0x54ed35={'title':_0x51d90c[_0x6cc980(0xe6)],'type':_0x6cc980(0xc8),'list':[]};_0x5c8088['map'](function(_0x4aeabd){var _0xb2c3df=_0x6cc980;_0x54ed35[_0xb2c3df(0xd1)]['push']({'title':_0x720849[_0x4aeabd[_0xb2c3df(0xef)]],'info':_0x5da151+_0x4aeabd[_0xb2c3df(0xcf)]+_0x12f9b3+_0x4aeabd[_0xb2c3df(0xc6)],'nRs':_0x4aeabd[_0xb2c3df(0xc6)],'unit':_0x4aeabd[_0xb2c3df(0xcf)],'cb':_0x4aeabd[_0xb2c3df(0x104)],'type':_0xb2c3df(0xc8)});}),_0x33d9ef[_0x6cc980(0x100)](_0x54ed35);}var _0x379b21=_0x46f2fe[_0x6cc980(0xd6)](function(_0x52bcf7){var _0x3e5163=_0x6cc980;return _0x52bcf7[_0x3e5163(0x106)]==_0x3e5163(0xff);});if(_0x379b21['length']){var _0x2fa908={'title':_0x51d90c[_0x6cc980(0xff)],'type':'service','list':[]};_0x379b21[_0x6cc980(0xf0)](function(_0x4d5d93){var _0x4622c4=_0x6cc980;_0x2fa908['list'][_0x4622c4(0x100)]({'title':_0x4d5d93[_0x4622c4(0xdd)]+'['[_0x4622c4(0xfe)](_0x4d5d93[_0x4622c4(0xeb)],']'),'info':_0x5da151+_0x4d5d93[_0x4622c4(0xbf)]+_0x12f9b3+_0x4d5d93['num'],'nRs':_0x4d5d93[_0x4622c4(0xea)],'unit':_0x4d5d93[_0x4622c4(0xbf)],'cb':_0x4d5d93[_0x4622c4(0xdf)],'type':_0x4622c4(0xff)});}),_0x33d9ef[_0x6cc980(0x100)](_0x2fa908);}var _0xce5752=_0x46f2fe[_0x6cc980(0xd6)](function(_0x52f4cc){var _0x366bb7=_0x6cc980;return _0x52f4cc[_0x366bb7(0x106)]==_0x366bb7(0xec);});if(_0xce5752[_0x6cc980(0xca)]){var _0x365988={'title':_0x51d90c[_0x6cc980(0xec)],'type':_0x6cc980(0xec),'list':[]};_0xce5752[_0x6cc980(0xf0)](function(_0x183c00){var _0x948979=_0x6cc980;_0x183c00[_0x948979(0xc5)]!='0'&&_0x365988[_0x948979(0xd1)][_0x948979(0x100)]({'title':_0x183c00[_0x948979(0xdd)]+'['[_0x948979(0xfe)](_0x720849[_0x948979(0xf1)],']'),'info':_0x5da151+_0x183c00[_0x948979(0xe2)]+_0x12f9b3+_0x183c00[_0x948979(0xc5)],'nRs':_0x183c00[_0x948979(0xc5)],'unit':_0x183c00[_0x948979(0xe2)],'cb':_0x183c00[_0x948979(0xcc)],'type':_0x948979(0xec)}),_0x183c00[_0x948979(0xc2)]!='0'&&_0x365988['list'][_0x948979(0x100)]({'title':_0x183c00[_0x948979(0xdd)]+'['[_0x948979(0xfe)](_0x720849['child'],']'),'info':_0x5da151+_0x183c00[_0x948979(0xfb)]+_0x12f9b3+_0x183c00[_0x948979(0xc2)],'nRs':_0x183c00[_0x948979(0xc2)],'unit':_0x183c00[_0x948979(0xfb)],'cb':_0x183c00['basechildprice'],'type':'trip'});}),_0x33d9ef['push'](_0x365988);}var _0x38fa61=[],_0x20c9a0=_0x46f2fe[_0x6cc980(0xd6)](function(_0x41d4bd){var _0x461ad2=_0x6cc980;return _0x41d4bd[_0x461ad2(0x106)]==_0x461ad2(0xc0);});_0x20c9a0[_0x6cc980(0xca)]&&_0x20c9a0['map'](function(_0x5a4798){var _0x54f528=_0x6cc980,_0x92ef13=_0x5a4798[_0x54f528(0xdd)][_0x54f528(0x102)]('|')||[''];_0x38fa61['push']({'title':_0x720849[_0x54f528(0xc0)]+'['[_0x54f528(0xfe)](_0x92ef13[0x0],']'),'info':_0x5da151+_0x5a4798[_0x54f528(0xdc)],'unit':_0x5a4798[_0x54f528(0xdc)],'cb':_0x5a4798[_0x54f528(0xdc)],'type':_0x54f528(0xc0)});});var _0x4c31a8=_0x46f2fe[_0x6cc980(0xd6)](function(_0x5f4d24){var _0x5abe35=_0x6cc980;return _0x5f4d24[_0x5abe35(0x106)]==_0x5abe35(0xc7);});_0x4c31a8['length']&&_0x4c31a8[_0x6cc980(0xf0)](function(_0x5aba00){var _0x33aad3=_0x6cc980;_0x38fa61[_0x33aad3(0x100)]({'title':_0x720849[_0x33aad3(0xe5)]+'['[_0x33aad3(0xfe)](_0x5aba00[_0x33aad3(0xdd)],']'),'info':_0x5da151+_0x5aba00[_0x33aad3(0xdc)],'unit':_0x5aba00[_0x33aad3(0xdc)],'cb':_0x5aba00['money'],'type':'vip'});});var _0x29ea02=_0x46f2fe[_0x6cc980(0xd6)](function(_0x52d091){var _0x7eecb4=_0x6cc980;return _0x52d091[_0x7eecb4(0x106)]=='promotion';});_0x29ea02['length']&&_0x29ea02[_0x6cc980(0xf0)](function(_0x4fe0bd){var _0x9897be=_0x6cc980;_0x38fa61[_0x9897be(0x100)]({'title':_0x720849['promotion'],'info':_0x5da151+_0x4fe0bd[_0x9897be(0xdc)],'unit':_0x4fe0bd[_0x9897be(0xdc)],'cb':_0x4fe0bd['money'],'type':_0x9897be(0xcd)});});_0x38fa61[_0x6cc980(0xca)]&&_0x33d9ef['push']({'title':_0x51d90c[_0x6cc980(0xdb)],'type':_0x6cc980(0xdb),'list':_0x38fa61});var _0x427ed6=_0x46f2fe[_0x6cc980(0xd6)](function(_0x2f02cf){var _0x4e31a6=_0x6cc980;return _0x2f02cf[_0x4e31a6(0x106)]=='airtax';});if(_0x427ed6[_0x6cc980(0xca)]){var _0x34c528={'title':_0x51d90c[_0x6cc980(0xed)],'type':_0x6cc980(0xed),'list':[]};_0x427ed6[_0x6cc980(0xf0)](function(_0x52d15b){var _0x34449d=_0x6cc980;_0x34c528[_0x34449d(0xd1)][_0x34449d(0x100)]({'title':_0x720849[_0x52d15b[_0x34449d(0xe0)]],'info':_0x5da151+_0x52d15b[_0x34449d(0xbf)]+_0x12f9b3+_0x52d15b['sl'],'nRs':_0x52d15b['sl'],'unit':_0x52d15b[_0x34449d(0xbf)],'cb':_0x52d15b[_0x34449d(0xf5)],'type':_0x52d15b[_0x34449d(0xe0)]});}),_0x33d9ef[_0x6cc980(0x100)](_0x34c528);}var _0x4b353e=[_0x6cc980(0xc8),_0x6cc980(0xff),_0x6cc980(0xec),'elder',_0x6cc980(0xc7),'promotion','airtax'],_0x29a4b8=_0x46f2fe[_0x6cc980(0xd6)](function(_0x1cae10){var _0x1c096e=_0x6cc980;return!_0x4b353e[_0x1c096e(0xe1)](_0x1cae10[_0x1c096e(0x106)]);}),_0x2afe49={'title':_0x51d90c['other'],'type':_0x6cc980(0xda),'list':[]};for(var _0x1d72bb=0x0;_0x1d72bb<_0x29a4b8[_0x6cc980(0xca)];_0x1d72bb++){var _0x148a19=_0x29a4b8[_0x1d72bb];_0x148a19[_0x6cc980(0x106)]==_0x6cc980(0xe9)&&_0x2afe49['list'][_0x6cc980(0x100)]({'title':_0x720849[_0x6cc980(0xe9)]+'['[_0x6cc980(0xfe)](_0x148a19[_0x6cc980(0xdd)],']'),'info':_0x5da151+_0x148a19[_0x6cc980(0xdc)],'unit':_0x148a19[_0x6cc980(0xdc)],'type':_0x148a19[_0x6cc980(0x106)]}),_0x148a19[_0x6cc980(0x106)]==_0x6cc980(0xd3)&&_0x2afe49['list'][_0x6cc980(0x100)]({'title':_0x720849[_0x6cc980(0xd3)]+'['[_0x6cc980(0xfe)](_0x148a19['name'],']'),'info':_0x5da151+_0x148a19[_0x6cc980(0xd4)]+_0x12f9b3+_0x148a19['users']+_0x720849['r'],'nRs':_0x148a19['users'],'unit':_0x148a19[_0x6cc980(0xd4)],'cb':_0x148a19['unit'],'type':_0x6cc980(0xd3)}),(_0x148a19[_0x6cc980(0x106)]==_0x6cc980(0x101)||_0x148a19['strLx']==_0x6cc980(0xde))&&_0x2afe49['list'][_0x6cc980(0x100)]({'title':_0x720849[_0x148a19[_0x6cc980(0x106)]],'info':_0x5da151+_0x148a19[_0x6cc980(0xdc)],'unit':_0x148a19[_0x6cc980(0xdc)],'type':_0x148a19[_0x6cc980(0x106)]}),_0x148a19['strLx']=='tip'&&_0x2afe49['list'][_0x6cc980(0x100)]({'title':_0x720849[_0x148a19[_0x6cc980(0x106)]],'info':_0x5da151+_0x148a19[_0x6cc980(0xe4)]+_0x12f9b3+_0x148a19[_0x6cc980(0x103)]+_0x720849['r']+_0x12f9b3+_0x148a19[_0x6cc980(0xd8)]+_0x720849['t'],'nRs':_0x148a19[_0x6cc980(0x103)],'count':_0x148a19['tipday'],'unit':_0x148a19[_0x6cc980(0xe4)],'type':_0x148a19[_0x6cc980(0x106)]}),_0x148a19[_0x6cc980(0x106)]==_0x6cc980(0xc1)&&_0x2afe49['list'][_0x6cc980(0x100)]({'title':_0x720849[_0x148a19[_0x6cc980(0x106)]],'info':_0x5da151+_0x148a19[_0x6cc980(0xc9)],'unit':_0x148a19['totaltax'],'type':_0x148a19[_0x6cc980(0x106)]});}_0x2afe49[_0x6cc980(0xd1)][_0x6cc980(0xca)]&&_0x33d9ef[_0x6cc980(0x100)](_0x2afe49);var _0x38e5df=_0x46f2fe['filter'](function(_0x4564a8){var _0x482ba1=_0x6cc980;return _0x4564a8[_0x482ba1(0x106)]==_0x482ba1(0xf3);});return _0x38e5df['length']&&_0x33d9ef['push']({'title':_0x51d90c[_0x6cc980(0xf3)],'type':_0x6cc980(0xf3),'list':[{'title':_0x51d90c['totalprice'],'info':_0x5da151+_0x38e5df[0x0][_0x6cc980(0xc3)]}]}),_0x33d9ef;}function a0_0x5bbe(_0x5e9f98,_0x3ad3ab){var _0x465d63=a0_0x465d();return a0_0x5bbe=function(_0x5bbebd,_0x52570f){_0x5bbebd=_0x5bbebd-0xbf;var _0x525332=_0x465d63[_0x5bbebd];return _0x525332;},a0_0x5bbe(_0x5e9f98,_0x3ad3ab);}var _default=exports['default']={'handleCosting':handleCosting};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var a1_0x1430ab=a1_0x43ee;function a1_0x15d2(){var _0x3034bd=['1810632yxYxGR','./func','default','3343870EWewAA','801594KOkBzr','180xRlFaC','__esModule','804367RZTFiT','defineProperty','10369488szbSam','20856708bwwymT','46677yoholB','35PBdYoL'];a1_0x15d2=function(){return _0x3034bd;};return a1_0x15d2();}(function(_0x57e169,_0xb25c52){var _0x332ed4=a1_0x43ee,_0x421c7c=_0x57e169();while(!![]){try{var _0x85ce3d=-parseInt(_0x332ed4(0xfd))/0x1+parseInt(_0x332ed4(0xfb))/0x2*(-parseInt(_0x332ed4(0x101))/0x3)+-parseInt(_0x332ed4(0xf6))/0x4+parseInt(_0x332ed4(0xf9))/0x5+-parseInt(_0x332ed4(0xfa))/0x6*(parseInt(_0x332ed4(0x102))/0x7)+parseInt(_0x332ed4(0xff))/0x8+parseInt(_0x332ed4(0x100))/0x9;if(_0x85ce3d===_0xb25c52)break;else _0x421c7c['push'](_0x421c7c['shift']());}catch(_0x357951){_0x421c7c['push'](_0x421c7c['shift']());}}}(a1_0x15d2,0xe9a72));Object[a1_0x1430ab(0xfe)](exports,a1_0x1430ab(0xfc),{'value':!![]}),exports[a1_0x1430ab(0xf8)]=void 0x0;var _utils=_interopRequireDefault(require('./utils')),_func=_interopRequireDefault(require(a1_0x1430ab(0xf7)));function _interopRequireDefault(_0xbcc71){var _0x123df8=a1_0x1430ab;return _0xbcc71&&_0xbcc71[_0x123df8(0xfc)]?_0xbcc71:{'default':_0xbcc71};}function a1_0x43ee(_0x3793ba,_0x3d528d){var _0x15d2a5=a1_0x15d2();return a1_0x43ee=function(_0x43ee7d,_0xa19de3){_0x43ee7d=_0x43ee7d-0xf6;var _0x44e9d2=_0x15d2a5[_0x43ee7d];return _0x44e9d2;},a1_0x43ee(_0x3793ba,_0x3d528d);}var _default=exports['default']={'utils':_utils[a1_0x1430ab(0xf8)],'func':_func[a1_0x1430ab(0xf8)]};
|
package/dist/test.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var a2_0x468a47=a2_0x16e3;(function(_0x19d7bf,_0x1d3466){var _0x3c26fa=a2_0x16e3,_0x3b2fec=_0x19d7bf();while(!![]){try{var _0x43eb1f=parseInt(_0x3c26fa(0x1b7))/0x1+-parseInt(_0x3c26fa(0x1a0))/0x2*(parseInt(_0x3c26fa(0x1b9))/0x3)+parseInt(_0x3c26fa(0x1bf))/0x4+-parseInt(_0x3c26fa(0x1b2))/0x5+-parseInt(_0x3c26fa(0x1c4))/0x6*(parseInt(_0x3c26fa(0x1a4))/0x7)+-parseInt(_0x3c26fa(0x1c9))/0x8*(parseInt(_0x3c26fa(0x1a3))/0x9)+parseInt(_0x3c26fa(0x1cd))/0xa;if(_0x43eb1f===_0x1d3466)break;else _0x3b2fec['push'](_0x3b2fec['shift']());}catch(_0x4f4356){_0x3b2fec['push'](_0x3b2fec['shift']());}}}(a2_0x39d5,0x4c2ea));Object[a2_0x468a47(0x1a7)](exports,'__esModule',{'value':!![]}),exports[a2_0x468a47(0x1ae)]=void 0x0;function _typeof(_0x1e0e92){'@babel/helpers - typeof';var _0x4f9fc5=a2_0x468a47;return _typeof=_0x4f9fc5(0x1c0)==typeof Symbol&&_0x4f9fc5(0x1b1)==typeof Symbol[_0x4f9fc5(0x1be)]?function(_0x2a72fb){return typeof _0x2a72fb;}:function(_0x43717c){var _0x9002d8=_0x4f9fc5;return _0x43717c&&_0x9002d8(0x1c0)==typeof Symbol&&_0x43717c[_0x9002d8(0x19c)]===Symbol&&_0x43717c!==Symbol[_0x9002d8(0x1b0)]?_0x9002d8(0x1b1):typeof _0x43717c;},_typeof(_0x1e0e92);}function _slicedToArray(_0x551d71,_0x36cb36){return _arrayWithHoles(_0x551d71)||_iterableToArrayLimit(_0x551d71,_0x36cb36)||_unsupportedIterableToArray(_0x551d71,_0x36cb36)||_nonIterableRest();}function _nonIterableRest(){var _0x474710=a2_0x468a47;throw new TypeError(_0x474710(0x1b5));}function _unsupportedIterableToArray(_0x595820,_0x455180){var _0x1b7661=a2_0x468a47;if(_0x595820){if('string'==typeof _0x595820)return _arrayLikeToArray(_0x595820,_0x455180);var _0x10e98a={}['toString'][_0x1b7661(0x1bc)](_0x595820)[_0x1b7661(0x1ca)](0x8,-0x1);return _0x1b7661(0x1bb)===_0x10e98a&&_0x595820[_0x1b7661(0x19c)]&&(_0x10e98a=_0x595820[_0x1b7661(0x19c)][_0x1b7661(0x1c3)]),_0x1b7661(0x1a6)===_0x10e98a||_0x1b7661(0x1c6)===_0x10e98a?Array[_0x1b7661(0x1c7)](_0x595820):'Arguments'===_0x10e98a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/['test'](_0x10e98a)?_arrayLikeToArray(_0x595820,_0x455180):void 0x0;}}function _arrayLikeToArray(_0x493990,_0x347174){var _0x346d1b=a2_0x468a47;(null==_0x347174||_0x347174>_0x493990[_0x346d1b(0x19e)])&&(_0x347174=_0x493990[_0x346d1b(0x19e)]);for(var _0x3a4832=0x0,_0xe3e210=Array(_0x347174);_0x3a4832<_0x347174;_0x3a4832++)_0xe3e210[_0x3a4832]=_0x493990[_0x3a4832];return _0xe3e210;}function _iterableToArrayLimit(_0x52000c,_0x1caf57){var _0x814487=a2_0x468a47,_0xead54f=null==_0x52000c?null:_0x814487(0x1a9)!=typeof Symbol&&_0x52000c[Symbol[_0x814487(0x1be)]]||_0x52000c[_0x814487(0x1b8)];if(null!=_0xead54f){var _0x233a5f,_0x5ea775,_0x5946ad,_0x5dff6f,_0x263dc2=[],_0x393f43=!0x0,_0x4d9c3a=!0x1;try{if(_0x5946ad=(_0xead54f=_0xead54f[_0x814487(0x1bc)](_0x52000c))['next'],0x0===_0x1caf57){if(Object(_0xead54f)!==_0xead54f)return;_0x393f43=!0x1;}else{for(;!(_0x393f43=(_0x233a5f=_0x5946ad['call'](_0xead54f))[_0x814487(0x1af)])&&(_0x263dc2[_0x814487(0x1a8)](_0x233a5f[_0x814487(0x1ab)]),_0x263dc2[_0x814487(0x19e)]!==_0x1caf57);_0x393f43=!0x0);}}catch(_0x5c28c3){_0x4d9c3a=!0x0,_0x5ea775=_0x5c28c3;}finally{try{if(!_0x393f43&&null!=_0xead54f[_0x814487(0x1b6)]&&(_0x5dff6f=_0xead54f[_0x814487(0x1b6)](),Object(_0x5dff6f)!==_0x5dff6f))return;}finally{if(_0x4d9c3a)throw _0x5ea775;}}return _0x263dc2;}}function _arrayWithHoles(_0x2b4c76){var _0x4ceb4d=a2_0x468a47;if(Array[_0x4ceb4d(0x19d)](_0x2b4c76))return _0x2b4c76;}function email(_0x1b0dd2){var _0x1a6ca5=a2_0x468a47;return/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/[_0x1a6ca5(0x1b4)](_0x1b0dd2);}function mobile(_0x5beb18){var _0x35a57a=a2_0x468a47;return/^1([3589]\d|4[5-9]|6[1-2,4-7]|7[0-8])\d{8}$/[_0x35a57a(0x1b4)](_0x5beb18);}function isValidPhoneNumber(_0x31b937){var _0xa24606=a2_0x468a47;if(_0x31b937[_0xa24606(0x1ad)]('-')){var _0x87a68e=_0x31b937[_0xa24606(0x1c1)]('-'),_0x331085=_slicedToArray(_0x87a68e,0x2),_0x467e75=_0x331085[0x0],_0x2db220=_0x331085[0x1];if(_0x467e75==='86')return/^\d{11}$/[_0xa24606(0x1b4)](_0x2db220)&&_0x2db220[_0xa24606(0x19b)]('1');else return _0x467e75===_0xa24606(0x1ac)?/^\d{8}$/[_0xa24606(0x1b4)](_0x2db220)&&['5','6','9','8'][_0xa24606(0x1ad)](_0x2db220['charAt'](0x0)):/^\d+$/['test'](_0x2db220);}else return/^\d+$/[_0xa24606(0x1b4)](_0x31b937);}function a2_0x39d5(){var _0x21064f=['slice','[object\x20Array]','catch','5436330dGzaob','startsWith','constructor','isArray','length','[object\x20Object]','12STektr','object','indexOf','25497Jigaxc','7naVHNS','string','Map','defineProperty','push','undefined','toString','value','852','includes','default','done','prototype','symbol','1225555SwEjAN','replace','test','Invalid\x20attempt\x20to\x20destructure\x20non-iterable\x20instance.\x0aIn\x20order\x20to\x20be\x20iterable,\x20non-array\x20objects\x20must\x20have\x20a\x20[Symbol.iterator]()\x20method.','return','53341oinKEl','@@iterator','139182RotHcn','[object\x20RegExp]','Object','call','parse','iterator','2393916chhxnc','function','split','boolean','name','306834IYkutd','then','Set','from','number','872apVAei'];a2_0x39d5=function(){return _0x21064f;};return a2_0x39d5();}function url(_0x2b6c2c){var _0x47c895=a2_0x468a47;return/^((https|http|ftp|rtsp|mms):\/\/)(([0-9a-zA-Z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z].[a-zA-Z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+\/?)$/[_0x47c895(0x1b4)](_0x2b6c2c);}function date(_0x22b84b){var _0x3c3426=a2_0x468a47;if(!_0x22b84b)return![];if(number(_0x22b84b))_0x22b84b=+_0x22b84b;return!/Invalid|NaN/[_0x3c3426(0x1b4)](new Date(_0x22b84b)[_0x3c3426(0x1aa)]());}function dateISO(_0x661559){var _0x3664fd=a2_0x468a47;return/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/[_0x3664fd(0x1b4)](_0x661559);}function isNumber(_0x30339f){var _0x5c87d9=a2_0x468a47;return/^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/[_0x5c87d9(0x1b4)](_0x30339f);}function isString(_0x4ab489){return typeof _0x4ab489==='string';}function digits(_0x184f55){var _0x187157=a2_0x468a47;return/^\d+$/[_0x187157(0x1b4)](_0x184f55);}function idCard(_0x1ff63c){var _0x21db37=a2_0x468a47;return/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/[_0x21db37(0x1b4)](_0x1ff63c);}function carNo(_0x144976){var _0x4f103d=a2_0x468a47,_0x3a4510=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/,_0x3c6d44=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;if(_0x144976[_0x4f103d(0x19e)]===0x7)return _0x3c6d44[_0x4f103d(0x1b4)](_0x144976);if(_0x144976['length']===0x8)return _0x3a4510['test'](_0x144976);return![];}function amount(_0x39e696){var _0x5691df=a2_0x468a47;return/^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/[_0x5691df(0x1b4)](_0x39e696);}function chinese(_0x3b51c5){var _0x49fc72=a2_0x468a47,_0x24b901=/^[\u4e00-\u9fa5]+$/gi;return _0x24b901[_0x49fc72(0x1b4)](_0x3b51c5);}function letter(_0x367bca){var _0x398eb4=a2_0x468a47;return/^[a-zA-Z]*$/[_0x398eb4(0x1b4)](_0x367bca);}function enOrNum(_0x41bbf2){var _0x127f96=a2_0x468a47,_0x327aad=/^[0-9a-zA-Z]*$/g;return _0x327aad[_0x127f96(0x1b4)](_0x41bbf2);}function contains(_0x22d63e,_0x510dfa){var _0x5eced9=a2_0x468a47;return _0x22d63e[_0x5eced9(0x1a2)](_0x510dfa)>=0x0;}function range(_0x421fc,_0x9d0a67){return _0x421fc>=_0x9d0a67[0x0]&&_0x421fc<=_0x9d0a67[0x1];}function rangeLength(_0x555e07,_0x356cf6){var _0x15da04=a2_0x468a47;return _0x555e07[_0x15da04(0x19e)]>=_0x356cf6[0x0]&&_0x555e07[_0x15da04(0x19e)]<=_0x356cf6[0x1];}function landline(_0x56aaf6){var _0x8a0123=a2_0x468a47,_0x594116=/^\d{3,4}-\d{7,8}(-\d{3,4})?$/;return _0x594116[_0x8a0123(0x1b4)](_0x56aaf6);}function empty(_0x1bcefa){var _0x5c7144=a2_0x468a47;switch(_typeof(_0x1bcefa)){case _0x5c7144(0x1a9):return!![];case _0x5c7144(0x1a5):if(_0x1bcefa[_0x5c7144(0x1b3)](/(^[ \t\n\r]*)|([ \t\n\r]*$)/g,'')[_0x5c7144(0x19e)]==0x0)return!![];break;case _0x5c7144(0x1c2):if(!_0x1bcefa)return!![];break;case'number':if(_0x1bcefa===0x0||isNaN(_0x1bcefa))return!![];break;case _0x5c7144(0x1a1):if(_0x1bcefa===null||_0x1bcefa[_0x5c7144(0x19e)]===0x0)return!![];for(var _0x40c858 in _0x1bcefa){return![];}return!![];}return![];}function jsonString(_0xb44ca9){var _0x2ca64d=a2_0x468a47;if(typeof _0xb44ca9===_0x2ca64d(0x1a5))try{var _0x1a49d6=JSON[_0x2ca64d(0x1bd)](_0xb44ca9);if(_typeof(_0x1a49d6)===_0x2ca64d(0x1a1)&&_0x1a49d6)return!![];return![];}catch(_0x39124e){return![];}return![];}function array(_0x5b7d68){var _0x5a17cf=a2_0x468a47;if(typeof Array[_0x5a17cf(0x19d)]===_0x5a17cf(0x1c0))return Array[_0x5a17cf(0x19d)](_0x5b7d68);return Object[_0x5a17cf(0x1b0)][_0x5a17cf(0x1aa)][_0x5a17cf(0x1bc)](_0x5b7d68)===_0x5a17cf(0x1cb);}function object(_0x629015){var _0x25afd7=a2_0x468a47;return Object[_0x25afd7(0x1b0)][_0x25afd7(0x1aa)][_0x25afd7(0x1bc)](_0x629015)===_0x25afd7(0x19f);}function code(_0x7c7919){var _0x1e6a8d=a2_0x468a47,_0x5afa46=arguments['length']>0x1&&arguments[0x1]!==undefined?arguments[0x1]:0x6;return new RegExp('^\x5cd{'['concat'](_0x5afa46,'}$'))[_0x1e6a8d(0x1b4)](_0x7c7919);}function func(_0xc01946){return typeof _0xc01946==='function';}function promise(_0x143617){var _0x88f0a6=a2_0x468a47;return object(_0x143617)&&func(_0x143617[_0x88f0a6(0x1c5)])&&func(_0x143617[_0x88f0a6(0x1cc)]);}function a2_0x16e3(_0x5a2684,_0x2dc716){var _0x39d501=a2_0x39d5();return a2_0x16e3=function(_0x16e3ac,_0x157a9c){_0x16e3ac=_0x16e3ac-0x19b;var _0x283d50=_0x39d501[_0x16e3ac];return _0x283d50;},a2_0x16e3(_0x5a2684,_0x2dc716);}function image(_0x2171d9){var _0x4c2568=a2_0x468a47,_0x47cf29=_0x2171d9[_0x4c2568(0x1c1)]('?')[0x0],_0x4a5a4c=/\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;return _0x4a5a4c[_0x4c2568(0x1b4)](_0x47cf29);}function video(_0x163c75){var _0x35bd1b=a2_0x468a47,_0x41f243=/\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i;return _0x41f243[_0x35bd1b(0x1b4)](_0x163c75);}function regExp(_0x3c2182){var _0x54fc4b=a2_0x468a47;return _0x3c2182&&Object[_0x54fc4b(0x1b0)][_0x54fc4b(0x1aa)][_0x54fc4b(0x1bc)](_0x3c2182)===_0x54fc4b(0x1ba);}function isNumeric(_0x4c31d0){var _0x29679f=a2_0x468a47,_0x5aa26c=arguments['length']>0x1&&arguments[0x1]!==undefined?arguments[0x1]:0x0;if(typeof _0x4c31d0===_0x29679f(0x1c8))_0x4c31d0=_0x4c31d0['toString']();if(typeof _0x4c31d0!==_0x29679f(0x1a5))return![];switch(_0x5aa26c){case 0x1:return/^\d+(\.\d+)?$/[_0x29679f(0x1b4)](_0x4c31d0);case 0x2:return/^-\d+(\.\d+)?$/[_0x29679f(0x1b4)](_0x4c31d0);case 0x3:return/^-?\d+$/[_0x29679f(0x1b4)](_0x4c31d0);case 0x4:return/^\d+$/[_0x29679f(0x1b4)](_0x4c31d0);case 0x5:return/^-\d+$/[_0x29679f(0x1b4)](_0x4c31d0);default:return/^-?\d*\.?\d*$/['test'](_0x4c31d0)&&!_0x4c31d0[_0x29679f(0x19b)]('.')&&!_0x4c31d0[_0x29679f(0x1ad)]('--');}}var _default=exports[a2_0x468a47(0x1ae)]={'isNumeric':isNumeric,'email':email,'mobile':mobile,'url':url,'date':date,'dateISO':dateISO,'isNumber':isNumber,'digits':digits,'idCard':idCard,'carNo':carNo,'amount':amount,'chinese':chinese,'letter':letter,'enOrNum':enOrNum,'contains':contains,'range':range,'rangeLength':rangeLength,'empty':empty,'jsonString':jsonString,'landline':landline,'object':object,'array':array,'code':code,'func':func,'promise':promise,'video':video,'image':image,'regExp':regExp,'isString':isString,'isValidPhoneNumber':isValidPhoneNumber};
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var a3_0x3dbf5c=a3_0x2a50;(function(_0x4a8471,_0xdc66d){var _0x3edd84=a3_0x2a50,_0x55429d=_0x4a8471();while(!![]){try{var _0x50f8bc=parseInt(_0x3edd84(0x223))/0x1+-parseInt(_0x3edd84(0x1f1))/0x2+parseInt(_0x3edd84(0x210))/0x3+-parseInt(_0x3edd84(0x20e))/0x4*(parseInt(_0x3edd84(0x220))/0x5)+parseInt(_0x3edd84(0x216))/0x6*(-parseInt(_0x3edd84(0x218))/0x7)+-parseInt(_0x3edd84(0x20f))/0x8*(-parseInt(_0x3edd84(0x1df))/0x9)+parseInt(_0x3edd84(0x21f))/0xa*(parseInt(_0x3edd84(0x205))/0xb);if(_0x50f8bc===_0xdc66d)break;else _0x55429d['push'](_0x55429d['shift']());}catch(_0x55ff1){_0x55429d['push'](_0x55429d['shift']());}}}(a3_0x5565,0x698e6));Object[a3_0x3dbf5c(0x1fe)](exports,'__esModule',{'value':!![]}),exports[a3_0x3dbf5c(0x1fc)]=void 0x0;function _createForOfIteratorHelper(_0x46bf32,_0x58b21a){var _0x20842d=a3_0x3dbf5c,_0x39189f=_0x20842d(0x1dd)!=typeof Symbol&&_0x46bf32[Symbol[_0x20842d(0x1e9)]]||_0x46bf32[_0x20842d(0x1f5)];if(!_0x39189f){if(Array[_0x20842d(0x1fa)](_0x46bf32)||(_0x39189f=_unsupportedIterableToArray(_0x46bf32))||_0x58b21a&&_0x46bf32&&_0x20842d(0x1e8)==typeof _0x46bf32[_0x20842d(0x20a)]){_0x39189f&&(_0x46bf32=_0x39189f);var _0x38ce26=0x0,_0x17bd4a=function _0x4c005f(){};return{'s':_0x17bd4a,'n':function _0x15a8ab(){return _0x38ce26>=_0x46bf32['length']?{'done':!0x0}:{'done':!0x1,'value':_0x46bf32[_0x38ce26++]};},'e':function _0x445550(_0x3dce2b){throw _0x3dce2b;},'f':_0x17bd4a};}throw new TypeError(_0x20842d(0x1ea));}var _0x3b564d,_0xd24d2=!0x0,_0x2bd9ff=!0x1;return{'s':function _0x164e4a(){var _0xb10ece=_0x20842d;_0x39189f=_0x39189f[_0xb10ece(0x21c)](_0x46bf32);},'n':function _0x2f1e11(){var _0x12b0aa=_0x20842d,_0x33c36e=_0x39189f[_0x12b0aa(0x1e4)]();return _0xd24d2=_0x33c36e[_0x12b0aa(0x225)],_0x33c36e;},'e':function _0x203ee6(_0x54b57c){_0x2bd9ff=!0x0,_0x3b564d=_0x54b57c;},'f':function _0x548507(){var _0x57adac=_0x20842d;try{_0xd24d2||null==_0x39189f[_0x57adac(0x202)]||_0x39189f['return']();}finally{if(_0x2bd9ff)throw _0x3b564d;}}};}function _typeof(_0x2fa181){'@babel/helpers - typeof';var _0x258df1=a3_0x3dbf5c;return _typeof='function'==typeof Symbol&&_0x258df1(0x208)==typeof Symbol[_0x258df1(0x1e9)]?function(_0x5c01b0){return typeof _0x5c01b0;}:function(_0x7693b9){var _0x1347c5=_0x258df1;return _0x7693b9&&_0x1347c5(0x203)==typeof Symbol&&_0x7693b9[_0x1347c5(0x1fb)]===Symbol&&_0x7693b9!==Symbol[_0x1347c5(0x207)]?_0x1347c5(0x208):typeof _0x7693b9;},_typeof(_0x2fa181);}function _slicedToArray(_0xe11331,_0x1c6155){return _arrayWithHoles(_0xe11331)||_iterableToArrayLimit(_0xe11331,_0x1c6155)||_unsupportedIterableToArray(_0xe11331,_0x1c6155)||_nonIterableRest();}function _nonIterableRest(){var _0x3982e1=a3_0x3dbf5c;throw new TypeError(_0x3982e1(0x209));}function _unsupportedIterableToArray(_0x309ccb,_0x35506e){var _0x340c95=a3_0x3dbf5c;if(_0x309ccb){if(_0x340c95(0x1f2)==typeof _0x309ccb)return _arrayLikeToArray(_0x309ccb,_0x35506e);var _0x4f3768={}['toString']['call'](_0x309ccb)[_0x340c95(0x20b)](0x8,-0x1);return _0x340c95(0x1e0)===_0x4f3768&&_0x309ccb[_0x340c95(0x1fb)]&&(_0x4f3768=_0x309ccb[_0x340c95(0x1fb)][_0x340c95(0x1f8)]),_0x340c95(0x1e2)===_0x4f3768||_0x340c95(0x224)===_0x4f3768?Array[_0x340c95(0x215)](_0x309ccb):_0x340c95(0x21d)===_0x4f3768||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/[_0x340c95(0x21a)](_0x4f3768)?_arrayLikeToArray(_0x309ccb,_0x35506e):void 0x0;}}function _arrayLikeToArray(_0x15c45e,_0x3b3abe){var _0x2400c3=a3_0x3dbf5c;(null==_0x3b3abe||_0x3b3abe>_0x15c45e[_0x2400c3(0x20a)])&&(_0x3b3abe=_0x15c45e[_0x2400c3(0x20a)]);for(var _0x1c5021=0x0,_0x22e83d=Array(_0x3b3abe);_0x1c5021<_0x3b3abe;_0x1c5021++)_0x22e83d[_0x1c5021]=_0x15c45e[_0x1c5021];return _0x22e83d;}function _iterableToArrayLimit(_0x101270,_0x11acca){var _0x2ba4ac=a3_0x3dbf5c,_0x5f19d4=null==_0x101270?null:'undefined'!=typeof Symbol&&_0x101270[Symbol[_0x2ba4ac(0x1e9)]]||_0x101270[_0x2ba4ac(0x1f5)];if(null!=_0x5f19d4){var _0x59184a,_0x903f81,_0x245bfd,_0x4ac9dc,_0xccbd8c=[],_0x4a1f85=!0x0,_0x43c650=!0x1;try{if(_0x245bfd=(_0x5f19d4=_0x5f19d4['call'](_0x101270))[_0x2ba4ac(0x1e4)],0x0===_0x11acca){if(Object(_0x5f19d4)!==_0x5f19d4)return;_0x4a1f85=!0x1;}else{for(;!(_0x4a1f85=(_0x59184a=_0x245bfd['call'](_0x5f19d4))['done'])&&(_0xccbd8c['push'](_0x59184a[_0x2ba4ac(0x211)]),_0xccbd8c['length']!==_0x11acca);_0x4a1f85=!0x0);}}catch(_0x3787fe){_0x43c650=!0x0,_0x903f81=_0x3787fe;}finally{try{if(!_0x4a1f85&&null!=_0x5f19d4[_0x2ba4ac(0x202)]&&(_0x4ac9dc=_0x5f19d4[_0x2ba4ac(0x202)](),Object(_0x4ac9dc)!==_0x4ac9dc))return;}finally{if(_0x43c650)throw _0x903f81;}}return _0xccbd8c;}}function _arrayWithHoles(_0x344bf3){var _0x36d86f=a3_0x3dbf5c;if(Array[_0x36d86f(0x1fa)](_0x344bf3))return _0x344bf3;}function fmtNum(_0xb8b82c){var _0x5069f5=a3_0x3dbf5c;if(_0xb8b82c==0x0)return'0';if(!_0xb8b82c)return'';var _0x26d04e=typeof _0xb8b82c===_0x5069f5(0x1f2)?parseFloat(_0xb8b82c):_0xb8b82c;if(isNaN(_0x26d04e))return'';return _0x26d04e[_0x5069f5(0x206)]('en-US',{'minimumFractionDigits':0x0,'maximumFractionDigits':0x2});}function splitName(_0x1c2238){var _0x207f5d=a3_0x3dbf5c,_0x2cfd28=arguments[_0x207f5d(0x20a)]>0x1&&arguments[0x1]!==undefined?arguments[0x1]:![],_0x3859bf={'surname':'','givenName':''};if(_0x2cfd28){var _0x2ffe8a=_0x1c2238[_0x207f5d(0x204)](',')?_0x1c2238[_0x207f5d(0x1f6)](','):_0x1c2238[_0x207f5d(0x1f6)](/\s+/);_0x2ffe8a[_0x207f5d(0x20a)]>=0x2&&(_0x3859bf[_0x207f5d(0x1eb)]=_0x2ffe8a[0x0]['trim'](),_0x3859bf[_0x207f5d(0x21b)]=_0x2ffe8a[0x1]['trim']());}else{var _0x168cbd=['欧阳','太史','端木','上官','司马','东方','独孤','南宫','万俟','闻人','夏侯','诸葛','尉迟','公羊','赫连','澹台','皇甫','宗政','濮阳','公冶','太叔','申屠','公孙','慕容','仲孙','钟离','长孙','宇文','司徒','鲜于','司空','闾丘','子车','亓官','司寇','巫马','公西','颛孙','壤驷','公良','漆雕','乐正','宰父','谷梁','拓跋','夹谷','轩辕','令狐','段干','百里','呼延','东郭','南门','羊舌','微生','公户','公玉','公仪','梁丘','公仲','公上','公门','公山','公坚','左丘','公伯','西门','公祖','第五','公乘','贯丘','公皙','南荣','东里','东宫','仲长','子书','子桑','即墨','达奚','褚师','吴铭','歐陽','太史','端木','上官','司馬','東方','獨孤','南宮','萬俟','聞人','夏侯','諸葛','尉遲','公羊','赫連','澹臺','皇甫','宗政','濮陽','公冶','太叔','申屠','公孫','慕容','仲孫','鐘離','長孫','宇文','司徒','鮮於','司空','閭丘','子車','亓官','司寇','巫馬','公西','顓孫','壤駟','公良','漆雕','樂正','宰父','穀梁','拓跋','夾谷','軒轅','令狐','段幹','百里','呼延','東郭','南門','羊舌','微生','公戶','公玉','公儀','梁丘','公仲','公上','公門','公山','公堅','左丘','公伯','西門','公祖','第五','公乘','貫丘','公皙','南榮','東里','東宮','仲長','子書','子桑','即墨','達奚','褚師','吳銘'];for(var _0x91b877=0x0;_0x91b877<_0x168cbd[_0x207f5d(0x20a)];_0x91b877++){var _0xc46120=_0x168cbd[_0x91b877];if(_0x1c2238[_0x207f5d(0x1de)](_0xc46120))return _0x3859bf[_0x207f5d(0x1eb)]=_0xc46120,_0x3859bf[_0x207f5d(0x21b)]=_0x1c2238[_0x207f5d(0x212)](_0xc46120[_0x207f5d(0x20a)])[_0x207f5d(0x1ff)](),_0x3859bf;}var _0x4dbf9a=_0x1c2238[_0x207f5d(0x1f6)]('\x20');if(_0x4dbf9a['length']===0x1){var _0x2cd769=_0x1c2238['match'](/[\u4e00-\u9fa5]/);_0x3859bf[_0x207f5d(0x1eb)]=_0x2cd769?_0x2cd769[0x0]:'',_0x3859bf[_0x207f5d(0x21b)]=_0x1c2238[_0x207f5d(0x1f3)](_0x3859bf[_0x207f5d(0x1eb)],'')[_0x207f5d(0x1ff)]();}else _0x3859bf[_0x207f5d(0x1eb)]=_0x4dbf9a[0x0],_0x3859bf[_0x207f5d(0x21b)]=_0x4dbf9a['slice'](0x1)['join']('\x20');}return _0x3859bf;}function modifyKeys(_0x40085e){var _0x4e22e7=a3_0x3dbf5c,_0x44f1d3=arguments[_0x4e22e7(0x20a)]>0x1&&arguments[0x1]!==undefined?arguments[0x1]:{'strCode':_0x4e22e7(0x20c),'strFjbh':'fjbh','strGuid':_0x4e22e7(0x211),'strValue':'label'};if(!_0x40085e[_0x4e22e7(0x20a)]||_0x40085e===null)return[];var _0x5ceab6=_0x40085e[_0x4e22e7(0x219)](function(_0x2678c2){var _0x1a4856=_0x4e22e7,_0x39ac54={};for(var _0x10b3b0 in _0x2678c2){_0x44f1d3[_0x1a4856(0x1f4)](_0x10b3b0)?_0x39ac54[_0x44f1d3[_0x10b3b0]]=_0x2678c2[_0x10b3b0]:_0x39ac54[_0x10b3b0]=_0x2678c2[_0x10b3b0];}return _0x39ac54;});return _0x5ceab6;}function sliceArray(_0x2ee9c3,_0xca4e60,_0x3b2640){var _0x27f582=a3_0x3dbf5c;if(_0xca4e60<=0x0)return console[_0x27f582(0x1e7)](_0x27f582(0x1f7)),[];return _0x3b2640?_0x2ee9c3[_0x27f582(0x20b)](0x0,_0xca4e60):_0x2ee9c3[_0x27f582(0x20b)](-_0xca4e60);}function findDataByData(_0x3f2880,_0x846b91,_0x314fad){var _0x2c042d=a3_0x3dbf5c,_0x50964f=_0x3f2880[_0x2c042d(0x200)](function(_0x9bbd61){return _0x9bbd61[_0x314fad]===_0x846b91;});return _0x50964f||null;}function splitArray(_0x1a7574,_0x51fbfc){var _0x4e05da=a3_0x3dbf5c,_0x586204=[];for(var _0x9a635c=0x0;_0x9a635c<_0x1a7574[_0x4e05da(0x20a)];_0x9a635c+=_0x51fbfc){_0x586204[_0x4e05da(0x1f0)](_0x1a7574[_0x4e05da(0x20b)](_0x9a635c,_0x9a635c+_0x51fbfc));}return _0x586204;}function getProxyType(_0x2b680a){var _0x1f69dd=a3_0x3dbf5c;return Object[_0x1f69dd(0x207)][_0x1f69dd(0x201)][_0x1f69dd(0x21c)](_0x2b680a)[_0x1f69dd(0x20b)](0x8,-0x1);}var timeout=null;function debounce(_0x4bd59d){var _0x9c8128=a3_0x3dbf5c,_0xada249=arguments[_0x9c8128(0x20a)]>0x1&&arguments[0x1]!==undefined?arguments[0x1]:0x1f4,_0x1dc222=arguments[_0x9c8128(0x20a)]>0x2&&arguments[0x2]!==undefined?arguments[0x2]:![];if(timeout!==null)clearTimeout(timeout);if(_0x1dc222){var _0x1feef9=!timeout;timeout=setTimeout(function(){timeout=null;},_0xada249);if(_0x1feef9)typeof _0x4bd59d===_0x9c8128(0x203)&&_0x4bd59d();}else timeout=setTimeout(function(){var _0x42053c=_0x9c8128;typeof _0x4bd59d===_0x42053c(0x203)&&_0x4bd59d();},_0xada249);}function matchKeyValueInArray(_0x2f14a3,_0x3e3a1e,_0x2e0013){var _0x387d51=a3_0x3dbf5c;for(var _0x4d35eb=0x0;_0x4d35eb<_0x2f14a3[_0x387d51(0x20a)];_0x4d35eb++){if(_0x2f14a3[_0x4d35eb][_0x3e3a1e]===_0x2e0013)return!![];}return![];}function urlEncode(){var _0x423545=a3_0x3dbf5c,_0x9dd9a0=arguments[_0x423545(0x20a)]>0x0&&arguments[0x0]!==undefined?arguments[0x0]:{},_0x274110=[],_0x470ccf=function _0x1ff936(_0x4e7e48){var _0x30962b=_0x423545,_0x1ef758=_0x9dd9a0[_0x4e7e48];if(!_0x1ef758)return 0x1;isArray(_0x1ef758)?_0x1ef758[_0x30962b(0x1ee)](function(_0x49be4d){var _0x403d0d=_0x30962b;_0x274110[_0x403d0d(0x1f0)](_0x4e7e48+'='+_0x49be4d);}):_0x274110[_0x30962b(0x1f0)](_0x4e7e48+'='+_0x1ef758);};for(var _0x563aff in _0x9dd9a0){if(_0x470ccf(_0x563aff))continue;}return _0x274110[_0x423545(0x1e5)]('&');}function compareDates(_0x54fd3d,_0x457558){var _0x40c64c=a3_0x3dbf5c;_0x54fd3d=new Date(_0x54fd3d);!_0x457558?_0x457558=new Date():_0x457558=new Date(_0x457558);_0x54fd3d['setHours'](0x0,0x0,0x0,0x0),_0x457558['setHours'](0x0,0x0,0x0,0x0);var _0x4bbd8f=_0x54fd3d['getTime'](),_0x512da1=_0x457558[_0x40c64c(0x1e3)]();if(_0x4bbd8f<_0x512da1)return-0x1;else return _0x4bbd8f>_0x512da1?0x1:0x0;}function getDaysBetween(_0x54633e,_0x10bfa2){var _0x5eeb1b=a3_0x3dbf5c,_0x329e8a=new Date(_0x54633e),_0x2552ed=new Date(_0x10bfa2),_0x1a43a1=Math[_0x5eeb1b(0x1e6)](_0x329e8a[_0x5eeb1b(0x1e3)]()-_0x2552ed['getTime']()),_0x32de2f=Math[_0x5eeb1b(0x1e1)](_0x1a43a1/(0x3e8*0x3c*0x3c*0x18));return _0x32de2f+0x1;}function chineseNumeral(_0x196f9c){var _0x3cea1c=a3_0x3dbf5c,_0x5479e4=['零','壹','贰','叁','肆','伍','陆','柒','捌','玖'],_0x24a41d=['','拾','佰','仟'],_0x224234=['','万','亿','兆'],_0x60a545=Math[_0x3cea1c(0x1e1)](_0x196f9c),_0x569766=Math[_0x3cea1c(0x214)]((_0x196f9c-_0x60a545)*0x64),_0x2a1269='';for(var _0x3e20d4=0x0;_0x60a545>0x0;_0x3e20d4++){var _0x5b4f73='',_0x3b0b71=_0x60a545%0x2710;_0x60a545=Math[_0x3cea1c(0x1e1)](_0x60a545/0x2710);for(var _0x4f9508=0x0;_0x3b0b71>0x0;_0x4f9508++){var _0x2b6ed9=_0x3b0b71%0xa;_0x5b4f73=(_0x2b6ed9?_0x5479e4[_0x2b6ed9]+_0x24a41d[_0x4f9508]:'')+_0x5b4f73,_0x3b0b71=Math[_0x3cea1c(0x1e1)](_0x3b0b71/0xa);}_0x2a1269=_0x5b4f73+(_0x5b4f73?_0x224234[_0x3e20d4]:_0x224234[_0x3e20d4]&&!_0x2a1269['includes']('零')?'零':'')+_0x2a1269;}_0x2a1269+=_0x2a1269?'元':'零元';if(_0x569766>0x0){var _0x4ccecf=Math[_0x3cea1c(0x1e1)](_0x569766/0xa),_0x3f4b8c=_0x569766%0xa;_0x2a1269+=(_0x4ccecf?_0x5479e4[_0x4ccecf]+'角':'')+(_0x3f4b8c?_0x5479e4[_0x3f4b8c]+'分':'');}else _0x2a1269+='整';return _0x2a1269[_0x3cea1c(0x1f3)](/零{2,}/g,'零')[_0x3cea1c(0x1f3)](/零元/,'元');}function getMonthDate(_0x15f05e){var _0x5caf52=a3_0x3dbf5c;(!_0x15f05e||_0x15f05e['trim']()==='')&&(_0x15f05e=''[_0x5caf52(0x20d)](new Date()[_0x5caf52(0x21e)](),'-')[_0x5caf52(0x20d)](new Date()[_0x5caf52(0x1ec)]()+0x1));var _0x372212=[],_0x4e08f3=_0x15f05e[_0x5caf52(0x1f6)]('-')[_0x5caf52(0x219)](Number),_0xd39552=_slicedToArray(_0x4e08f3,0x2),_0x2e2d66=_0xd39552[0x0],_0x4efbd5=_0xd39552[0x1],_0x4ca88d=new Date(_0x2e2d66,_0x4efbd5,0x0),_0x4b3a0b=_0x4ca88d[_0x5caf52(0x1fd)]();for(var _0x2d785d=0x1;_0x2d785d<=_0x4b3a0b;_0x2d785d++){var _0x3565e9=_0x2d785d<0xa?'0'[_0x5caf52(0x20d)](_0x2d785d):''[_0x5caf52(0x20d)](_0x2d785d),_0x5f586c=_0x4efbd5<0xa?'0'[_0x5caf52(0x20d)](_0x4efbd5):''[_0x5caf52(0x20d)](_0x4efbd5);_0x372212[_0x5caf52(0x1f0)]({'date':''[_0x5caf52(0x20d)](_0x2e2d66,'-')[_0x5caf52(0x20d)](_0x5f586c,'-')[_0x5caf52(0x20d)](_0x3565e9),'disable':!![]});}return _0x372212;}function a3_0x2a50(_0x5312a5,_0x57ab83){var _0x55650c=a3_0x5565();return a3_0x2a50=function(_0x2a501f,_0x7f7b84){_0x2a501f=_0x2a501f-0x1dd;var _0x16846c=_0x55650c[_0x2a501f];return _0x16846c;},a3_0x2a50(_0x5312a5,_0x57ab83);}function a3_0x5565(){var _0x322be8=['prototype','symbol','Invalid\x20attempt\x20to\x20destructure\x20non-iterable\x20instance.\x0aIn\x20order\x20to\x20be\x20iterable,\x20non-array\x20objects\x20must\x20have\x20a\x20[Symbol.iterator]()\x20method.','length','slice','code','concat','4TBbtjo','36248zyzTFQ','830457iJVaPr','value','substring','除数不能为0','round','from','18wtIqEB','padStart','661955aWXYNP','map','test','givenName','call','Arguments','getFullYear','308280yxvAey','2854450WyMKrv','stringify','object','195836jJjlkj','Set','done','undefined','startsWith','981aczReF','Object','floor','Map','getTime','next','join','abs','error','number','iterator','Invalid\x20attempt\x20to\x20iterate\x20non-iterable\x20instance.\x0aIn\x20order\x20to\x20be\x20iterable,\x20non-array\x20objects\x20must\x20have\x20a\x20[Symbol.iterator]()\x20method.','surname','getMonth','boolean','forEach','无效的操作符,操作符应为1、2、3或4','push','1270518mpNlzj','string','replace','hasOwnProperty','@@iterator','split','Quantity\x20should\x20be\x20greater\x20than\x200.','name','parse','isArray','constructor','default','getDate','defineProperty','trim','find','toString','return','function','includes','341AkBOJq','toLocaleString'];a3_0x5565=function(){return _0x322be8;};return a3_0x5565();}function getToday(_0x1493f2){var _0x5a69e5=a3_0x3dbf5c,_0x573a37=new Date(),_0xfede47=String(_0x573a37[_0x5a69e5(0x1fd)]())[_0x5a69e5(0x217)](0x2,'0'),_0x28100f=String(_0x573a37[_0x5a69e5(0x1ec)]()+0x1)[_0x5a69e5(0x217)](0x2,'0'),_0x4ea41c=_0x573a37[_0x5a69e5(0x21e)]();return _0x573a37=_0x4ea41c+'-'+_0x28100f+'-'+_0xfede47,_0x573a37;}function resetObject(_0x15852f){var _0x2acd3a=a3_0x3dbf5c,_0x2d1e02=JSON[_0x2acd3a(0x1f9)](JSON[_0x2acd3a(0x221)](_0x15852f));for(var _0x32e0eb in _0x2d1e02){if(typeof _0x2d1e02[_0x32e0eb]===_0x2acd3a(0x1e8))_0x2d1e02[_0x32e0eb]=0x0;else{if(typeof _0x2d1e02[_0x32e0eb]===_0x2acd3a(0x1ed))_0x2d1e02[_0x32e0eb]=![];else{if(Array[_0x2acd3a(0x1fa)](_0x2d1e02[_0x32e0eb]))_0x2d1e02[_0x32e0eb]=[];else _typeof(_0x2d1e02[_0x32e0eb])===_0x2acd3a(0x222)&&_0x2d1e02[_0x32e0eb]!==null?resetObject(_0x2d1e02[_0x32e0eb]):_0x2d1e02[_0x32e0eb]='';}}}return _0x2d1e02;}function preciseOperation(_0x5aa167,_0x56b7f6,_0x155a6e){var _0x15061b=a3_0x3dbf5c,_0x1fdcc4=arguments[_0x15061b(0x20a)]>0x3&&arguments[0x3]!==undefined?arguments[0x3]:0xf4240;if(isNaN(_0x5aa167)||isNaN(_0x56b7f6))return NaN;if(!isFinite(_0x5aa167)||!isFinite(_0x56b7f6))return NaN;var _0x33b044=BigInt(Math[_0x15061b(0x214)](_0x5aa167*_0x1fdcc4)),_0x227694=BigInt(Math[_0x15061b(0x214)](_0x56b7f6*_0x1fdcc4)),_0x565c3b;switch(_0x155a6e){case 0x1:_0x565c3b=_0x33b044+_0x227694;break;case 0x2:_0x565c3b=_0x33b044-_0x227694;break;case 0x3:_0x565c3b=_0x33b044*_0x227694;break;case 0x4:if(_0x227694===0x0n)throw new Error(_0x15061b(0x213));_0x565c3b=_0x33b044/_0x227694;break;default:throw new Error(_0x15061b(0x1ef));}return Number(_0x565c3b)/_0x1fdcc4;}function preciseSum(_0x4f4a5e){var _0x1b570f=a3_0x3dbf5c,_0x94a9ae=0x0,_0x2c6cd1=_createForOfIteratorHelper(_0x4f4a5e),_0x12cf43;try{for(_0x2c6cd1['s']();!(_0x12cf43=_0x2c6cd1['n']())[_0x1b570f(0x225)];){var _0x1bca40=_0x12cf43['value'],_0x2ff885=0x0;if(typeof _0x1bca40===_0x1b570f(0x1f2)){var _0x11654e=parseFloat(_0x1bca40);!isNaN(_0x11654e)&&(_0x2ff885=_0x11654e);}else typeof _0x1bca40==='number'&&(_0x2ff885=_0x1bca40);_0x94a9ae=preciseOperation(_0x94a9ae,_0x2ff885,0x1);}}catch(_0x4629a9){_0x2c6cd1['e'](_0x4629a9);}finally{_0x2c6cd1['f']();}return _0x94a9ae;}function getRelativeDate(_0x122bf3){var _0x38777a=a3_0x3dbf5c,_0x344b36=arguments['length']>0x1&&arguments[0x1]!==undefined?arguments[0x1]:0x0,_0x179de2=new Date(_0x122bf3);_0x179de2['setDate'](_0x179de2[_0x38777a(0x1fd)]()+_0x344b36);var _0x186abd=_0x179de2[_0x38777a(0x21e)](),_0x4a3431=(_0x179de2[_0x38777a(0x1ec)]()+0x1)['toString']()[_0x38777a(0x217)](0x2,'0'),_0x1e00b5=_0x179de2[_0x38777a(0x1fd)]()[_0x38777a(0x201)]()['padStart'](0x2,'0');return''[_0x38777a(0x20d)](_0x186abd,'-')['concat'](_0x4a3431,'-')[_0x38777a(0x20d)](_0x1e00b5);}function validateFields(_0x210c8f,_0x39a146){var _0x6d0714=a3_0x3dbf5c,_0x40206f=arguments[_0x6d0714(0x20a)]>0x2&&arguments[0x2]!==undefined?arguments[0x2]:'',_0x15b9e2=_createForOfIteratorHelper(_0x39a146),_0x1028fb;try{for(_0x15b9e2['s']();!(_0x1028fb=_0x15b9e2['n']())[_0x6d0714(0x225)];){var _0x50435e=_0x1028fb[_0x6d0714(0x211)];if(_0x210c8f[_0x50435e]===_0x40206f)return!![];}}catch(_0x36d018){_0x15b9e2['e'](_0x36d018);}finally{_0x15b9e2['f']();}return![];}function mergeObjects(_0x2ac313,_0x111a64){var _0x5be804=a3_0x3dbf5c;for(var _0x132c44 in _0x2ac313){_0x111a64[_0x5be804(0x1f4)](_0x132c44)&&(_0x2ac313[_0x132c44]=_0x111a64[_0x132c44]);}return _0x2ac313;}var _default=exports[a3_0x3dbf5c(0x1fc)]={'fmtNum':fmtNum,'splitName':splitName,'preciseSum':preciseSum,'modifyKeys':modifyKeys,'sliceArray':sliceArray,'findDataByData':findDataByData,'splitArray':splitArray,'getProxyType':getProxyType,'debounce':debounce,'matchKeyValueInArray':matchKeyValueInArray,'urlEncode':urlEncode,'compareDates':compareDates,'getDaysBetween':getDaysBetween,'chineseNumeral':chineseNumeral,'getMonthDate':getMonthDate,'getToday':getToday,'resetObject':resetObject,'preciseOperation':preciseOperation,'getRelativeDate':getRelativeDate,'validateFields':validateFields,'mergeObjects':mergeObjects};
|
package/package.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yunlin",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "
|
|
5
|
-
"module": "
|
|
3
|
+
"version": "1.0.21",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"require": "./dist/index.js",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
6
15
|
"type": "module",
|
|
7
16
|
"scripts": {
|
|
8
17
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -19,4 +28,4 @@
|
|
|
19
28
|
"@babel/preset-env": "^7.26.0",
|
|
20
29
|
"javascript-obfuscator": "^4.1.1"
|
|
21
30
|
}
|
|
22
|
-
}
|
|
31
|
+
}
|
package/src/func.js
DELETED
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 计价数据格式处理
|
|
3
|
-
* @param {Object} valList 价格数据数组
|
|
4
|
-
* @param {Object} hbfh 货币符号
|
|
5
|
-
* @param {Object} title 自定义标题
|
|
6
|
-
*/
|
|
7
|
-
function handleCosting(valList, hbfh = '¥', titles = {
|
|
8
|
-
people: '人員費用',
|
|
9
|
-
service: '附加服務',
|
|
10
|
-
trip: '附加行程',
|
|
11
|
-
other: '其他費用',
|
|
12
|
-
reduction: '減免費用',
|
|
13
|
-
totalprice: '總計',
|
|
14
|
-
airtax: '機場稅',
|
|
15
|
-
}, keys = {
|
|
16
|
-
//键名对应 数据返回键名对应显示标题 与其他拓展
|
|
17
|
-
adult: '成人',
|
|
18
|
-
child: '兒童',
|
|
19
|
-
childusebed: '兒童[占床]',
|
|
20
|
-
infant: '嬰兒',
|
|
21
|
-
half: '拼房',
|
|
22
|
-
//其他拓展
|
|
23
|
-
tip: '小費',
|
|
24
|
-
elder: '長者減免',
|
|
25
|
-
vip: '會員減免',
|
|
26
|
-
promotion: '促銷',
|
|
27
|
-
insure: '保險費用',
|
|
28
|
-
coupon: '優惠券',
|
|
29
|
-
point: '積分',
|
|
30
|
-
tax: '稅金',
|
|
31
|
-
viprecharge: '會員充值',
|
|
32
|
-
r: '人',
|
|
33
|
-
t: '天',
|
|
34
|
-
}) {
|
|
35
|
-
let list = []
|
|
36
|
-
const rideIcon = ' * '
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//取出人员明细
|
|
40
|
-
const peopleList = valList.filter(item => item.strLx == 'base')
|
|
41
|
-
if (peopleList.length) {
|
|
42
|
-
let val = {
|
|
43
|
-
title: titles['people'],
|
|
44
|
-
type: 'base',
|
|
45
|
-
list: []
|
|
46
|
-
}
|
|
47
|
-
peopleList.map(item => {
|
|
48
|
-
val.list.push({
|
|
49
|
-
title: keys[item.strJgbm], //标题
|
|
50
|
-
info: hbfh + item.fLsjUnit + rideIcon + item.nRs, //描述
|
|
51
|
-
nRs: item.nRs, //人数
|
|
52
|
-
unit: item.fLsjUnit, //单价
|
|
53
|
-
cb: item.fJcbzlsjUnit, //成本
|
|
54
|
-
type: 'base'
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
list.push(val)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
//附加服务
|
|
61
|
-
const serviceList = valList.filter(item => item.strLx == 'service')
|
|
62
|
-
if (serviceList.length) {
|
|
63
|
-
let val = {
|
|
64
|
-
title: titles['service'],
|
|
65
|
-
type: 'service',
|
|
66
|
-
list: []
|
|
67
|
-
}
|
|
68
|
-
serviceList.map(item => {
|
|
69
|
-
val.list.push({
|
|
70
|
-
title: item.name + `[${item.itemname}]`, //标题
|
|
71
|
-
info: hbfh + item.unitprice + rideIcon + item.num, //描述
|
|
72
|
-
nRs: item.num, //人数
|
|
73
|
-
unit: item.unitprice, //单价
|
|
74
|
-
cb: item.baseprice, //成本
|
|
75
|
-
type: 'service'
|
|
76
|
-
})
|
|
77
|
-
})
|
|
78
|
-
list.push(val)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
//附加行程
|
|
82
|
-
const tripList = valList.filter(item => item.strLx == 'trip')
|
|
83
|
-
if (tripList.length) {
|
|
84
|
-
let val = {
|
|
85
|
-
title: titles['trip'],
|
|
86
|
-
type: 'trip',
|
|
87
|
-
list: []
|
|
88
|
-
}
|
|
89
|
-
tripList.map(item => {
|
|
90
|
-
if (item.adultnum != '0') {
|
|
91
|
-
val.list.push({
|
|
92
|
-
title: item.name + `[${keys['adult']}]`, //成人
|
|
93
|
-
info: hbfh + item.adultprice + rideIcon + item.adultnum, //描述
|
|
94
|
-
nRs: item.adultnum, //人数
|
|
95
|
-
unit: item.adultprice, //单价
|
|
96
|
-
cb: item.baseadultprice, //成本
|
|
97
|
-
type: 'trip'
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
if (item.childnum != '0') {
|
|
101
|
-
val.list.push({
|
|
102
|
-
title: item.name + `[${keys['child']}]`, //儿童
|
|
103
|
-
info: hbfh + item.childprice + rideIcon + item.childnum, //描述
|
|
104
|
-
nRs: item.childnum, //人数
|
|
105
|
-
unit: item.childprice, //单价
|
|
106
|
-
cb: item.basechildprice, //成本
|
|
107
|
-
type: 'trip'
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
list.push(val)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
let reductionList = []
|
|
115
|
-
//长者减免
|
|
116
|
-
const elderList = valList.filter(item => item.strLx == 'elder')
|
|
117
|
-
if (elderList.length) {
|
|
118
|
-
elderList.map(item => {
|
|
119
|
-
const parts = item.name.split("|") || [''];
|
|
120
|
-
reductionList.push({
|
|
121
|
-
title: keys['elder'] + `[${parts[0]}]`,
|
|
122
|
-
info: hbfh + item.money, //描述
|
|
123
|
-
unit: item.money, //单价
|
|
124
|
-
cb: item.money, //成本
|
|
125
|
-
type: 'elder'
|
|
126
|
-
})
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
//会员减免
|
|
130
|
-
const vipList = valList.filter(item => item.strLx == 'vipdiscounted')
|
|
131
|
-
if (vipList.length) {
|
|
132
|
-
vipList.map(item => {
|
|
133
|
-
reductionList.push({
|
|
134
|
-
title: keys['vip'] + `[${item.name}]`,
|
|
135
|
-
info: hbfh + item.money, //描述
|
|
136
|
-
unit: item.money, //单价
|
|
137
|
-
cb: item.money, //成本
|
|
138
|
-
type: 'vip'
|
|
139
|
-
})
|
|
140
|
-
})
|
|
141
|
-
}
|
|
142
|
-
//促销
|
|
143
|
-
const promotionList = valList.filter(item => item.strLx == 'promotion')
|
|
144
|
-
if (promotionList.length) {
|
|
145
|
-
promotionList.map(item => {
|
|
146
|
-
reductionList.push({
|
|
147
|
-
title: keys['promotion'],
|
|
148
|
-
info: hbfh + item.money, //描述
|
|
149
|
-
unit: item.money, //单价
|
|
150
|
-
cb: item.money, //成本
|
|
151
|
-
type: 'promotion'
|
|
152
|
-
})
|
|
153
|
-
})
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
//减免或促销费用
|
|
157
|
-
if (reductionList.length) {
|
|
158
|
-
list.push({
|
|
159
|
-
title: titles['reduction'],
|
|
160
|
-
type: 'reduction',
|
|
161
|
-
list: reductionList
|
|
162
|
-
})
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
//机场税
|
|
166
|
-
const airtaxList = valList.filter(item => item.strLx == 'airtax')
|
|
167
|
-
if (airtaxList.length) {
|
|
168
|
-
let val = {
|
|
169
|
-
title: titles['airtax'],
|
|
170
|
-
type: 'airtax',
|
|
171
|
-
list: []
|
|
172
|
-
}
|
|
173
|
-
airtaxList.map(item => {
|
|
174
|
-
val.list.push({
|
|
175
|
-
title: keys[item.rylx], //标题
|
|
176
|
-
info: hbfh + item.unitprice + rideIcon + item.sl, //描述
|
|
177
|
-
nRs: item.sl, //人数
|
|
178
|
-
unit: item.unitprice, //单价
|
|
179
|
-
cb: item.unitpricewb, //其他币种
|
|
180
|
-
type: item.rylx
|
|
181
|
-
})
|
|
182
|
-
})
|
|
183
|
-
list.push(val)
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const listKey = ['base', 'service', 'trip', 'elder', 'vipdiscounted', 'promotion', 'airtax'] //数据格式参数
|
|
187
|
-
//取出其他信息
|
|
188
|
-
const otherList = valList.filter(item => !listKey.includes(item.strLx));
|
|
189
|
-
|
|
190
|
-
let otherVal = {
|
|
191
|
-
title: titles['other'],
|
|
192
|
-
type: 'other',
|
|
193
|
-
list: []
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
for (var i = 0; i < otherList.length; i++) {
|
|
197
|
-
const item = otherList[i]
|
|
198
|
-
//会员充值
|
|
199
|
-
if (item.strLx == 'viprecharge') {
|
|
200
|
-
otherVal.list.push({
|
|
201
|
-
title: keys['viprecharge'] + `[${item.name}]`,
|
|
202
|
-
info: hbfh + item.money,
|
|
203
|
-
unit: item.money, //单价
|
|
204
|
-
type: item.strLx
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
//保险
|
|
208
|
-
if (item.strLx == 'insure') {
|
|
209
|
-
otherVal.list.push({
|
|
210
|
-
title: keys['insure'] + `[${item.name}]`,
|
|
211
|
-
info: hbfh + item.unit + rideIcon + item.users + keys['r'], //描述
|
|
212
|
-
nRs: item.users, //人数
|
|
213
|
-
unit: item.unit, //单价
|
|
214
|
-
cb: item.unit, //成本
|
|
215
|
-
type: 'insure'
|
|
216
|
-
})
|
|
217
|
-
}
|
|
218
|
-
//优惠券-积分
|
|
219
|
-
if (item.strLx == 'coupon' || item.strLx == 'point') {
|
|
220
|
-
otherVal.list.push({
|
|
221
|
-
title: keys[item.strLx],
|
|
222
|
-
info: hbfh + item.money,
|
|
223
|
-
unit: item.money, //单价
|
|
224
|
-
type: item.strLx
|
|
225
|
-
})
|
|
226
|
-
}
|
|
227
|
-
//小费
|
|
228
|
-
if (item.strLx == 'tip') {
|
|
229
|
-
otherVal.list.push({
|
|
230
|
-
title: keys[item.strLx], //标题
|
|
231
|
-
info: hbfh + item.tip + rideIcon + item.tipuser + keys['r'] + rideIcon + item.tipday +
|
|
232
|
-
keys['t'], //描述
|
|
233
|
-
nRs: item.tipuser, //人数
|
|
234
|
-
count: item.tipday, //天数,数量等
|
|
235
|
-
unit: item.tip, //单价
|
|
236
|
-
type: item.strLx //类型
|
|
237
|
-
})
|
|
238
|
-
}
|
|
239
|
-
//税
|
|
240
|
-
if (item.strLx == 'tax') {
|
|
241
|
-
otherVal.list.push({
|
|
242
|
-
title: keys[item.strLx],
|
|
243
|
-
info: hbfh + item.totaltax,
|
|
244
|
-
unit: item.totaltax,
|
|
245
|
-
type: item.strLx
|
|
246
|
-
})
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (otherVal.list.length) {
|
|
250
|
-
list.push(otherVal)
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const totalprice = valList.filter(item => item.strLx == 'totalprice')
|
|
254
|
-
//总价(实付价格)
|
|
255
|
-
if (totalprice.length) {
|
|
256
|
-
list.push({
|
|
257
|
-
title: titles['totalprice'],
|
|
258
|
-
type: 'totalprice',
|
|
259
|
-
list: [{
|
|
260
|
-
title: titles['totalprice'],
|
|
261
|
-
info: hbfh + totalprice[0].price
|
|
262
|
-
}]
|
|
263
|
-
})
|
|
264
|
-
}
|
|
265
|
-
return list
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
export default {
|
|
271
|
-
handleCosting
|
|
272
|
-
};
|
package/src/index.js
DELETED
package/src/test.js
DELETED
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 验证电子邮箱格式
|
|
3
|
-
*/
|
|
4
|
-
function email(value) {
|
|
5
|
-
return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(value)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 验证手机格式
|
|
10
|
-
*/
|
|
11
|
-
function mobile(value) {
|
|
12
|
-
return /^1([3589]\d|4[5-9]|6[1-2,4-7]|7[0-8])\d{8}$/.test(value)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 验证手机格式
|
|
17
|
-
* @param {Object} phoneNumber
|
|
18
|
-
*/
|
|
19
|
-
function isValidPhoneNumber(phoneNumber) {
|
|
20
|
-
// 检查电话号码是否包含 "-"
|
|
21
|
-
if (phoneNumber.includes('-')) {
|
|
22
|
-
// 分离区号和电话号码
|
|
23
|
-
const [areaCode, number] = phoneNumber.split('-');
|
|
24
|
-
// 根据区号判断号码格式
|
|
25
|
-
if (areaCode === '86') {
|
|
26
|
-
// 中国大陆手机号码格式验证
|
|
27
|
-
// 11位数字,以1开头
|
|
28
|
-
return /^\d{11}$/.test(number) && number.startsWith('1');
|
|
29
|
-
} else if (areaCode === '852') {
|
|
30
|
-
// 香港手机号码格式验证
|
|
31
|
-
// 8位数字,以5、6或9开头
|
|
32
|
-
return /^\d{8}$/.test(number) && ['5', '6', '9', '8'].includes(number.charAt(0));
|
|
33
|
-
} else {
|
|
34
|
-
// 对于未知的区号,只检查电话号码是否全部由数字组成
|
|
35
|
-
return /^\d+$/.test(number);
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
// 对于不包含 "-" 的电话号码,只检查是否全部由数字组成
|
|
39
|
-
return /^\d+$/.test(phoneNumber);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* 验证URL格式
|
|
47
|
-
*/
|
|
48
|
-
function url(value) {
|
|
49
|
-
return /^((https|http|ftp|rtsp|mms):\/\/)(([0-9a-zA-Z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z].[a-zA-Z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+\/?)$/
|
|
50
|
-
.test(value)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* 验证日期格式
|
|
55
|
-
*/
|
|
56
|
-
function date(value) {
|
|
57
|
-
if (!value) return false
|
|
58
|
-
// 判断是否数值或者字符串数值(意味着为时间戳),转为数值,否则new Date无法识别字符串时间戳
|
|
59
|
-
if (number(value)) value = +value
|
|
60
|
-
return !/Invalid|NaN/.test(new Date(value).toString())
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 验证ISO类型的日期格式
|
|
65
|
-
*/
|
|
66
|
-
function dateISO(value) {
|
|
67
|
-
return /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 验证十进制数字
|
|
72
|
-
*/
|
|
73
|
-
function isNumber(value) {
|
|
74
|
-
return /^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/.test(value)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* 验证字符串
|
|
79
|
-
*/
|
|
80
|
-
function isString(value) {
|
|
81
|
-
return typeof value === 'string'
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* 验证整数
|
|
86
|
-
*/
|
|
87
|
-
function digits(value) {
|
|
88
|
-
return /^\d+$/.test(value)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* 验证身份证号码
|
|
93
|
-
*/
|
|
94
|
-
function idCard(value) {
|
|
95
|
-
return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(
|
|
96
|
-
value
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 是否车牌号
|
|
104
|
-
*/
|
|
105
|
-
function carNo(value) {
|
|
106
|
-
// 新能源车牌
|
|
107
|
-
const xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/
|
|
108
|
-
// 旧车牌
|
|
109
|
-
const creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/
|
|
110
|
-
if (value.length === 7) {
|
|
111
|
-
return creg.test(value)
|
|
112
|
-
}
|
|
113
|
-
if (value.length === 8) {
|
|
114
|
-
return xreg.test(value)
|
|
115
|
-
}
|
|
116
|
-
return false
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* 金额,只允许2位小数
|
|
121
|
-
*/
|
|
122
|
-
function amount(value) {
|
|
123
|
-
// 金额,只允许保留两位小数
|
|
124
|
-
return /^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(value)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* 中文
|
|
129
|
-
*/
|
|
130
|
-
function chinese(value) {
|
|
131
|
-
const reg = /^[\u4e00-\u9fa5]+$/gi
|
|
132
|
-
return reg.test(value)
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* 只能输入字母
|
|
137
|
-
*/
|
|
138
|
-
function letter(value) {
|
|
139
|
-
return /^[a-zA-Z]*$/.test(value)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* 只能是字母或者数字
|
|
144
|
-
*/
|
|
145
|
-
function enOrNum(value) {
|
|
146
|
-
// 英文或者数字
|
|
147
|
-
const reg = /^[0-9a-zA-Z]*$/g
|
|
148
|
-
return reg.test(value)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 验证是否包含某个值
|
|
153
|
-
*/
|
|
154
|
-
function contains(value, param) {
|
|
155
|
-
return value.indexOf(param) >= 0
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* 验证一个值范围[min, max]
|
|
160
|
-
*/
|
|
161
|
-
function range(value, param) {
|
|
162
|
-
return value >= param[0] && value <= param[1]
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* 验证一个长度范围[min, max]
|
|
167
|
-
*/
|
|
168
|
-
function rangeLength(value, param) {
|
|
169
|
-
return value.length >= param[0] && value.length <= param[1]
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* 是否固定电话
|
|
174
|
-
*/
|
|
175
|
-
function landline(value) {
|
|
176
|
-
const reg = /^\d{3,4}-\d{7,8}(-\d{3,4})?$/
|
|
177
|
-
return reg.test(value)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* 判断是否为空
|
|
182
|
-
*/
|
|
183
|
-
function empty(value) {
|
|
184
|
-
switch (typeof value) {
|
|
185
|
-
case 'undefined':
|
|
186
|
-
return true
|
|
187
|
-
case 'string':
|
|
188
|
-
if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true
|
|
189
|
-
break
|
|
190
|
-
case 'boolean':
|
|
191
|
-
if (!value) return true
|
|
192
|
-
break
|
|
193
|
-
case 'number':
|
|
194
|
-
if (value === 0 || isNaN(value)) return true
|
|
195
|
-
break
|
|
196
|
-
case 'object':
|
|
197
|
-
if (value === null || value.length === 0) return true
|
|
198
|
-
for (const i in value) {
|
|
199
|
-
return false
|
|
200
|
-
}
|
|
201
|
-
return true
|
|
202
|
-
}
|
|
203
|
-
return false
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* 是否json字符串
|
|
208
|
-
*/
|
|
209
|
-
function jsonString(value) {
|
|
210
|
-
if (typeof value === 'string') {
|
|
211
|
-
try {
|
|
212
|
-
const obj = JSON.parse(value)
|
|
213
|
-
if (typeof obj === 'object' && obj) {
|
|
214
|
-
return true
|
|
215
|
-
}
|
|
216
|
-
return false
|
|
217
|
-
} catch (e) {
|
|
218
|
-
return false
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return false
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* 是否数组
|
|
226
|
-
*/
|
|
227
|
-
function array(value) {
|
|
228
|
-
if (typeof Array.isArray === 'function') {
|
|
229
|
-
return Array.isArray(value)
|
|
230
|
-
}
|
|
231
|
-
return Object.prototype.toString.call(value) === '[object Array]'
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* 是否对象
|
|
236
|
-
*/
|
|
237
|
-
function object(value) {
|
|
238
|
-
return Object.prototype.toString.call(value) === '[object Object]'
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* 是否短信验证码
|
|
243
|
-
*/
|
|
244
|
-
function code(value, len = 6) {
|
|
245
|
-
return new RegExp(`^\\d{${len}}$`).test(value)
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* 是否函数方法
|
|
250
|
-
* @param {Object} value
|
|
251
|
-
*/
|
|
252
|
-
function func(value) {
|
|
253
|
-
return typeof value === 'function'
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* 是否promise对象
|
|
258
|
-
* @param {Object} value
|
|
259
|
-
*/
|
|
260
|
-
function promise(value) {
|
|
261
|
-
return object(value) && func(value.then) && func(value.catch)
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
/** 是否图片格式
|
|
265
|
-
* @param {Object} value
|
|
266
|
-
*/
|
|
267
|
-
function image(value) {
|
|
268
|
-
const newValue = value.split('?')[0]
|
|
269
|
-
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i
|
|
270
|
-
return IMAGE_REGEXP.test(newValue)
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* 是否视频格式
|
|
275
|
-
* @param {Object} value
|
|
276
|
-
*/
|
|
277
|
-
function video(value) {
|
|
278
|
-
const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i
|
|
279
|
-
return VIDEO_REGEXP.test(value)
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* 是否为正则对象
|
|
284
|
-
* @param {Object}
|
|
285
|
-
* @return {Boolean}
|
|
286
|
-
*/
|
|
287
|
-
function regExp(o) {
|
|
288
|
-
return o && Object.prototype.toString.call(o) === '[object RegExp]'
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* 判断一个字符串或浮点数是否仅包含数字、减号和小数点
|
|
293
|
-
* @param {string|number} str - 要检查的字符串或浮点数
|
|
294
|
-
* @param {number} type - 类型 0: 可以输入金额 1: 只能输入正数 2: 只能输入负数 3: 只能输入整数 4: 只能输入正整数 5: 只能输入负整数
|
|
295
|
-
* @returns {boolean} - 是否符合条件
|
|
296
|
-
*/
|
|
297
|
-
function isNumeric(str, type = 0) {
|
|
298
|
-
// 将数字转换为字符串
|
|
299
|
-
if (typeof str === 'number') str = str.toString();
|
|
300
|
-
// 如果不是字符串,返回 false
|
|
301
|
-
if (typeof str !== 'string') return false;
|
|
302
|
-
switch (type) {
|
|
303
|
-
case 1:
|
|
304
|
-
// 只能输入正数
|
|
305
|
-
return /^\d+(\.\d+)?$/.test(str);
|
|
306
|
-
case 2:
|
|
307
|
-
// 只能输入负数
|
|
308
|
-
return /^-\d+(\.\d+)?$/.test(str);
|
|
309
|
-
case 3:
|
|
310
|
-
// 只能输入整数(正数或负数)
|
|
311
|
-
return /^-?\d+$/.test(str);
|
|
312
|
-
case 4:
|
|
313
|
-
// 只能输入正整数
|
|
314
|
-
return /^\d+$/.test(str);
|
|
315
|
-
case 5:
|
|
316
|
-
// 只能输入负整数
|
|
317
|
-
return /^-\d+$/.test(str);
|
|
318
|
-
default:
|
|
319
|
-
// 可以输入金额(正数或负数)
|
|
320
|
-
return /^-?\d*\.?\d*$/.test(str) && !str.startsWith('.') && !str.includes('--');
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
export default {
|
|
325
|
-
isNumeric,
|
|
326
|
-
email,
|
|
327
|
-
mobile,
|
|
328
|
-
url,
|
|
329
|
-
date,
|
|
330
|
-
dateISO,
|
|
331
|
-
isNumber,
|
|
332
|
-
digits,
|
|
333
|
-
idCard,
|
|
334
|
-
carNo,
|
|
335
|
-
amount,
|
|
336
|
-
chinese,
|
|
337
|
-
letter,
|
|
338
|
-
enOrNum,
|
|
339
|
-
contains,
|
|
340
|
-
range,
|
|
341
|
-
rangeLength,
|
|
342
|
-
empty,
|
|
343
|
-
jsonString,
|
|
344
|
-
landline,
|
|
345
|
-
object,
|
|
346
|
-
array,
|
|
347
|
-
code,
|
|
348
|
-
func,
|
|
349
|
-
promise,
|
|
350
|
-
video,
|
|
351
|
-
image,
|
|
352
|
-
regExp,
|
|
353
|
-
isString,
|
|
354
|
-
isValidPhoneNumber
|
|
355
|
-
}
|
package/src/utils.js
DELETED
|
@@ -1,545 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 格式化数字,添加千分位分隔符。
|
|
5
|
-
* 支持数字和字符串类型的数字输入。
|
|
6
|
-
* 如果输入无效,返回空字符串。
|
|
7
|
-
*
|
|
8
|
-
* @param {number|string} num - 要格式化的数字或数字字符串。
|
|
9
|
-
* @return {string} 格式化后的带千分位分隔符的字符串,或空字符串(如果输入无效)。
|
|
10
|
-
*/
|
|
11
|
-
function fmtNum(num) {
|
|
12
|
-
if (num == 0) return '0'
|
|
13
|
-
if (!num) return ''
|
|
14
|
-
|
|
15
|
-
// 尝试将输入转换为数字,如果输入是字符串则使用parseFloat进行转换
|
|
16
|
-
let number = typeof num === 'string' ? parseFloat(num) : num;
|
|
17
|
-
// 检查转换后的值是否为有效数字
|
|
18
|
-
if (isNaN(number)) {
|
|
19
|
-
// 如果转换失败,返回空字符串
|
|
20
|
-
return '';
|
|
21
|
-
}
|
|
22
|
-
// 使用 toLocaleString 方法格式化数字,添加千分位分隔符
|
|
23
|
-
// 设置国际化选项:使用美国英语格式,小数部分显示0至2位
|
|
24
|
-
return number.toLocaleString('en-US', {
|
|
25
|
-
minimumFractionDigits: 0,
|
|
26
|
-
maximumFractionDigits: 2
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 分割全名成姓和名
|
|
32
|
-
* @param {string} fullName - 待处理的完整姓名
|
|
33
|
-
* @param {boolean} [isEn=false] - 指示姓名是否为英文格式,默认为false表示中文姓名
|
|
34
|
-
* @returns {object} 返回一个对象,包含姓(surname)和名(givenName)
|
|
35
|
-
*/
|
|
36
|
-
function splitName(fullName, isEn = false) {
|
|
37
|
-
// 初始化结果对象,用于存储姓和名
|
|
38
|
-
let result = {
|
|
39
|
-
surname: '', // 姓
|
|
40
|
-
givenName: '' // 名
|
|
41
|
-
};
|
|
42
|
-
// 如果是英文姓名
|
|
43
|
-
if (isEn) {
|
|
44
|
-
// 英文姓名通常格式为 "SURNAME, GIVEN NAME(S)"
|
|
45
|
-
// const parts = fullName.split(','); // 使用逗号分割姓名
|
|
46
|
-
// 使用逗号分割姓名,如果没有逗号 以空格分隔
|
|
47
|
-
const parts = fullName.includes(',') ? fullName.split(',') : fullName.split(/\s+/);
|
|
48
|
-
if (parts.length >= 2) {
|
|
49
|
-
// 移除前后空白字符并分配给姓和名
|
|
50
|
-
result.surname = parts[0].trim(); // 第一部分为姓
|
|
51
|
-
result.givenName = parts[1].trim(); // 第二部分为名
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
// 定义中文复姓列表
|
|
55
|
-
const surnames = [
|
|
56
|
-
"欧阳", "太史", "端木", "上官", "司马", "东方", "独孤", "南宫", "万俟", "闻人",
|
|
57
|
-
"夏侯", "诸葛", "尉迟", "公羊", "赫连", "澹台", "皇甫", "宗政", "濮阳", "公冶",
|
|
58
|
-
"太叔", "申屠", "公孙", "慕容", "仲孙", "钟离", "长孙", "宇文", "司徒", "鲜于",
|
|
59
|
-
"司空", "闾丘", "子车", "亓官", "司寇", "巫马", "公西", "颛孙", "壤驷", "公良",
|
|
60
|
-
"漆雕", "乐正", "宰父", "谷梁", "拓跋", "夹谷", "轩辕", "令狐", "段干", "百里",
|
|
61
|
-
"呼延", "东郭", "南门", "羊舌", "微生", "公户", "公玉", "公仪", "梁丘", "公仲",
|
|
62
|
-
"公上", "公门", "公山", "公坚", "左丘", "公伯", "西门", "公祖", "第五", "公乘",
|
|
63
|
-
"贯丘", "公皙", "南荣", "东里", "东宫", "仲长", "子书", "子桑", "即墨", "达奚",
|
|
64
|
-
"褚师", "吴铭",
|
|
65
|
-
// 繁体(如果有不同的写法)
|
|
66
|
-
"歐陽", "太史", "端木", "上官", "司馬", "東方", "獨孤", "南宮", "萬俟", "聞人",
|
|
67
|
-
"夏侯", "諸葛", "尉遲", "公羊", "赫連", "澹臺", "皇甫", "宗政", "濮陽", "公冶",
|
|
68
|
-
"太叔", "申屠", "公孫", "慕容", "仲孫", "鐘離", "長孫", "宇文", "司徒", "鮮於",
|
|
69
|
-
"司空", "閭丘", "子車", "亓官", "司寇", "巫馬", "公西", "顓孫", "壤駟", "公良",
|
|
70
|
-
"漆雕", "樂正", "宰父", "穀梁", "拓跋", "夾谷", "軒轅", "令狐", "段幹", "百里",
|
|
71
|
-
"呼延", "東郭", "南門", "羊舌", "微生", "公戶", "公玉", "公儀", "梁丘", "公仲",
|
|
72
|
-
"公上", "公門", "公山", "公堅", "左丘", "公伯", "西門", "公祖", "第五", "公乘",
|
|
73
|
-
"貫丘", "公皙", "南榮", "東里", "東宮", "仲長", "子書", "子桑", "即墨", "達奚",
|
|
74
|
-
"褚師", "吳銘"
|
|
75
|
-
];
|
|
76
|
-
// 尝试查找复姓
|
|
77
|
-
for (let i = 0; i < surnames.length; i++) {
|
|
78
|
-
const surname = surnames[i];
|
|
79
|
-
// 如果全名以某个复姓开头
|
|
80
|
-
if (fullName.startsWith(surname)) {
|
|
81
|
-
// 设置姓为该复姓,名则为复姓之后的部分
|
|
82
|
-
result.surname = surname;
|
|
83
|
-
result.givenName = fullName.substring(surname.length).trim();
|
|
84
|
-
return result; // 找到后立即返回结果
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// 如果没有找到复姓,处理单姓的情况
|
|
88
|
-
const parts = fullName.split(' '); // 使用空格分割姓名
|
|
89
|
-
if (parts.length === 1) {
|
|
90
|
-
// 如果没有空格分隔,使用正则表达式来识别第一个汉字作为姓
|
|
91
|
-
const surnameMatch = fullName.match(/[\u4e00-\u9fa5]/); // 匹配第一个汉字
|
|
92
|
-
result.surname = surnameMatch ? surnameMatch[0] : ''; // 设置姓
|
|
93
|
-
// 移除姓后的剩余部分作为名
|
|
94
|
-
result.givenName = fullName.replace(result.surname, '').trim();
|
|
95
|
-
} else {
|
|
96
|
-
// 如果有空格分隔,第一部分作为姓,剩余部分作为名
|
|
97
|
-
result.surname = parts[0]; // 第一部分为姓
|
|
98
|
-
result.givenName = parts.slice(1).join(' '); // 其余部分为名
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 将指定键名替换成另外的键名
|
|
107
|
-
* strCode:原始键名
|
|
108
|
-
* code:新键名
|
|
109
|
-
*/
|
|
110
|
-
function modifyKeys(array, keyMap = {
|
|
111
|
-
strCode: "code",
|
|
112
|
-
strFjbh: "fjbh",
|
|
113
|
-
strGuid: "value",
|
|
114
|
-
strValue: "label"
|
|
115
|
-
}) {
|
|
116
|
-
if (!array.length || array === null) return []
|
|
117
|
-
// 遍历数组中的每个对象
|
|
118
|
-
const modifiedArray = array.map(obj => {
|
|
119
|
-
const modifiedObj = {};
|
|
120
|
-
// 遍历对象的键
|
|
121
|
-
for (const key in obj) {
|
|
122
|
-
if (keyMap.hasOwnProperty(key)) {
|
|
123
|
-
// 如果键在映射表中有对应的新键名,则使用新键名
|
|
124
|
-
modifiedObj[keyMap[key]] = obj[key];
|
|
125
|
-
} else {
|
|
126
|
-
// 否则保持原始键名
|
|
127
|
-
modifiedObj[key] = obj[key];
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return modifiedObj;
|
|
131
|
-
});
|
|
132
|
-
return modifiedArray;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* 对数组进行切片处理
|
|
137
|
-
* data:需要处理的数组
|
|
138
|
-
* quantity:需要切割的数量
|
|
139
|
-
* fromFront:是从前还是从后面切,默认从后
|
|
140
|
-
*/
|
|
141
|
-
function sliceArray(data, quantity, fromFront) {
|
|
142
|
-
if (quantity <= 0) {
|
|
143
|
-
console.error("Quantity should be greater than 0.");
|
|
144
|
-
return [];
|
|
145
|
-
}
|
|
146
|
-
if (fromFront) {
|
|
147
|
-
return data.slice(0, quantity);
|
|
148
|
-
} else {
|
|
149
|
-
return data.slice(-quantity);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* 判断指定键名的值是否在数组内
|
|
156
|
-
* @param {*} inputArray 源数组
|
|
157
|
-
* @param {*} target 需要匹配的值
|
|
158
|
-
* @param {*} key 键名
|
|
159
|
-
*/
|
|
160
|
-
function findDataByData(inputArray, target, key) {
|
|
161
|
-
const foundData = inputArray.find(item => item[key] === target);
|
|
162
|
-
return foundData || null;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* 分割数组
|
|
167
|
-
*/
|
|
168
|
-
function splitArray(arr, n) {
|
|
169
|
-
const result = [];
|
|
170
|
-
for (let i = 0; i < arr.length; i += n) {
|
|
171
|
-
result.push(arr.slice(i, i + n));
|
|
172
|
-
}
|
|
173
|
-
return result;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* 获取proxy的数据类型
|
|
179
|
-
*/
|
|
180
|
-
function getProxyType(value) {
|
|
181
|
-
return Object.prototype.toString.call(value).slice(8, -1);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
let timeout = null
|
|
186
|
-
/**
|
|
187
|
-
* 防抖原理:一定时间内,只有最后一次操作,再过wait毫秒后才执行函数
|
|
188
|
-
*
|
|
189
|
-
* @param {Function} func 要执行的回调函数
|
|
190
|
-
* @param {Number} wait 延时的时间
|
|
191
|
-
* @param {Boolean} immediate 是否立即执行
|
|
192
|
-
* @return null
|
|
193
|
-
*/
|
|
194
|
-
function debounce(func, wait = 500, immediate = false) {
|
|
195
|
-
// 清除定时器
|
|
196
|
-
if (timeout !== null) clearTimeout(timeout)
|
|
197
|
-
// 立即执行,此类情况一般用不到
|
|
198
|
-
if (immediate) {
|
|
199
|
-
const callNow = !timeout
|
|
200
|
-
timeout = setTimeout(() => {
|
|
201
|
-
timeout = null
|
|
202
|
-
}, wait)
|
|
203
|
-
if (callNow) typeof func === 'function' && func()
|
|
204
|
-
} else {
|
|
205
|
-
// 设置定时器,当最后一次操作后,timeout不会再被清除,所以在延时wait毫秒后执行func回调方法
|
|
206
|
-
timeout = setTimeout(() => {
|
|
207
|
-
typeof func === 'function' && func()
|
|
208
|
-
}, wait)
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* 判断指定键名的值是否在数组内
|
|
214
|
-
*/
|
|
215
|
-
function matchKeyValueInArray(arr, key, value) {
|
|
216
|
-
for (let i = 0; i < arr.length; i++) {
|
|
217
|
-
if (arr[i][key] === value) {
|
|
218
|
-
return true;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* 对象转URL
|
|
227
|
-
* @param {object} obj
|
|
228
|
-
*/
|
|
229
|
-
function urlEncode(obj = {}) {
|
|
230
|
-
const result = []
|
|
231
|
-
for (const key in obj) {
|
|
232
|
-
const item = obj[key]
|
|
233
|
-
if (!item) {
|
|
234
|
-
continue
|
|
235
|
-
}
|
|
236
|
-
if (isArray(item)) {
|
|
237
|
-
item.forEach(val => {
|
|
238
|
-
result.push(key + '=' + val)
|
|
239
|
-
})
|
|
240
|
-
} else {
|
|
241
|
-
result.push(key + '=' + item)
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
return result.join('&')
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* 比较日期大小
|
|
249
|
-
* @param {Object} date1
|
|
250
|
-
* @param {Object} date2 默认当日
|
|
251
|
-
*/
|
|
252
|
-
function compareDates(date1, date2) {
|
|
253
|
-
date1 = new Date(date1);
|
|
254
|
-
if (!date2) {
|
|
255
|
-
date2 = new Date();
|
|
256
|
-
} else {
|
|
257
|
-
date2 = new Date(date2);
|
|
258
|
-
}
|
|
259
|
-
date1.setHours(0, 0, 0, 0); // 将时间部分设置为0
|
|
260
|
-
date2.setHours(0, 0, 0, 0); // 将时间部分设置为0
|
|
261
|
-
// 将日期转换为时间戳进行比较
|
|
262
|
-
var timeStamp1 = date1.getTime();
|
|
263
|
-
var timeStamp2 = date2.getTime();
|
|
264
|
-
if (timeStamp1 < timeStamp2) {
|
|
265
|
-
return -1; // date1 小于 date2
|
|
266
|
-
} else if (timeStamp1 > timeStamp2) {
|
|
267
|
-
return 1; // date1 大于 date2
|
|
268
|
-
} else {
|
|
269
|
-
return 0; // date1 等于 date2
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/**
|
|
274
|
-
* 获取2个日期间的天数
|
|
275
|
-
* @param {Object} date1
|
|
276
|
-
* @param {Object} date2
|
|
277
|
-
*/
|
|
278
|
-
function getDaysBetween(date1, date2) {
|
|
279
|
-
// 将日期字符串转换为Date对象
|
|
280
|
-
const d1 = new Date(date1);
|
|
281
|
-
const d2 = new Date(date2);
|
|
282
|
-
|
|
283
|
-
// 计算两个日期之间的毫秒数
|
|
284
|
-
const diff = Math.abs(d1.getTime() - d2.getTime());
|
|
285
|
-
|
|
286
|
-
// 将毫秒数转换为天数
|
|
287
|
-
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
|
|
288
|
-
|
|
289
|
-
return days + 1; // 包括起始日期和结束日期,所以需要加1
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* 转中文大写
|
|
295
|
-
* @param {Object} num
|
|
296
|
-
*/
|
|
297
|
-
function chineseNumeral(num) {
|
|
298
|
-
const numerals = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'];
|
|
299
|
-
const units = ['', '拾', '佰', '仟'];
|
|
300
|
-
const scales = ['', '万', '亿', '兆'];
|
|
301
|
-
|
|
302
|
-
let integerPart = Math.floor(num);
|
|
303
|
-
let decimalPart = Math.round((num - integerPart) * 100); // 取小数点后两位的整数表示
|
|
304
|
-
let str = '';
|
|
305
|
-
|
|
306
|
-
// 转换整数部分
|
|
307
|
-
for (let i = 0; integerPart > 0; i++) {
|
|
308
|
-
let temp = '';
|
|
309
|
-
let section = integerPart % 10000;
|
|
310
|
-
integerPart = Math.floor(integerPart / 10000);
|
|
311
|
-
|
|
312
|
-
for (let j = 0; section > 0; j++) {
|
|
313
|
-
let digit = section % 10;
|
|
314
|
-
temp = (digit ? numerals[digit] + units[j] : '') + temp;
|
|
315
|
-
section = Math.floor(section / 10);
|
|
316
|
-
}
|
|
317
|
-
str = temp + (temp ? scales[i] : scales[i] && !str.includes('零') ? '零' : '') + str;
|
|
318
|
-
}
|
|
319
|
-
str += str ? '元' : '零元';
|
|
320
|
-
// 转换小数部分
|
|
321
|
-
if (decimalPart > 0) {
|
|
322
|
-
let jiao = Math.floor(decimalPart / 10);
|
|
323
|
-
let fen = decimalPart % 10;
|
|
324
|
-
str += (jiao ? numerals[jiao] + '角' : '') + (fen ? numerals[fen] + '分' : '');
|
|
325
|
-
} else {
|
|
326
|
-
str += '整';
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
return str.replace(/零{2,}/g, '零').replace(/零元/, '元');
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* 获取月份所有日期
|
|
335
|
-
* @param {*} monthYear 月份,格式为2024-2或2024-02 不传或者空字符串则返回当月
|
|
336
|
-
*/
|
|
337
|
-
function getMonthDate(monthYear) {
|
|
338
|
-
if (!monthYear || monthYear.trim() === '') {
|
|
339
|
-
monthYear = `${new Date().getFullYear()}-${new Date().getMonth() + 1}`;
|
|
340
|
-
}
|
|
341
|
-
let dates = [];
|
|
342
|
-
let [year, month] = monthYear.split('-').map(Number);
|
|
343
|
-
let date = new Date(year, month, 0);
|
|
344
|
-
let days = date.getDate();
|
|
345
|
-
|
|
346
|
-
for (let i = 1; i <= days; i++) {
|
|
347
|
-
let day = i < 10 ? `0${i}` : `${i}`;
|
|
348
|
-
let monthFormatted = month < 10 ? `0${month}` : `${month}`;
|
|
349
|
-
dates.push({
|
|
350
|
-
date: `${year}-${monthFormatted}-${day}`,
|
|
351
|
-
disable: true
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
return dates;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
function getToday(date) {
|
|
358
|
-
var today = new Date();
|
|
359
|
-
var dd = String(today.getDate()).padStart(2, '0');
|
|
360
|
-
var mm = String(today.getMonth() + 1).padStart(2, '0'); //January is 0!
|
|
361
|
-
var yyyy = today.getFullYear();
|
|
362
|
-
today = yyyy + '-' + mm + '-' + dd
|
|
363
|
-
return today
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* 重置对象
|
|
372
|
-
* @param {Object} obj
|
|
373
|
-
*/
|
|
374
|
-
function resetObject(val) {
|
|
375
|
-
let obj = JSON.parse(JSON.stringify(val))
|
|
376
|
-
for (const key in obj) {
|
|
377
|
-
if (typeof obj[key] === 'number') {
|
|
378
|
-
obj[key] = 0;
|
|
379
|
-
} else if (typeof obj[key] === 'boolean') {
|
|
380
|
-
obj[key] = false;
|
|
381
|
-
} else if (Array.isArray(obj[key])) {
|
|
382
|
-
obj[key] = [];
|
|
383
|
-
} else if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
384
|
-
// 递归调用以处理嵌套对象
|
|
385
|
-
resetObject(obj[key]);
|
|
386
|
-
} else {
|
|
387
|
-
obj[key] = '';
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
return obj
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* 精确运算函数,解决浮点数计算精度丢失问题。
|
|
395
|
-
* 该函数接受两个数字和一个操作符(1: 加法, 2: 减法, 3: 乘法, 4: 除法),
|
|
396
|
-
* 通过将浮点数转换为整数进行计算,再转换回浮点数得到相对精确的结果。
|
|
397
|
-
* @param {number} a - 参与运算的第一个数字
|
|
398
|
-
* @param {number} b - 参与运算的第二个数字
|
|
399
|
-
* @param {number} operator - 表示运算类型的数字,1为加法,2为减法,3为乘法,4为除法
|
|
400
|
-
* @returns {number} - 根据操作符计算得到的结果
|
|
401
|
-
*/
|
|
402
|
-
function preciseOperation(a, b, operator, precisionFactor = 1000000) {
|
|
403
|
-
// 处理特殊值NaN
|
|
404
|
-
if (isNaN(a) || isNaN(b)) {
|
|
405
|
-
return NaN;
|
|
406
|
-
}
|
|
407
|
-
// 处理无穷大
|
|
408
|
-
if (!isFinite(a) || !isFinite(b)) {
|
|
409
|
-
return NaN;
|
|
410
|
-
}
|
|
411
|
-
let num1 = BigInt(Math.round(a * precisionFactor));
|
|
412
|
-
let num2 = BigInt(Math.round(b * precisionFactor));
|
|
413
|
-
let result;
|
|
414
|
-
switch (operator) {
|
|
415
|
-
case 1:
|
|
416
|
-
result = num1 + num2;
|
|
417
|
-
break;
|
|
418
|
-
case 2:
|
|
419
|
-
result = num1 - num2;
|
|
420
|
-
break;
|
|
421
|
-
case 3:
|
|
422
|
-
result = num1 * num2;
|
|
423
|
-
break;
|
|
424
|
-
case 4:
|
|
425
|
-
if (num2 === 0n) {
|
|
426
|
-
throw new Error('除数不能为0');
|
|
427
|
-
}
|
|
428
|
-
result = num1 / num2;
|
|
429
|
-
break;
|
|
430
|
-
default:
|
|
431
|
-
throw new Error('无效的操作符,操作符应为1、2、3或4');
|
|
432
|
-
}
|
|
433
|
-
return Number(result) / precisionFactor;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* 使用精确运算函数计算数组内所有元素的总和。
|
|
441
|
-
* 如果数组中的元素是字符串形式的数字,则尝试将其转换为数字;
|
|
442
|
-
* 如果转换失败或元素是 null/undefined,则将该元素视为 0。
|
|
443
|
-
* @param {Array} numbers - 数字或字符串形式的数字数组
|
|
444
|
-
* @returns {number} - 数组内所有元素的总和
|
|
445
|
-
*/
|
|
446
|
-
function preciseSum(numbers) {
|
|
447
|
-
// 初始化总和为0
|
|
448
|
-
let sum = 0;
|
|
449
|
-
// 遍历数组中的每个元素
|
|
450
|
-
for (const num of numbers) {
|
|
451
|
-
let currentNum = 0; // 默认值为0
|
|
452
|
-
// 尝试将元素转换为数字
|
|
453
|
-
if (typeof num === 'string') {
|
|
454
|
-
const parsedNum = parseFloat(num);
|
|
455
|
-
if (!isNaN(parsedNum)) {
|
|
456
|
-
currentNum = parsedNum;
|
|
457
|
-
}
|
|
458
|
-
} else if (typeof num === 'number') {
|
|
459
|
-
currentNum = num;
|
|
460
|
-
}
|
|
461
|
-
// 使用 preciseOperation 进行加法操作
|
|
462
|
-
sum = preciseOperation(sum, currentNum, 1); // 1 表示加法
|
|
463
|
-
}
|
|
464
|
-
return sum;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* 获取指定日期的前后时间
|
|
469
|
-
* @param {Object} dateStr 指定日期
|
|
470
|
-
* @param {Object} days 天数
|
|
471
|
-
*/
|
|
472
|
-
function getRelativeDate(dateStr, days = 0) {
|
|
473
|
-
const date = new Date(dateStr);
|
|
474
|
-
date.setDate(date.getDate() + days); // 在日期上加上指定的天数,负数则减去天数
|
|
475
|
-
|
|
476
|
-
// 将日期转换回 YYYY-MM-DD 格式
|
|
477
|
-
const year = date.getFullYear();
|
|
478
|
-
const month = (date.getMonth() + 1).toString().padStart(2, '0'); // getMonth() 返回 0-11
|
|
479
|
-
const day = date.getDate().toString().padStart(2, '0');
|
|
480
|
-
|
|
481
|
-
return `${year}-${month}-${day}`;
|
|
482
|
-
|
|
483
|
-
// 示例使用
|
|
484
|
-
// console.log(getRelativeDate('2023-03-04', 2)); // 返回 '2023-03-06'
|
|
485
|
-
// console.log(getRelativeDate('2023-03-04', -2)); // 返回 '2023-03-02'
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* 校验指定键名的值是否为指定值(默认为空字符串)
|
|
491
|
-
* @param {Object} model 校验对象
|
|
492
|
-
* @param {Array} fields 校验对象内的键名数组
|
|
493
|
-
* @param {Any} valueToCheck 校验的值
|
|
494
|
-
*/
|
|
495
|
-
function validateFields(model, fields, valueToCheck = "") {
|
|
496
|
-
for (let field of fields) {
|
|
497
|
-
if (model[field] === valueToCheck) {
|
|
498
|
-
return true;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return false;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* 本函数与Object.assign()的区别为不会像第一个对象中添加第一个对象原本不存在的键
|
|
506
|
-
* 将第二个对象中相同键名的值赋值给第一个对象中相同键名
|
|
507
|
-
* @param {Object} obj1
|
|
508
|
-
* @param {Object} obj2
|
|
509
|
-
*/
|
|
510
|
-
function mergeObjects(obj1, obj2) {
|
|
511
|
-
// 遍历 obj1 的键名
|
|
512
|
-
for (const key in obj1) {
|
|
513
|
-
// 如果 obj2 中存在相同的键名
|
|
514
|
-
if (obj2.hasOwnProperty(key)) {
|
|
515
|
-
// 将 obj2 中的值赋值给 obj1 中的相同键名
|
|
516
|
-
obj1[key] = obj2[key];
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
return obj1;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
export default {
|
|
524
|
-
fmtNum,
|
|
525
|
-
splitName,
|
|
526
|
-
preciseSum,
|
|
527
|
-
modifyKeys,
|
|
528
|
-
sliceArray,
|
|
529
|
-
findDataByData,
|
|
530
|
-
splitArray,
|
|
531
|
-
getProxyType,
|
|
532
|
-
debounce,
|
|
533
|
-
matchKeyValueInArray,
|
|
534
|
-
urlEncode,
|
|
535
|
-
compareDates,
|
|
536
|
-
getDaysBetween,
|
|
537
|
-
chineseNumeral,
|
|
538
|
-
getMonthDate,
|
|
539
|
-
getToday,
|
|
540
|
-
resetObject,
|
|
541
|
-
preciseOperation,
|
|
542
|
-
getRelativeDate,
|
|
543
|
-
validateFields,
|
|
544
|
-
mergeObjects
|
|
545
|
-
}
|