king
2020-12-30 e003a8ee8843aa60b0b7135f413b2b99857acff9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
import React, {Component} from 'react'
import { NavBar, Icon, InputItem, List, Popover, Button } from 'antd-mobile'
import moment from 'moment'
 
import Utils from '@/utils/utils.js'
import './index.scss'
 
const Item = Popover.Item
const viewParams = [{
  id: '1592367218835q9cgh8kcbeoop2kdroa',
  config: window.btoa(window.encodeURIComponent(JSON.stringify({"version":1,"entrance":true,"label":"","uuid":"1592367218835q9cgh8kcbeoop2kdroa", "NextMenuID": "1592367218835q9cgh8kcbeoop2kdrov"}))),
  pageParam: JSON.stringify({page: '广告页'})
}, {
  id: '1592367218835q9cgh8kcbeoop2kdrob',
  config: window.btoa(window.encodeURIComponent(JSON.stringify({"version":1,"entrance":true,"label":"","uuid":"1592367218835q9cgh8kcbeoop2kdrob", "NextMenuID": "1592367218835q9cgh8kcbeoop2kdrov","components":[{"type": "navBar", "uuid": "fasfdadsfadfjiasdijfodfijidsfj", sublist: [
    {uuid: 'sadfasdfsagsfdgsdfgfdfsf', label: "首页", type: 'tabview', field: 'blueTab', icon: 'minke-book-open', subcomponents: [{uuid: 'ddsfgtrhyysdfjucdsdyjsrefr', type: 'search', subtype: 'top-search'}, {uuid: 'ddsfgtrhyyjucdsdyjsrefr', type: 'list', subtype: 'carousel'}, {uuid: 'sadfasdfsagsfdgsdfgfdfsf', type: 'list', subtype: 'stab-list'}]},
    {uuid: 'ddsfgtrhyyjucdsdyjsrefr', label: "应用市场", type: 'tabview', field: 'redTab', icon: 'minke-eshop001', subcomponents: [{uuid: 'ddsfgtrhyyjucdsdyjsrefr', type: 'list', subtype: 'carousel'}]},
    {uuid: 'ddsfgtrhyyjudsfsdfyjsrefr', label: "控制台", type: 'tabview', field: 'greenTab', icon: 'minke-window', subcomponents: [{uuid: 'ddsfgtrhyyjudsfsdfyjsrefr', type: 'list', subtype: 'card-list'}]},
    {uuid: 'ddsfgtrhyyjuyjdsfsgsfdsrefr', label: "消息", type: 'tabview', field: 'yellowTab', dot: true, icon: 'minke-notification', subcomponents: [{uuid: 'ddsfgtrhyyjuyjdsfsgsfdsrefr', type: 'list', subtype: 'noticebar'}]}
  ]}]}))),
  pageParam: JSON.stringify({page: '导航栏'})
}, {
  id: '1592367218835q9cgh8kcbeoop2kdroc',
  config: window.btoa(window.encodeURIComponent(JSON.stringify({label: "首页", type: 'tabview', field: 'blueTab', icon: 'minke-book-open', subcomponents: [{uuid: 'ddsfgtrhyysdfjucdsdyjsrefr', type: 'search', subtype: 'top-search'}, {uuid: 'ddsfgtrhyyjucdsdyjsrefr', type: 'list', subtype: 'carousel'}, {uuid: 'sadfasdfsagsfdgsdfgfdfsf', type: 'list', subtype: 'stab-list'}]}))),
  pageParam: JSON.stringify({page: '首页'})
}, {
  id: '1592367218835q9cgh8kcbeoop2kdrod',
  config: window.btoa(window.encodeURIComponent(JSON.stringify({label: "应用市场", type: 'tabview', field: 'redTab', icon: 'minke-eshop001', subcomponents: [{uuid: 'ddsfgtrhyyjucdsdyjsrefr', type: 'list', subtype: 'carousel'}]}))),
  pageParam: JSON.stringify({page: '应用市场'})
}, {
  id: '1592367218835q9cgh8kcbeoop2kdroe',
  config: window.btoa(window.encodeURIComponent(JSON.stringify({label: "控制台", type: 'tabview', field: 'greenTab', icon: 'minke-window', subcomponents: [{uuid: 'ddsfgtrhyyjudsfsdfyjsrefr', type: 'list', subtype: 'card-list'}]}))),
  pageParam: JSON.stringify({page: '控制台'})
}, {
  id: '1592367218835q9cgh8kcbeoop2kdrof',
  config: window.btoa(window.encodeURIComponent(JSON.stringify({label: "消息", type: 'tabview', field: 'yellowTab', dot: true, icon: 'minke-notification', subcomponents: [{uuid: 'ddsfgtrhyyjuyjdsfsgsfdsrefr', type: 'list', subtype: 'noticebar'}]}))),
  pageParam: JSON.stringify({page: '消息'})
}]
 
