Commit e2aeb4e8 authored by 张伯涛's avatar 张伯涛

dsbridge通信

parent 396470d4
......@@ -28,6 +28,8 @@ import permission from './directive/permission'
import '@/icons' // icon
import '@/assets/icons' // icon
import '@/permission' // permission control
// 安卓h5交互
import { WebView } from '@/utils/WebViewContact'
/**
* If you don't want to use mock-server
......@@ -58,6 +60,7 @@ Viewer.setDefaults({
})
// 全局方法挂载
Vue.prototype.$WebView = WebView
Vue.prototype.getDict = getDict
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.parseTime = parseTime
......
const DS_BRIDGE = require('dsbridge')
// 拍照
export const openCamera = (params) => {
return new Promise(resolve => {
DS_BRIDGE.call('openCamera', params, res => {
resolve(res)
})
})
}
// 存储数据
export const saveLocationData = (params) => {
return new Promise(resolve => {
DS_BRIDGE.call('saveLocationData', params, res => {
resolve(res)
})
})
}
export const WebView = {
openCamera,
saveLocationData
}
<template>
<div class="setup_module">
<div class="button_row">
<el-button type="primary">扫码</el-button>
<el-button type="primary">拍照</el-button>
<el-button type="primary" @click="handleTest">扫码</el-button>
<el-button type="primary" @click="handleTakePhotos">拍照</el-button>
</div>
<div class="button_row">
<el-button type="primary" @click="handleOutbound">出库</el-button>
......@@ -13,7 +13,7 @@
<script>
export default {
name: "index",
name: 'Index',
data() {
return {
......@@ -22,6 +22,26 @@ export default {
created() {
},
methods: {
handleTest() {
const params = {
name: 'ceshi1312',
content: 'aaaaaaa'
}
this.$WebView.saveLocationData(params).then(res => {
console.log('提交后结果', res)
})
},
/** 拍照按钮*/
handleTakePhotos() {
console.log('调用前')
const params = {
name: 'ceshi1312',
content: 'aaaaaaa'
}
this.$WebView.openCamera(params).then(res => {
console.log('拍照', res)
})
},
handleOutbound() {
this.$router.push({
path: '/setup/outbound'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment