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
|