let pindex = 0
 
class CardList1 extends Component {
 
  state = {
    timer: null,
    status: '',
    sname: '播放',
    scanResult: ''
  }
 
  componentDidMount() {
    window.appScanResult = this.appScanResult
  }
 
  getCookie = (cname) => {
    let name = cname + '='
    let ca = document.cookie.split(';');
    for (let i = 0; i < ca.length; i++) {
      let c = ca[i].trim()
      if (c.indexOf(name) === 0) return c.substring(name.length, c.length)
    }
    return ''
  }
 
  componentWillUnmount() {
    const { timer } = this.state
 
    if (timer) {
      clearInterval(timer)
    }
  }
 
  speak = () => {
    if (window.GLOB.systemType === 'ios' && window.webkit) {
      this.setState({status: 'speak',sname: '播放'})
      console.log('您有新的订单,请及时处理。')
      window.webkit.messageHandlers.speak.postMessage('您有新的订单,请及时处理。')
    } else if (window.GLOB.systemType === 'android' && window.android) {
      this.setState({status: 'speak',sname: '播放'})
      console.log('您有新的订单,请及时处理。')
      window.android.speak('您有新的订单,请及时处理。')
    }
  }
  pause = () => {
    if (window.GLOB.systemType === 'ios' && window.webkit) {
      this.setState({status: 'pause', sname: '继续播放'})
      window.webkit.messageHandlers.pause.postMessage(null)
    } else if (window.GLOB.systemType === 'android' && window.android) {
      this.setState({status: 'pause', sname: '继续播放'})
      window.android.pause(null)
    }
  }
  stop = () => {
    if (window.GLOB.systemType === 'ios' && window.webkit) {
      this.setState({status: 'stop', sname: '重新播放'})
      window.webkit.messageHandlers.stop.postMessage(null)
    } else if (window.GLOB.systemType === 'android' && window.android) {
      this.setState({status: 'stop', sname: '重新播放'})
      window.android.stop(null)
    }
  }
 
  appScanResult = (val) => {
    this.setState({
      scanResult: val
    })
  }
 
  onSelect = (e) => {
    let val = e.props.value
 
    if (val === 'simplescan') {
      if (window.GLOB.systemType === 'ios' && window.webkit) {
        window.webkit.messageHandlers.callQrOrBarCode.postMessage(JSON.stringify({type: 0}))
      } else if (window.GLOB.systemType === 'android' && window.android) {
        window.android.callQrOrBarCode(JSON.stringify({type: 0}))
      }
    } else if (val === 'scan') {
      let params = {
        "func":"sPC_TableData_InUpDe",
        "ID":"",
        "LText":"",
        "LText2":"",
        "LText1": `/* 系统生成 */
          Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@ModularDetailCode nvarchar(50),@nvarchar7 nvarchar(50),@nvarchar9 nvarchar(50),@nvarchar1 nvarchar(50),@int2 decimal(18,0),@int6 decimal(18,0)
                
          select @nvarchar7='四川分厂',@nvarchar9='KR29D',@nvarchar1='@barcode@',@int2=24,@int6=35
          
          /* 凭证及用户信息初始化赋值 */
          select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='admin', @FullName='admin', @BillCode='', @ModularDetailCode=''
          
          /* 账期验证 */
          exec s_FIBVoucherDateCheck @ErrorCode=@ErrorCode OUTPUT,@retmsg=@retmsg OUTPUT
          if @ErrorCode!=''
            GOTO aaa
          
          /* 唯一性验证 */
          select @tbid='', @ErrorCode='',@retmsg=''
          select @tbid='X' from demo_table where nvarchar1='@barcode@'
          If @tbid!=''
          Begin
            select @ErrorCode='S',@retmsg='扫码成功'
            goto aaa
          end
          If @tbid=''
          Begin
            select @ErrorCode='E',@retmsg='非系统条码'
            goto aaa
          end
          
          aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`,
        "userid": this.getCookie('UserID'),
        "lang":"zh-CN",
        "SessionUid":"77f85glb5splf1r58lpp0cvcbguaal0u",
        "LoginUID": this.getCookie('LoginUID'),
        "appkey":"20191106103859640976D6E924E464D029CF0",
        "nonc": Utils.getuuid()
      }
 
      params.LText1 = Utils.formatOptions(params.LText1)
      params.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
      params.secretkey = Utils.encrypt(params.LText, params.timestamp)
 
      if (window.GLOB.systemType === 'ios' && window.webkit) {
        window.webkit.messageHandlers.callQrOrBarCode.postMessage(JSON.stringify({type: 1, interface: 'http://qingqiumarket.cn/MKWMS/webapi/dostars', params: params, scanField: 'barcode'}))
      } else if (window.GLOB.systemType === 'android' && window.android) {
        window.android.callQrOrBarCode(JSON.stringify({type: 1, interfaceurl: 'http://qingqiumarket.cn/MKWMS/webapi/dostars', params: params, scanField: 'barcode'}))
      }
    }
  }
 
