tplus-member 3.41.2 → 3.41.3
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.
@@ -125,7 +125,8 @@ var BindCard = function (_Component) {
|
|
125
125
|
|
126
126
|
var ref = inputType === 'value' ? _this.inputRef.input : _this.passwordRef.input;
|
127
127
|
_tplusComponentsTouch.Keyboard.open(function (v) {
|
128
|
-
var
|
128
|
+
var code = inputType === 'value' ? _this.state.value : _this.state.password;
|
129
|
+
var value = _tplusComponentsTouch.Keyboard.getNewValue(ref, code, v);
|
129
130
|
inputType === 'value' && _this.onChange(value);
|
130
131
|
inputType === 'password' && _this.setState({ password: value });
|
131
132
|
}, function () {
|
@@ -227,11 +228,9 @@ var BindCard = function (_Component) {
|
|
227
228
|
}, {
|
228
229
|
key: 'changeDisabled',
|
229
230
|
value: function changeDisabled() {
|
230
|
-
var
|
231
|
-
value = _state.value,
|
232
|
-
password = _state.password;
|
231
|
+
var value = this.state.value;
|
233
232
|
|
234
|
-
this.props.changeBindCardBtnDisabled(!value.length
|
233
|
+
this.props.changeBindCardBtnDisabled(!value.length);
|
235
234
|
}
|
236
235
|
// 显示键盘
|
237
236
|
|
@@ -244,9 +243,9 @@ var BindCard = function (_Component) {
|
|
244
243
|
value: function render() {
|
245
244
|
var _this3 = this;
|
246
245
|
|
247
|
-
var
|
248
|
-
value =
|
249
|
-
password =
|
246
|
+
var _state = this.state,
|
247
|
+
value = _state.value,
|
248
|
+
password = _state.password;
|
250
249
|
|
251
250
|
return _react2.default.createElement(
|
252
251
|
'div',
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["tplus-member/member/memberMenu/bindCard/index.js"],"names":["keyList","BindCard","props","keyPressStamp","scanValue","onChange","value","newValue","replace","setState","changeDisabled","onPasswordChange","password","KeyboardShow","inputType","bindCardClick","ref","inputRef","input","passwordRef","Keyboard","open","
|
1
|
+
{"version":3,"sources":["tplus-member/member/memberMenu/bindCard/index.js"],"names":["keyList","BindCard","props","keyPressStamp","scanValue","onChange","value","newValue","replace","setState","changeDisabled","onPasswordChange","password","KeyboardShow","inputType","bindCardClick","ref","inputRef","input","passwordRef","Keyboard","open","code","state","getNewValue","v","close","keyboardClose","blur","inputBlur","handleKeyPress","ev","keyCode","key","length","includes","currentStamp","Date","now","substring","focus","changeBindCardBtnDisabled","marginTop","hotKey","hotKeyNotFilter","target","Component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AAEA;;AACA;;;;AAEA,IAAMA,UAAU,CAAC,OAAD,EAAU,WAAV,EAAuB,OAAvB,EAAgC,KAAhC,EAAuC,UAAvC,EAAmD,MAAnD,EAA2D,KAA3D,EAAkE,SAAlE,EAA6E,QAA7E,CAAhB;;IACqBC,Q;;;AAGjB,sBAAaC,KAAb,EAAoB;AAAA;;AAAA;;AAAA,8IACVA,KADU;;AAAA,cAFpBC,aAEoB,GAFJ,IAEI;AAAA,cADpBC,SACoB,GADR,EACQ;;AAAA,cAWpBC,QAXoB;AAAA,gGAWT,iBAAOC,KAAP;AAAA;AAAA;AAAA;AAAA;AAAA;AACHC,wCADG,GACQD,KADR;AAEP;;AACAC,2CAAWD,MAAME,OAAN,CAAc,eAAd,EAA8B,EAA9B,CAAX;AACA;AAJO;AAAA,uCAKD,MAAKC,QAAL,CAAc,EAACH,OAAOC,QAAR,EAAd,CALC;;AAAA;AAMP,sCAAKG,cAAL;;AANO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aAXS;;AAAA;AAAA;AAAA;AAAA;;AAAA,cAqBpBC,gBArBoB;AAAA,iGAqBD,kBAAOC,QAAP;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCACT,MAAKH,QAAL,CAAc,EAACG,kBAAD,EAAd,CADS;;AAAA;AAEf,sCAAKF,cAAL;;AAFe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,aArBC;;AAAA;AAAA;AAAA;AAAA;;AAAA,cA8BpBG,YA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AgBC,KAAzB;AAAA,qBAFT;AAGI,iCAAY,4CAHhB;AAII,2BAAOZ,KAJX;AAKI,8BAAU;AAAA,4BAAaA,KAAb,SAAGuC,MAAH,CAAavC,KAAb;AAAA,+BAA2B,OAAKD,QAAL,CAAcC,KAAd,CAA3B;AAAA,qBALd;AAMI,6BAAS;AAAA,+BAAM,OAAKO,YAAL,CAAkB,OAAlB,CAAN;AAAA,qBANb;AAOI,4BAAQ,KAAKgB,SAPjB;AAQI,+BAAW,KAAKC;AARpB,kBADJ;AAWI,uDAAK,WAAU,MAAf,GAXJ;AAYI;AACI,yBAAK;AAAA,+BAAS,OAAKX,WAAL,GAAmBD,KAA5B;AAAA,qBADT;AAEI,0BAAK,UAFT;AAGI,iCAAY,sCAHhB;AAII,2BAAON,QAJX;AAKI,8BAAU;AAAA,4BAAaN,KAAb,SAAGuC,MAAH,CAAavC,KAAb;AAAA,+BAA2B,OAAKK,gBAAL,CAAsBL,KAAtB,CAA3B;AAAA,qBALd;AAMI,6BAAS;AAAA,+BAAM,OAAKO,YAAL,CAAkB,UAAlB,CAAN;AAAA,qBANb;AAOI,4BAAQ,KAAKgB;AAPjB;AAZJ,aADJ;AAwBH;;;EA7GiCiB,gB;;kBAAjB7C,Q","file":"index.js","sourcesContent":["import React, { Component } from 'react'\r\nimport { Input } from 'antd'\r\nimport { Keyboard, hotKey } from 'tplus-components-touch'\r\nimport './style.less';\r\n\r\nconst keyList = ['Shift', 'Backspace', 'Enter', 'Tab', 'CapsLock', 'Meta', 'Alt', 'Control', 'Delete']\r\nexport default class BindCard extends Component {\r\n keyPressStamp = null\r\n scanValue = ''\r\n constructor (props) {\r\n super(props)\r\n this.state = {\r\n value: '',\r\n password: ''\r\n }\r\n }\r\n componentDidMount () {\r\n // 设置输入框focus\r\n this.inputRef.focus()\r\n }\r\n onChange = async (value) => {\r\n let newValue = value\r\n // console.log(Date.now())\r\n newValue = value.replace(/[^a-zA-Z0-9]/g,'')\r\n // newValue = newValue.length > 16 ? newValue.substring(0, 16) : newValue\r\n await this.setState({value: newValue})\r\n this.changeDisabled()\r\n }\r\n \r\n // 密码框\r\n onPasswordChange = async (password) => {\r\n await this.setState({password})\r\n this.changeDisabled()\r\n }\r\n changeDisabled () {\r\n const { value } = this.state\r\n this.props.changeBindCardBtnDisabled(!value.length)\r\n }\r\n // 显示键盘\r\n KeyboardShow = (inputType) => {\r\n const { bindCardClick } = this.props\r\n const ref = inputType === 'value' ? this.inputRef.input : this.passwordRef.input\r\n Keyboard.open(v => {\r\n const code = inputType === 'value' ? this.state.value : this.state.password\r\n const value = Keyboard.getNewValue(ref, code, v);\r\n inputType === 'value' && this.onChange(value)\r\n inputType === 'password' && this.setState({password: value})\r\n }, () => {\r\n // 点击键盘的确定按钮,设置disabled\r\n this.changeDisabled()\r\n Keyboard.close() \r\n bindCardClick && bindCardClick()\r\n }, this.keyboardClose)()\r\n }\r\n // 点击键盘的关闭按钮,设置disabled\r\n keyboardClose = () => {\r\n this.changeDisabled()\r\n this.inputRef.blur()\r\n }\r\n // 输入框失去焦点,关闭键盘,设置disabled\r\n inputBlur = () => {\r\n Keyboard.close()\r\n this.changeDisabled()\r\n }\r\n handleKeyPress = async (ev, value) => {\r\n const { keyCode, key } = ev\r\n if (key && key.length && !keyList.includes(key)) this.scanValue += key\r\n // 扫描录入会自动触发enter\r\n if (keyCode === 13) {\r\n const currentStamp = Date.now()\r\n // 触发enter事件的时候,如果当前触发事件-上次keyDown事件大于300毫秒,说明是手动录入,否则是扫描录入\r\n if (currentStamp - this.keyPressStamp <= 300) {\r\n const newValue = this.scanValue.substring(0, 16)\r\n const password = this.scanValue.substring(16)\r\n const { bindCardClick } = this.props\r\n await this.setState({\r\n value: newValue,\r\n password\r\n })\r\n bindCardClick()\r\n }\r\n this.scanValue = ''\r\n } else {\r\n // keydown的时候保存当前时间戳,用来做是手动录入的还是扫描录入的判断\r\n this.keyPressStamp = Date.now()\r\n }\r\n this.changeDisabled()\r\n }\r\n\r\n render () {\r\n const { value, password } = this.state\r\n return (\r\n <div className=\"bind-card-container\" style={{ marginTop:' 14px' }}>\r\n <Input \r\n className={hotKey.hotKeyNotFilter('storageNo-input')}\r\n ref={input => this.inputRef = input}\r\n placeholder='请输入储值卡号'\r\n value={value}\r\n onChange={({ target: { value } }) => this.onChange(value)}\r\n onFocus={() => this.KeyboardShow('value')}\r\n onBlur={this.inputBlur}\r\n onKeyDown={this.handleKeyPress}\r\n />\r\n <div className=\"line\"></div>\r\n <Input \r\n ref={input => this.passwordRef = input}\r\n type='password'\r\n placeholder='请输入兑换码'\r\n value={password}\r\n onChange={({ target: { value } }) => this.onPasswordChange(value)}\r\n onFocus={() => this.KeyboardShow('password')}\r\n onBlur={this.inputBlur}\r\n />\r\n </div>\r\n )\r\n }\r\n} "]}
|