Commit 4ba29899 authored by 李俊赕's avatar 李俊赕

二维码扫描组件

parent 780a01e6
...@@ -3,27 +3,20 @@ ...@@ -3,27 +3,20 @@
<view class="u-flex"> <view class="u-flex">
请输入:<u-input class="u-flex-1" v-model="dataValue" @input="valueChange" type="text" /> 请输入:<u-input class="u-flex-1" v-model="dataValue" @input="valueChange" type="text" />
</view> </view>
<view class="u-flex" @click="getScan('')"> <view class="u-flex" @click="scanCode">
<view class="txt u-flex-1">扫描二维码(仅挚达充电桩可扫描)</view> <view class="txt u-flex-1">扫描二维码(仅挚达充电桩可扫描)</view>
<u-icon name="arrow-right" color="#666" size="28"></u-icon> <u-icon name="arrow-right" color="#666" size="28"></u-icon>
</view> </view>
<!-- <view class="list u-flex u-row-between">
<text class="required" v-if="item.required">*</text>
<view class="u-m-r-20">{{item.fieldsTitle}}</view>
<view class="u-flex-1">{{valueTxt || ''}}</view>
<u-button type="primary" size="mini" @click="$u.debounce(getLocation,1000)">默认按钮</u-button>
</view> -->
</view> </view>
</template> </template>
<script> <script>
import objMixin from './objMixin' import stringMixin from './stringMixin'
export default { export default {
name: 'XhScan', name: 'XhScan',
components: {}, components: {},
mixins: [objMixin], mixins: [stringMixin],
props: {}, props: {},
filters:{}, filters:{},
data() { data() {
...@@ -42,33 +35,23 @@ ...@@ -42,33 +35,23 @@
watch: {}, watch: {},
mounted() {}, mounted() {},
methods: { methods: {
getScan(type){ scanCode(type){
const self = this
// qrCode 二维码;barCode 条形码
let scanType = type && [type] || ['qrCode']
uni.scanCode({ uni.scanCode({
scanType: ['barCode'], // scanType: scanType,
success: function (res) { success: function (res) {
console.log('条码类型:' + res.scanType); self.dataValue = res.result
console.log('条码内容:' + res.result); self.valueChange(res.result)
// console.log('条码类型:' + res.scanType);
// console.log('条码内容:' + res.result);
} }
}); });
}, },
getLocation() { // setValue(txt) {
let self = this // this.valueChange(this.dataValue)
const dataValue = this.dataValue || [] // }
const waterInfo = this.waterInfo
uni.getLocation({
type: 'gcj02',
success: function(res) {
dataValue.push(res.longitude)
dataValue.push(res.latitude)
self.dataValue = dataValue
self.setValue(dataValue)
},
fail(err) {}
});
},
setValue(txt) {
this.valueChange(this.dataValue)
}
} }
} }
</script> </script>
......
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