  addConfig = () => {
    if (window.GLOB.systemType === 'ios' && window.webkit) {
      let result = ''
      try {
        result = window.webkit.messageHandlers.addConfig.postMessage(JSON.stringify(viewParams[pindex % 6]))
      } catch {
        console.log('H5 调用app的 addConfig 方法,传递当前需要保存的参数')
      }
      pindex++
      console.log(result)
    } else if (window.GLOB.systemType === 'android' && window.android) {
      let result = ''
      try {
        result = window.android.addConfig(JSON.stringify(viewParams[pindex % 6]))
      } catch {
        console.log('H5 调用app的 addConfig 方法,传递当前需要保存的参数')
      }
      pindex++
      console.log(result)
    }
  }
 
  updateConfig = () => {
    if (window.GLOB.systemType === 'ios' && window.webkit) {
      let _index = pindex === 0 ? 0 : pindex - 1
 
      let param = JSON.parse(JSON.stringify(viewParams[_index % 6]))
      param.pageParam = JSON.parse(param.pageParam)
      param.pageParam.isupdate = true
      param.pageParam = JSON.stringify(param.pageParam)
 
      let result = ''
      try {
        result = window.webkit.messageHandlers.updateConfig.postMessage(JSON.stringify(param))
      } catch {
        console.log('H5 调用app的 updateConfig 方法,传递当前需要修改的参数')
      }
      console.log(result)
    } else if (window.GLOB.systemType === 'android' && window.android) {
      let _index = pindex === 0 ? 0 : pindex - 1
 
      let param = JSON.parse(JSON.stringify(viewParams[_index % 6]))
      param.pageParam = JSON.parse(param.pageParam)
      param.pageParam.isupdate = true
      param.pageParam = JSON.stringify(param.pageParam)
 
      let result = ''
      try {
        result = window.android.updateConfig(JSON.stringify(param))
      } catch {
        console.log('H5 调用app的 updateConfig 方法,传递当前需要修改的参数')
      }
      console.log(result)
    }
  }
 
  deleteConfig = () => {
    if (window.GLOB.systemType === 'ios' && window.webkit) {
      let result = ''
      try {
        result = window.webkit.messageHandlers.deleteConfig.postMessage(JSON.stringify(['1592367218835q9cgh8kcbeoop2kdroa', '1592367218835q9cgh8kcbeoop2kdrob', '1592367218835q9cgh8kcbeoop2kdroc']))
      } catch {
        console.log('H5 调用app的 deleteConfig 方法,传递需要删除信息的id值')
      }
      console.log(result)
    } else if (window.GLOB.systemType === 'android' && window.android) {
      let result = ''
      try {
        result = window.android.deleteConfig(JSON.stringify(['1592367218835q9cgh8kcbeoop2kdroa', '1592367218835q9cgh8kcbeoop2kdrob', '1592367218835q9cgh8kcbeoop2kdroc']))
      } catch {
        console.log('H5 调用app的 deleteConfig 方法,传递需要删除信息的id值')
      }
      console.log(result)
    }
  }
 
  clearConfig = () => {
    if (window.GLOB.systemType === 'ios' && window.webkit) {
      let result = ''
      try {
        result = window.webkit.messageHandlers.clearConfig.postMessage(null)
      } catch {
        console.log('H5 调用app的 clearConfig 方法,清空配置信息')
      }
      console.log(result)
    } else if (window.GLOB.systemType === 'android' && window.android) {
      let result = ''
      try {
        result = window.android.clearConfig(null)
      } catch {
        console.log('H5 调用app的 clearConfig 方法,清空配置信息')
      }
      console.log(result)
    }
  }
 
  queryConfig = () => {
    if (window.GLOB.systemType === 'ios' && window.webkit) {
      let _index = pindex === 0 ? 0 : pindex - 1
 
      let menuId = viewParams[_index % 6].id
      try {
        window.webkit.messageHandlers.queryConfig.postMessage(menuId)
        window.returnConfig = this.returnConfig
      } catch {
        console.log('H5 调用app的 queryConfig 方法,通过id请求配置信息。')
      }
    } else if (window.GLOB.systemType === 'android' && window.android) {
      let _index = pindex === 0 ? 0 : pindex - 1
 
      let menuId = viewParams[_index % 6].id
      try {
        window.android.queryConfig(menuId)
        window.returnConfig = this.returnConfig
      } catch {
        console.log('H5 调用app的 queryConfig 方法,通过id请求配置信息。')
      }
    }
  }
 
  returnConfig = (param) => {
    console.log('app返回:' + param)
  }
 
  render() {
    const { sname, scanResult } = this.state
 
    return (
      <div className="top-search">
        <NavBar
          mode="light"
          icon={<span>云产品</span>}
          onLeftClick={() => console.log('onLeftClick')}
          rightContent={
            <Popover mask
              overlayClassName="fortest"
              overlayStyle={{ color: 'currentColor' }}
              visible={this.state.visible}
              overlay={[
                (<Item key="4" value="simplescan" >扫一扫(单)</Item>),
                (<Item key="6" value="scan" >扫一扫</Item>),
                (<Item key="5" value="special" style={{ whiteSpace: 'nowrap' }}>拍照</Item>),
              ]}
              align={{
                overflow: { adjustY: 0, adjustX: 0 },
                offset: [-10, 0],
              }}
              // onVisibleChange={this.handleVisibleChange}
              onSelect={this.onSelect}
            >
              <div style={{
                height: '100%',
                padding: '0 15px',
                marginRight: '-15px',
                display: 'flex',
                alignItems: 'center',
              }}
              >
                <Icon type="ellipsis" />
              </div>
            </Popover>
          }
        >
          <List>
            <InputItem
              placeholder="大家都在搜"
              clear
              onChange={(v) => { console.log('onChange', v); }}
              onBlur={(v) => { console.log('onBlur', v); }}
            ></InputItem>
          </List>
        </NavBar>
        <div style={{padding: '15px 20px'}}>
          <Button type="ghost" inline size="small" style={{ marginRight: '20px' }} onClick={this.speak}>{sname}</Button>
          <Button type="ghost" inline size="small" style={{ marginRight: '20px' }} onClick={this.pause}>暂停</Button>
          <Button type="ghost" inline size="small" onClick={this.stop}>停止</Button>
        </div>
        <div style={{padding: '15px 20px'}}>
          <p>页面配置信息</p>
          <Button type="ghost" inline size="small" style={{ marginRight: '20px' }} onClick={this.addConfig}>添加</Button>
          <Button type="ghost" inline size="small" style={{ marginRight: '20px' }} onClick={this.updateConfig}>修改</Button>
          <Button type="ghost" inline size="small" style={{ marginRight: '20px' }} onClick={this.deleteConfig}>删除</Button>
          <Button type="ghost" inline size="small" style={{ marginRight: '20px' }} onClick={this.clearConfig}>清空</Button>
          <Button type="ghost" inline size="small" onClick={this.queryConfig}>查询</Button>
        </div>
        {scanResult ? <div style={{padding: '5px 20px 15px'}}>扫码结果:{scanResult}</div> : null}
      </div>
    )
  }
}
 
export default CardList1